Wednesday, February 11, 2009

Procedural Content Generation

Procedural content generation is sort of a hip topic in both indie and mainstream games. If a game developer can generate assets from their code rather than designing assets by hand, that can save time and reduce the storage size of the game (on optical media or a hard drive).

For example, in the Diablo series, dungeons are pseudo-randomly generated. The benefits of this are two-fold. Players never see the same dungeon twice, adding replay value, and developers didn't have to go through and setup each dungeon manually.

I wanted to experiment with this concept. I decided to start as simplely as possible, a random maze generator. Algorithms exist for this problem and can be easily found via Google, but I decide to roll my own for my first try.

My maze generator basically works like this:
  1. Generate an m-by-n array of #'s (#'s denote and impassable tile)
  2. Randomly pick 2 tiles (a start and end point) and mark them "S' and "E" respectively
  3. Clear a path between the start and the end (replacing the #'s with .'s). My algorithm just starts at the start point and moves around randomly until it gets to the end point.
You've probably deduced this doesn't work too well.

Sometimes I generate decent mazes like:


Or:



Other times, I get something way too easy like:



So, what have I learned? Generating content purely randomly often doesn't work out too well. Also, random levels aren't that fun.

I'm going to try to implement a real maze building algorithm and see how that goes.

Sunday, February 1, 2009

Wizard

Wizard is a game that evolved from the spike ball tech demo from my previous post.

You're a wizard in your tower and you have to kill the attacking goblins using your fireballs. Everything in the game is a physics object so things can bump into each other and stuff like that. The goblin's shields will reflect the fireballs but hitting them on the head kills them.

To throw a fireball you click and drag and that magnitude and direction of the drag determines the direction and velocity of your fireball.


Wizard from Scott Carr on Vimeo.

Here's the direct download link. I think you'll need to install the Microsoft XNA framework, which is included in the zip file.