Save, load, save, load then repeat
As the title says... most of the week was spent working on saving and loading. I've done save/load once before, I did a save anywhere, anytime and everything solution. It was highly educational, in particular with using generics, but also took some time to create...
This time around I've decide to do a slightly more lightweight solution where the game saves at certain checkpoints only. Doing so gives you the ability to decide in much greater detail what you want to save, you can do specific save rooms for example and in those have nothing that changes appearance and only save whatever progress has been made. I'm adding some saving capabilities beyond progress tracking, thinking that the checkpoints should be somewhat easy to have in the levels and keep a nice flow.
A month or so ago, when I first started with this project, I quickly did a test to save and load object basic data, like position and velocity. Worked nicely and when I began working on the proper save/load, I simply continued on the tests that I had done ealier. Dumb mistake! Thankfully I did not spend too much time with it until I realized some planning might be good to have. Coffee + cookies = planning.
burp Planned how the game loads everything and where the save data should be injected in this process. In short the game first loads the map data from Tiled, then any basic scene create/loading is done, all the objects are created, all objects are told all objects are created and can do any in-between them configuration. At this point a level load is finished for how it is when you first load the level. If you are loading a saved game, here is where the next step comes in and the scene loads the saved data. It removes objects that were no longer present when the save was made and adds in new objects that had been created at the time of the saving. Then it continues with objects and they load any save data they might have and after that all is good to go for the player.
I've been trying to do everything so it works properly, but not 100% complete. Thinking I should move on as quickly as possible and go back later and improve as needed.
So far I have:
- Basic gameobjects data for position, velocity, rotation etc
- Tracking objects destroyed/added.
- Sensors/Collisions keep their state.
- Tweens. These are fantastic! Phaser has lots of great stuff, but tweens really are something. I've added basic support for tweening, but left out callbacks, timelines and more advanced features.
Left to do:
When done with the last two, the test game is fully savable.
Have a splendid weekend!
(I did my best to use d.tube but unable to upload video yesterday and not today either, had to fallback on youtube)