The last thing I got working was procedural generation of the game world. It will generate random rocks no matter how far you fly in any given direction, until the algorithm finally breaks down because the random seeds get too big (I really curious how far that is).
Now that I can generate the this enormous game world, the question becomes “How do I save the state of a practically infinite world!?” I obviously can’t save an infinite number of objects. I’ve peeked around a little inside Minecraft save-games, and I understand the basic approach used there. The world is divided up into “chunks” and only chunks that have actually been visited by the player are saved. No need to save stuff that the player hasn’t even seen yet. As a result, there’s no limit to how large the save-game can grow, but it only grows as much as the player roams around the map.
I decided to take a similar approach, but with a slight change that suits my world generation algorithm a little better. I only save the “diff” of what the player has done. Space is divided up into “sectors,” which are just square areas of space. As the player flies around, I generate rocks inside these sectors. But I don’t actually save any information about those rocks until the player does something to them (e.g. mines them). For example, if a rock is completely destroyed, I just add an entry to the saved state that says “rock 123 destroyed.” If the player ever comes back to that sector, I just generate all the rocks as I normally would, but when I come to rock 123, I skip it. Or if it has been partially mined, I’ll have some saved state that says “rock 123 mined, now has 500 hitpoints, next resource drop is 5 silicon,” etc…
So, the save-game can grow indefinitely, but it will stay about as small as possible. For now, I’m just saving the game in
localStorage, which is essentially a browser cookie. I don’t think that will work as the permanent solution because
localStorage tends to just randomly be erased. There are no guarantees about how much space you can use or how long it will last. The best idea I have for something better is to let the user download a save file and save it locally on their system. We’ll cross that bridge when we get to it.
Try out version 0.4.2.2. on the releases page. In this version, I’m currently saving any rocks that you completely destroy, any drops that you leave floating around (but their positions are all wrong), and your ship (where it is and what you’ve built).