Sunday, June 21, 2009

Breakout (XNA) - Update 7: Level Creator

Remember that level creator I kept mentioning would be cool, but never actually got around to creating? Well, that's history now, because I've finally managed to build one. Ok, so it's a little basic, but a person can now go in and click where they would like to place the bricks. Then it saves it to an XML file to be used later. Right now only one level can be saved at a time, so creating a new level will kill the old one, but I hope to fix that at some point and allow the player to choose which level they'd like to use.

Creating this level creator actually wasn't too difficult... saving it was a bit of a pain though. Luckily this tutorial was there to make things a little easier. It helped a lot with reading the XML files. Then I happened across this blog that taught me how to write the XML files. Of course I was still having problems since I wanted to store a number of bricks and the information in each file. At first I was passing the individual array fields to the serializer, but that wasn't working. Then I tried passing the entire array, and that was much better, but still wasn't giving me a readable array type (you'll see what I mean if you look at the XML file and the pages I gave you). Finally, I passed a list as the parameter. For some reason, it took me way longer than it should have to figure that out, but at least now it's working. And it turns out that working with XML in XNA really isn't too much of a problem in the first place. If you find you still need help with the XML after reading those two pages and checking out my code, let me know. I'll do what I can.

So, check out the code and have a look. Maybe you can make some improvements. Maybe put in some file handling to create new files for each level, or maybe even a way to edit previous levels. Hmm, sounds like fun! Either way, I think my time with Breakout is winding down. Maybe I'll do a few more things like figure out the file handling aspect, but other than that, it may be time to move on to bigger and better things. Please let me know what you think or if you have any suggestions. I really haven't been getting much feedback and even a "what's up?" is nice sometimes! Have a good one and, good luck with the coding!

No comments:

Post a Comment