May 07, 2015
Wednesday Workout: Asteroids
If you'd like to code along with it, you can get the latest version of the project template I start from here, and you can watch me code it either at my Twitch channel where it'll be archived for a little while, or on my YouTube channel. Sorry, in both cases I forgot to take down my "Will stream at 4pm" sign for a little bit but eventually the chat channel tells me so.
So, obviously, this is not a complete implementation of Asteroids -- here are some things you could do at home to "finish" it. I may get a chance to do a few of these things over the weekend, and if I do, I'll post another batch of code.
- Tweaking. Most of the constants are just random numbers I came up with on the fly, and so balancing this to be the best Asteroids it can be would be a good place to start.
- Scoring. I don't remember how scoring worked in Asteroids, but it was probably a per-asteroid increment, with a bigger bonus for killing the UFO, which reminds me:
- Add the UFO. In the original game, this UFO would appear every so often and fire bullets at the player.
- Add Hyperspace. Bind it to a key and give it a limited number of uses.
- Draw a little triangle behind the ship when accelerating. 'Nuff said, should be fairly easy.
- Particles! I'm pretty sure there should be a little particle effect (just points or small lines) when an asteroid splits up or disappears.
- Add audio. I probably won't have time to do audio in a meaningful way until I write some boilerplate code to stick in there. So that's a place you might do some useful work. One for bullets, one for asteroids splitting, one for accelerating.
- Finish off the game. Add an "attract mode" (just asteroids and and "Press Space to Start"), a proper number of lives, a respawn, a restart after you survive, an additional life when you hit a score threshhold, all that stuff.
Those are the things I can think of off the top of my head. Thanks for those who followed along! Be back next week with Breakout or Space Invaders, haven't decided which yet.
Posted by Brett Douville at May 7, 2015 12:49 PM