Closed Phlosioneer closed 1 year ago
The emscripten examples (like https://www.flecs.dev/tower_defense/etc/) are indeed projects that run standalone in C/C++ with little to no JS code involved.
If you want to build a JS game with Flecs you'll have to manually wrap the Flecs functions you want to use, and export them with EMSCRIPTEN_KEEPALIVE
(which admittedly would be a lot of work).
You can alternatively take a look at the Flecs Javascript library: https://www.flecs.dev/explorer/flecs.js which wraps around the Flecs REST API.
This JS API is not really optimized for client-side game development though, as it is more intended for connecting to a (remote) running (C/C++) flecs application.
TL;DR: it's possible but will likely require quite a bit of work.
Thanks for the quick reply. It seems like it'll be too much work to integrate it; I'll look for alternatives, or maybe a mini re-implementation.
I'd like to use FLECS for a javascript game. Emscripten support is shown on the readme, but all the examples of that seem to use FLECS as a library in a larger C or C++ project. For FLECS by itself, I don't see any
EMSCRIPTEN_KEEPALIVE
macros.Is this possible? I'm still very new to Emscripten, I might just be missing something obvious.