Cops and Robbers
[Note: The background music used in this tutorial was provided by one Mr. Nool. Head on over to his site to check out his free music pack and other goodies. Nice quality content and very much appreciated!]
Cops and Robbers was an idea that got stuck in my head when Shawn Hargreaves posted about how to to a 2D blur trick to make a game look like it had some speed. Suddenly, this game idea started zipping around in my head using that blur technique and Cops and Robbers was the result.
I started the game on Friday and I was releasing alpha versions throughout the weekend on the XNA IRC channel (you do go there right? IRC efnet #xna). I had all the game elements and gameplay in by Sunday and I spent the rest of the week cleaning up the code and refactoring. The code is a bit more advanced than normal for this site, but I tried to take the time to make the code readable. There are still a few things I wish I had done a bit differently and there are places where my comments are a bit lax (i.e. non-existent), but overall I think it's a solid sample of making a small game.
Gameplay:
The gameplay is pretty simple. You play as the Cop and you have to race around the level tagging all of the Robbers to put them in jail. Collect all of the robbers before time runs out and you win. Your chances of winning can be impacted both positively and negatively by the power ups that will appear throughout the level.
Gamepad:
The game was written for the PC, but both the Xbox 360 controller and the keyboard can be used for input.
Keyboard
Enter - Starts the game. Re-starts the game at the Congratulation or Game Over screens
P - Pauses/Un-pauses the game
Spacebar - Enters the ramp
Esc - Exits the game
Gamepad
Start - Starts the game. Re-starts the game at the Congratulations or Game Over screens
Start - Pauses/Unpauses the game while you're playing
A button - Enters the ramp
Back button - Exits the game
What concepts will you see in this game demo?
One of the major concepts you will see is how to blur images to give them the appearance of speed. This game is a good introduction to looking at different ways of laying out the code in your game and introduces some entry level Object Oriented concepts. Flashing lights, soundfx, background music are also demonstrated as well. By dissecting the code in this game, you should be able to throw together a variety of early 2D clones just using these concepts.
As always, feedback and comments are encouraged and welcome! Now go take a look at the code for the game, play with it and most of all, make sure you are having fun!