melonjs / melonJS

a fresh, modern & lightweight HTML5 game engine
https://melonjs.org
MIT License
5.89k stars 646 forks source link

Make the entire engine modular #1091

Open L1lith opened 2 years ago

L1lith commented 2 years ago

I recently published the library Melon Solid. Unfortunately, there is no way to instantiate each game/canvas to a specific component on the page (which is bad if the a game component is put on the page, taken off again, and put back again, like in the side of client side routing, or simply if there 2 games on the same page). Basically what I need to make everything work properly would be a way to instantiate every part of the engine (the pool, video object, etc) so that I can have one instance for each game (this prevents games from overlapping in memory).

I talked to the author in discord so I'm pretty sure they're already aware, but I'm just opening an issue so we can track this issue and others can comment.

obiot commented 2 years ago

@L1lith making some progress here, with now game being an instance of Application (a new class).

Unfortunately this not yet though possible to create a different Application instance, as references to the "default" game are hardcoded a bit everywhere and need more rework for instances to work independently. This is the last bit though as all other required elements can also now or already be dynamically instantiated.

L1lith commented 2 years ago

I feel like this one kinda fits here too https://github.com/melonjs/melonJS/issues/1139