Grid component not exported
I would like to be able to use the grid() component because I'm implementing custom addLevel() functionality but the grid() function does not appear to be exported.
grid() component because doesn't offer much functionalities at the moment and only makes sense with built-in addLevel() so wasn't exporting it. If you're implementing custom addLevel() you can copy the grid() code or you might be better off implementing your own better version if you need it. Also curious about why you're doing your own addLevel and if the features you're thinking to build can be provided by kaboom
I'll share a REPL link here once I publish it to #kajam2021 😉
Long story short, I have a really big level, so loading the whole thing at once is not good (bombs FPS to < 10). So I implemented a quad tree and a version of Level that tracks the camera position and loads/unloads blocks on demand. Using this instead of addLevel() is a little more challenging in some cases because your game objects lose their local state. So if you have something like a treasure that the player picks up, you need to track the state of whether the player has picked it up outside of the game object itself (or relying on destroy()). However, since the object factory functions get the position, you can store your state in an object that is persistent for the whole scene, instead of just within that one comp (just make it a multi dimensional array or object that you can look your state up in by position).
Update, here's the link: https://replit.com/@TeamKumuPaul/ToTheTop#code/level-loader.ts
Another difficult bit is supporting the grid() component since that means components spawned from the level grid can actually move between quads, and therefor when they should get unloaded changes 😅. My implementation assume that objects spawned by calling the Level.spawn function directly, as opposed to based on the level data, will live forever (I'm thinking about adding some eventing so that it is possible to detect when such an objects "home" quad is unloaded).
I have a really big level, so loading the whole thing at once is not good (bombs FPS to < 10)
I have the same problem. Think of a game like Zelda: A Link to the Past on SNES - it has some areas where the screen scrolls pretty far before you hit a boundary and do a transition to a new screen. It would be nice if Kaboom would help us handle this sort of thing, only rendering tiles a certain distance outside the visible window.
There was a rework of how levels and grids work. Now there is a tile() component. Can check here