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.

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.

Tuesday, January 27, 2009

Video: tech demo of my next game


Tech demo from Scott Carr on Vimeo.

The next game I'm working on is going to use Microsoft's XNA framework.

The physics engine I'm using is Farseer.

Saturday, January 24, 2009

You gotta know when to fold 'em

I've decided to cut my losses and abandon production of "Rap Hero." I think having the player type in rap lyrics then having a robotic voice echo them back is an interesting concept but it'd take a lot of work to get the game to the point where the average user would want to play it.

I still think hearing a robotic speech synthesis voice rap is funny, but it's hard to make a game around it. I was planning on doing something with regular expressions to determine if the player's lyrics rhyme, but I got frustrated before I got around to it.

The most frustrating part is that all the speech synthesis engines I found were for Linux. For me, I have to put a lot more effort into getting what I want than I do on Windows. Having years and years more experience with Windows might be the reason for that.

Here's my code if you're interested in playing that game (you're going to have to compile it yourself [yay linux!]). You need eSpeak and its library installed.

//============================================================================
// Name : eSpeak1.cpp
// Author :
// Version :
// Copyright :
// Description :
//============================================================================

#include
#include "espeak/speak_lib.h"
#include
using namespace std;

int main() {

const int SONG_LENGTH = 2;

string buffer_string;
string song[2];
//string blanks = "________";
string whole_song;
bool quit = false;
//char garabage;

// string myString = "We used poisonous gases. We poisoned their asses.";
//int synth_flags = espeakCHARS_AUTO | espeakPHONEMES;

espeak_Initialize(AUDIO_OUTPUT_SYNCH_PLAYBACK, 100, NULL, 0);

//espeak_SetSynthCallBack(SynthCallback);

//espeak_Synth(myString.c_str(), myString.length(), 0, POS_SENTENCE , 0, 0, NULL, NULL);

espeak_Synchronize();

song[0] = "Yo! Yo! I got a taste for expensive things \n like fast cars and ";

song[1] = "Pull my sleeve to flash my rolex \n all the fly honeys call me ";



cout << "**** Welcome to Rap Hero! *****\n";
cout << "A line of lyrics will appear on the screen. \n";
cout << "You need to type in the end of the next line to make it rhyme with the previous. \n";
cout << "At the end, your rap will be played back so you can hear it. \n \n \n \n";
//cin >> garabage;


for( int i = 0; i < SONG_LENGTH; i++)
{
cout << song[i];
cout << "\n";
getline(cin, buffer_string);
//song[i] += buffer_string;
//cout << song[1];
whole_song += song[i];
whole_song += buffer_string;
whole_song += "\n";
}



cout << whole_song;

espeak_Synth(whole_song.c_str(), whole_song.length(), 0, POS_SENTENCE , 0, 0, NULL, NULL);

//cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}

Wednesday, January 21, 2009

Teaser

My next game will (hopefully) feature text-to-speech (speech synthesis) technology.

Check out a demo here: http://www.cstr.ed.ac.uk/projects/festival/onlinedemo.html