Open jarcane opened 4 years ago
I think since assets
is already designed as a function, it might make sense to pass it state
and call it during the game loop - I don't think it would even be necessary to call it every frame, maybe twice a second or so - so that you can load (and unload) assets at will during runtime. I recognize this complicates the architecture of start!
and game-loop!
, and there is an open question about what should be available in the assets map while assets are loading, however.
Yeah. In-game loading is not something that was ever really considered; I mostly designed this for small arcade games like the demo. But during dev I experimented a lot with procedurally generating some of the assets with JS image manipulation tools, and I had to ditch it because it was too slow and the processing would hang the thread. If there were some safe async way we could do stuff like that it'd still be handy.
Something which would be useful to improve user experience when employing procedurally generated assets is to be able to generate them ahead of time during the loading screen, preventing visible slowdown or freeze during game startup.
The best method I've come up with so far for this is to add a new data type to the asset loader,
:function
, which accepts a function which takes a callback, executes that function, and then the callback responds as if on-done event. Proposal here is vague, because this is about all I've got so far on this idea.