Nerdsworth Academy

A rather poorly rendered mountain.

Developer Diary | Saving the World… and buttons

Posted at

I’m only going to have a few minutes for an update on the status of Splatterfield. Unfortunately, I didn’t make much progress in the last couple of days and I’m going to be going on a Thanksgiving vacation starting tomorrow, so I won’t be able to work on it at all until the weekend at the very earliest. I may not even be able to blog or play games either! Ohnoes!

Saving the World

Already I'm excited to get in there and see if I can build something awesome.

Already I’m excited to get in there and see if I can build something awesome.

The main thing that I got working was a save state for the world itself. Essentially the entire map object is dumped to a file on the hard drive using a Python function called Pickle. It’s a specially structured file that contains all of the object’s information. Once the object has been pickled, it can then be unpickled again to restore its state in the program.

So, essentially what happens is that when the game runs it checks to see if it has been called with a load_map flag, and if it has, it loads a specific map that I’ve been using as a placeholder. At any time after editing the map, you can press “m” and write out the current state of the map to the disk. Then, the next time the game starts up, it uses the updated map. Pretty slick.

Although it only ended up being a few lines of new code and some modifications to my old functions, this is a pretty big deal. From a debugging standpoint too it will be handy, since I can craft a setup to test something and then save it. Also, this is a fairly important part of the creation mode.

And, I can use the same method for saving other kinds of objects later on as well. If I want to create custom characters that stay with you from one battle to the next, for instance. Or record information about player performance or combat statistics.


I've added the buttons for saving, loading, resetting, and randomly generating maps... but none of them do anything just yet.

I’ve added the buttons for saving, loading, resetting, and randomly generating maps… but none of them do anything just yet.

Right now the loading and saving goes to the same placeholder.txt file… which isn’t going to be particularly useful.

I’ll need to add the ability for the user to choose whether to generate a new map or load an existing map as well. While I haven’t nailed this functionality down yet, I did experiment a bit today with the DirectUI object in Panda3D. It allows you to add buttons and other typical UI elements to the game.

So far, I’ve only added a few placeholder buttons, and it’s something that I’ll have to work on when I get back.

Then, I’ll need to build out the functionality for saving and loading named files, which shouldn’t be too bad. The generating should be similar to what I did in Quadril, and resetting to a default state only requires that I save out a default state.

I hope that everyone has a wonderful Thanksgiving! Stay tuned for more updates!


Leave a Reply

Your email address will not be published. Required fields are marked *