foreignsasquatch / raylib-hx Goto Github PK
View Code? Open in Web Editor NEWHaxe bindings for raylib, a simple and easy-to-use library to learn videogame programming
Home Page: https://raylib.com
License: zlib License
Haxe bindings for raylib, a simple and easy-to-use library to learn videogame programming
Home Page: https://raylib.com
License: zlib License
here canvas.texture.width or canvas.texture.height gives me a compiler error cuz its trying to acesss width and height with "->" operator
public function new(initialState:State) {
canvas = Rl.loadRenderTexture(320, 180);
var w = canvas.texture.width;
var h = canvas.texture.height;
sourceRect = Rectangle.create(-360, -180, 360, -180);
destRect = Rectangle.create(-360, -180, 1280 + (360 * 2), 720 + (160 * 2));
switchState(initialState);
}
void Game_obj::__construct( ::fucciboiGDX::State initialState){
HX_STACKFRAME(&_hx_pos_69efd8c9269cf369_22_new)
HXLINE( 23) this->canvas = LoadRenderTexture(320,180);
HXLINE( 24) int w = this->canvas->texture->width;
HXLINE( 25) int h = this->canvas->texture->height;
HXLINE( 26) this->sourceRect = Rectangle{ (float)-360, (float)-180, (float)360, (float)-180 };
HXLINE( 27) this->destRect = Rectangle{ (float)-360, (float)-180, (float)2000, (float)1040 };
HXLINE( 28) this->switchState(initialState);
}
heres the code I was trying to copy from the raylib examples
Rectangle sourceRec = { 0.0f, 0.0f, (float)target.texture.width, -(float)target.texture.height };
Rectangle destRec = { -virtualRatio, -virtualRatio, screenWidth + (virtualRatio*2), screenHeight + (virtualRatio*2) };
i tried patching the bindings but both RenderTexture and Texture types already have the @:structAccess modified so idk what could be wrong
Is there a vscode launch/task combo available?
Hi! can you please update wasm build config and wasm sample? I tried to use current wasm config from Web.xml with config from this commit
17e69ce#diff-5469ce10da37fb1a0de753a53e529b132ebe1f9e097a0ed958f164b4e2c66a4c
but I just got strange errors
Link: BasicWindow.html
error: bin does not exist
em++: error: '/opt/homebrew/Cellar/emscripten/3.1.31/libexec/tools/file_packager BasicWindow.data --from-emcc --preload bin' failed (returned 1)
Error: Build failed
I've installed the library and all the dependencies but unfortunately the example in your ReadMe doesn't work out of the box.
I get the following error:
src/Main.hx:14: characters 24-32 : Class<Raylib> has no field DrawText
If I remove line 14 it compiles and runs perfectly, no issues. But it doesn't like the call to DrawText()
.
I assume this function has been implemented otherwise you wouldn't put it in your ReadMe as an example, so maybe something's broken in the library?
There are some functions that can be seen in the raylib cheatsheet but that aren't currently on the library. For example, setWindowIcons, setWindowMaxSize or ToggleBorderlessWindowed. Why is this?
Line 328 in Raylib.hx reads:
static inline function create():Camera
should read:
static inline function create():Camera2D
It would be really nice to add extra targets to the library like hl
, js
, python
, c#
etc; Progress on any of these will be documented here. Any help would be appreciated
Hello! Can you update to the latest stable version ? And how can we help you to keep this project always updated?
So I've noticed that there are two conventions as for the enums:
MOUSE_CURSOR_DEFAULT -> Raylib.MouseCursor.MOUSE_CURSOR_DEFAULT
MOUSE_BUTTON_LEFT -> Raylib.MouseButton.LEFT
The shorter seam nicer but either is better than both imo.
Not sure if worth the hustle though - let me know; I can prepare a pr for that.
Hello, when i'm trying to create a Rectangle and then draw on screen, I get this error when i compile.
Here is the code i'm using.
import Raylib.Rectangle;
import Raylib.Colors;
import Raylib.*;
class Main
{
static function main()
{
var screenWidth = 800;
var screenHeight = 450;
InitWindow(screenWidth, screenHeight, "Draw a rectangle");
SetTargetFPS(60);
var rect = Rectangle.create(100, 100, 36, 36);
while(!WindowShouldClose())
{
BeginDrawing();
DrawRectangle(Std.int(rect.x), Std.int(rect.y), Std.int(rect.w), Std.int(rect.h), Colors.RED);
EndDrawing();
}
CloseWindow();
}
}
Hi! ๐ It's my first day with haxe and raylib. I tried to draw an image and I had a problem with using DrawTextureRec
. According to the cheatsheet the function should accept a vector and a rectangle, but the bindings say that it should be two rectangles.
Compare this
void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
to this
@:native("DrawTextureRec") static function DrawTextureRec(texture:Texture2D, source:Rectangle, dest:Rectangle, tint:Color):Void;
So it seems like there's a bug in the version available for haxe? ๐ค
Cheers!
Improvements that need to be done and stuff that you want to changed. Use this issue to tell them
To-Do:
Haxe Code:
class Main {
static function main() {
var logo:Rl.Image = Rl.loadImage("Assets/logo.png")
Rl.imageFormat(logo, Rl.PixelFormat.UNCOMPRESSED_R8G8B8A8);
Rl.initWindow(800, 450, "Spatial");
Rl.setWindowIcon(logo);
...
C++ Output:
void Main_obj::main(){
HX_STACKFRAME(&_hx_pos_e47a9afac0942eb9_4_main)
HXLINE( 5) const char* this1 = HX_("assets/logo.png",72,b4,d1,0d).utf8_str();
HXDLIN( 5) cpp::Struct< Image > logo = LoadImage(this1);
HXLINE( 6) ImageFormat(&(logo),PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
HXLINE( 7) const char* this2 = HX_("Spatial",a4,f0,48,6a).utf8_str();
HXDLIN( 7) InitWindow(800,450,this2);
HXLINE( 8) SetWindowIcon(logo);
Build Output;
Error: Main.cpp
./src/Main.cpp(34): error C2664: 'void ImageFormat(Image *,int)': cannot convert argument 1 from 'cpp::Struct<Image,cpp::DefaultStructHandler> *' to 'Image *'
./src/Main.cpp(34): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:/Users/ACER/Code/Haxe/lib/raylib-hx/source/lib/src/raylib.h(1231): note: see declaration of 'ImageFormat'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.