Hi all!
I’m implementing a simple multiplayer game engine for learning purposes, as I want to understand better EC systems, physics and generally “backend game development”. In what follows, completely ignore the rendering part - I’m not interested in the clients for now.
This is the basic idea:
- 3 coordinates world (XY for the horizontal planes, Z for height), composed of particles (small moving spheres but not masseless) only colliding with the Ground or with AABBs (walls, ceilings and floors), but not among themselves (ie, they can be at the same point in space)
- three “materials”: ground, impenetrable; water, realistic with drag & buoyancy; air, realistic with drag & buoyancy
- the “normal” plane, where particles initially move on, is the plane Z=0. Below that is either ground or water (but most often ground), above that is air (but it might be ground, if there is a natural “zigurrat” or floating islands)
Now, the world can change: ground can be dug and made Air (ie, a hole), or “rise” and become a zigurrat-like structure. For now, I only need to save what of these 3 types a “cell” is, but in future the cell can be more complex (saving inside properties for example, be of more materials etc)
My basic/prototype idea would be to make the map a binary file, then memory map it so the modifications are persisted. However this can lead to the map corruption, and is not scalable (sure, RAM is cheap these days… but it’s an annoying limit/waste nonetheless).
Another possibility would be a sparse format for the map, and/or dividing and loading the world in fixed chunks. This would allow to save space in disk (first option), and to cache the chunks actually in use without loading the others, saving loads of RAM.
I’m sure though I’m re-inventing the wheel, possibly in bad ways - so I turn to you for advice what do you think? do you know of any stable java libraries that do this, maybe even save in some known format, so I’ll be able to couple it with a world generator (given the constraints above)?
Thanks for any advice you can give.