Developer Diary 40 - Loading/Saving Implemented
The last few days have been very exciting for me! I sat down and began coding a saving system that actually writes to file. I had never attempted anything like it, so I was a bit scared to begin working on it. But quite quickly, I was able to save the relevant variables to an external file, and load those back in. At this point, I was very happy with the results. Everything seemed to be working well. I just needed to find a place where the game can save and load. Since the player cannot choose themselves when to save or load, I needed to find the best spot when to do these operations. The game only loads once: when you start the game after closing it, and pressing the start button. Saving, on the other hand, happens on three different occasions: when you earn money, spend it, and when day becomes night and vice versa.
Things seemed to be working on PC so I decided to give it a go on mobile. It's actually much harder to test on mobile than it is on PC. Normally I press the play button and run the game, to see how it behaves. For mobile, however, I need to build an .APK, upload it, then download and install it on mobile. That takes easily 10 times more time than testing for PC. I installed the .APK and the worst seemed to be true: the game was completely broken on mobile after implementing the saving feature. It really made me very sad, so I made a test project which focused just on the saving/loading process. To my surprise, this worked flawlessly, so I went back to the actual project and inspected my code. After a long time staring, I noticed I had used a single quote (') where in the other project I had used a double quote (") to refer to the file. I knew this was a mistake but didn't assume that would solve it, but built the .APK anyway. To my total shock, everything worked perfectly. I couldn't believe how such a small mistake could make such a big impact to my code. But it works, and that is the important part!
This is a really, really big step. Finally, doing an action is the game actually matters beyond the few minutes I would spend testing. Now, when you change the appearance of the character, it will stay that way! That’s honestly got me very excited.
I didn’t know if I could pull of a system like this, let alone in a matter of days. The only thing left to do now is to polish things up a bit, add some minor details and then start the lengthy process of killing as many bugs as I can. After that, you will get your hands on release 3 on both Windows and Android!
As always, thank you very much for your support <3
Albatross
Comments (3)
Yes, it is really surprising that everything was successfully resolved with bugs, good luck in further work.
Tiny mistakes in computer science destroy everything or show you had more errors then you thought
Awesome, glad things are working out!
