RobLoach / raylib-duktape

zlib License
32 stars 0 forks source link

General questions about raylib-js #6

Closed bberak closed 2 years ago

bberak commented 4 years ago

Hi @RobLoach,

Thanks for sharing this project. I'm trying to get my head around using Raylib with Javascript, so apologies if my questions are silly.

Firstly, would I be right in saying that raylib-js creates a JS context, fills it with raylib goodies and then instantiates an embedded JS engine which then interprets my .js files?

Secondly, I noticed that some of the functions in this include file are commented out. Does that essentially mean we cannot reference the 2D camera in our .js files?

Lastly, I also saw that you're also working on NodeJS bindings for raylib. What would be the recommended use-case for using this project over the other (or vice versa).

Thanks again for all the work, your projects look really interesting.

Cheers!

RobLoach commented 4 years ago

Hi @bberak! Thanks for checking it out...

Firstly, would I be right in saying that raylib-js creates a JS context, fills it with raylib goodies and then instantiates an embedded JS engine which then interprets my .js files?

Correct. raylib-js uses Duktape, which is a mini-JavaScript scirpting engine.

Secondly, I noticed that some of the functions in this include file are commented out. Does that essentially mean we cannot reference the 2D camera in our .js files?

Likely because the full integration isn't quite there yet. Dukglue is a wrapper for objects and structs, but doesn't bring everything over. Some additional padding is sometimes needed.... The Camera struct, in this case, likely isn't fully implemented.

Lastly, I also saw that you're also working on NodeJS bindings for raylib. What would be the recommended use-case for using this project over the other (or vice versa).

Using Node.js for it is pretty nice. Duktape means you can use the native Raylib implementation, and use JavaScript as a scripting engine for your desktop application. Duktape is a very small dependecy, which is nice. While Node.js is a big dependency, I've found that Duktape is slower than Node.js.

I'd also like to reconsider using Emscripten and WebAssembly for this too. Learned a lot about WASM over the past year, and would like a go at using a WebAssembly build of Raylib, with a JavaScript bridge for it.

bberak commented 4 years ago

Thanks for the info @RobLoach - I'm quite excited about this.. I've been looking for a lightweight (non-chromium based) way to develop simple games and graphical interfaces using Javascript - and I think raylib with a combination of your projects could make this possible. I'm also keen to hear about any progress you make with Emscripten and WASM. This lower-level stuff is not my forte at the moment, but I'll look to contribute back to your repos if possible.

Lastly, between node-raylib and raylib-js - which project would you say is further along in terms of raylib coverage?

Cheers and have a great weekend!

RobLoach commented 3 years ago

Lastly, between node-raylib and raylib-js - which project would you say is further along in terms of raylib coverage?

node-raylib.

RobLoach commented 2 years ago

Thanks for the interest!!! This'll be incase you want to embed the JS runtime. node-raylib is better generally though.