I implemented actual saving, along with a bunch of other bug fixes and code cleanups that have been bugging me for months. It turns out that saving is so fast it’s unnoticeable, so I built in some fake delay to make it seem like something is actually happening. This is what it looks like when it happens:
You will never believe how Microsoft officially recommends you save game data. Well, maybe you would.
string filename = "savegame.sav"; // Check to see whether the save exists. if (container.FileExists(filename)) // Delete it so that we can create one fresh. container.DeleteFile(filename); // Create the file. Stream stream = container.CreateFile(filename); // Convert the object to XML data and put it in the stream. XmlSerializer serializer = new XmlSerializer(typeof(SaveGameData)); serializer.Serialize(stream, data); // Close the file. stream.Close();
That’s right: the official developer documentation for XNA tells indie game developers they should delete the existing save file before writing the new one to disk. Normally my issue with Microsoft’s documentation is the byzantine twists required to track down the simplest piece of useful information. But I don’t know if I’ve ever before seen them give advice that wasn’t just bad, but dangerously wrong.
Next up is the screen management system (menu screens, etc) that was too big to start until I did some cleanup, leading to me finally renaming the game assets from “Arena” to “Enceladus.” I started the game project under the name “Arena” with the idea that it was just a test bed that I would throw away when I wrote the real game project. But, as always happens, the prototype slowly accreted into the actual project. I hadn’t bothered to change the name because I wasn’t sure exactly how to do it in Visual Studio, and also because I wasn’t completely sold on the name “Escape from Enceladus.” I happen to like the name a lot, but it’s a bit odd, and it also has the problem of being impossible to spell or pronounce for most people, which will make word of mouth marketing pretty tough. Today I finally decided I didn’t care and pulled the trigger. It’s kind of incredible how much more real that makes the game feel.