Thursday, July 16, 2009

Platformer 2

My latest project is a simple platformer game that is pretty bare bones but could serve as the base code for future projects.

My first idea was to make a platformer with an easy to use level editor. Experience has taught me that making a nice UI is difficult/time consuming so I decided to create Scaled Vector Graphics files in Adobe Illustrator and use those to represent my level. This is actually pretty simple and has worked out pretty well. An SVG file is just a text file that describes each shape in the image. Then all I have to do is make up a translation between shapes in the SVG file and levels in my game. For example, a black rectangle represents a regular impassable wall inside my game. So in my code all I have to do is read the SVG file and create walls at the specified location and size from the SVG file. I extended this idea to allow me to place enemies inside the level. Circles represent enemies or the player's spawn. The color of the circle tells the game what type of monster the circle represents or if it represents the player's spawn.




This idea is pretty cool, I think, because anyone who can use Illustrator can make a level for my game. Additionaly, the level maker can visually see the shape of the level as he/she is creating it.

You can download the executable here. Note that the character sprites are from the XNA Platformer Starter Kit and you need to have the XNA redistributable installed.

Importing your own levels is somewhat unimplemented/undocumented at this point, but you should be able to reverse engineering level_1.svg if you're interested. To import your own level name it level_1.svg and overwrite my level_1.svg.

Wednesday, July 15, 2009

Better Maze Algorithm


I've done some Google-ing and found a better maze building algorithm care of Mazeworks.com.

Basically, the algorithm works by creating a grid (a maze with every possible wall). Then the algorithm picks a start point randomly. Next, it goes around sort of drilling a path through walls, essentially destroying the wall between two cells and then moving to the next cell. It keeps drilling (back tracking if necessary) until each cell has been visited and no cell has no walls. Mazeworks has a great explanation here.

This is pretty awesome because the algorithm can build any size maze.

Try out my Maze Generator game here. You'll need the XNA redistributable as usual.