Monday, January 7, 2013

Platformer: saving and loading now works!


I was able to get the file loading and saving working using the structure I described in my previous post.

It works extremely well so far!

I did find a few bugs I need to fix:

1: Saving a file I do a getSpriteExists; if it fails then I write that particular block to be 0's. This later causes "empty" blocks in my structure so I need to do some sort of bubble sort on it.

2: The variable I use to determine what sprite # I'm on needs to be reset when I do a load.  For example if I put down 50 sprites and load the level it resets the sprite count back to 1 and each sprite I put down thereafter effectively deletes one of the loaded ones until I surpass the loaded sprite count (super easy to fix but just sharing what I saw).

Also I want to add some additional functionality such as loading/saving by name instead of hard coding it but I want to iron out the bugs before doing so.

But for my first 'level file format' I am jazzed at how well this is working!  Some times its great when you do some planning ahead of time and everything works out!

No comments:

Post a Comment