Geeks With Blogs
Code.Blog Code Talk for the Game Developer
Recently I've begun programming a new game I'm trying to keep under wraps a bit, although most close friends know what it's about already.  Although the game is quite new I'm already excited about the code.

In PongRPG, every sprite you see is positioned in code, there are lines that load each sprite personally and set them based on values in the code.  So, if I wanted to change the position of some item on the pause menu, I'd have to go into the code, track down that line, and change the value.  Not only that, but for each menu, I used a swapping method.  For every menu item there were two sprites, one displaying the non-active item, and one as the 'highlighted' version of the item.  When the user's mouse hovered within the sprite bounds, the non-active sprite would hide and the highlighted version would pop up.  This required the code to load 2 seperate sprites for each menu item, which in turn had multiple lines of code that statically set their position.

So how is the new code any different?  First off, I changed the way sprites are loaded.  Specifically for this style of game, it's more 'level-based' whereas Pong was really just repeated instances of the same level (as are most puzzle games), I use a definition file created as an XML file to load each level.  This way, I can create all my stuff in the XML and not have to change the code to load the items in.  This allows me to load and set properties like position without ever having lines of code specific to any certain sprite.  Also, the code will only load one instance of each sprite even if there are multiple uses for that sprite and I can continue to reference that sprite.

I've also heavily modified the way menus are created compared to Pong.  A big problem with Pong was if I wanted to ever port it to Xbox it would be quite a decent amount of work to create a cursor or implement a focus style menu.  I liked the idea of the focus style menu where each menu item has a focus and you can scroll through the items in the menu (similar to most all menus on the Xbox system).  In the new code, I have XML documents defining each menu, specifically each menu item including their position, and other menu information like the style of the menu.

There are loads of other changes but those are the ones that really stick out from Pong.  What really gets me excited is that I've designed code that is putting more and more of the game creation in the hands of the designers and content creators.  Yes, the menus still need code behind them to do specific actions, but I can have someone working on designing a menu and simply send me the menu sprites and the XML and I can load it in without writing any positioning or layout code.  Same goes for anyone designing Levels.

If I remember or get time, I'm planning on posting some code tutorials about the XML loading in XNA or some of the techniques I've described above. Posted on Friday, November 14, 2008 10:25 AM | Back to top

Comments on this post: The Wonder of Creator Content

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Matthew Christian | Powered by: