Generating Awesome...

14th February 2013
ASTEROIDS!
ASTEROIDS!

Game Number 2! So this month I have somewhat stuck with the “in space” theme and have remade Asteroids. I haven’t had as much time this month to work on the game, due to the fact that I got a programming apprenticeship. First 9 – 5 job (Well 8:30 – 5:30) so finding enough time to keep up with everything I used to do has been a bit of a struggle but I JUST managed to finish this month’s game. 😀

Get Adobe Flash player

Source code

I haven’t really got much time to write an epic summary like I did last time but I can break it down a little.

Doing things as I usually do, I planned out what the core gameplay would require. This was Player, Bullets, Asteroids, Asteroids manager and a HUD to display score, lives and the current level.

I started off by copying Player.as and HUD.as from the last game. Obviously these classes are going to be very similar in Asteroids as they were in Lunar Lander, so there’s no point in completely recoding them. (The lists bellow are in no real order)

From Player.as I:

  • Removed Gravity and added friction
  • Changed appling thrust from space bar to W or Forward Arrow
  • Removed the Thruster Image
  • Made space bar now fire bullets when pressed

From HUD.as I:

  • Removed all fuel related functions
  • Removed end of level screens and effects
  • Adjusted the game over function to deal with outputting the level at the end
  • Added an effect for the level text on the HUD

I did all the changes to the player class first and then created a parent class for the bullets and asteroids (They have basically the same functionality so there’s no reason to duplicate code). This handled movement, flying off screen, seting properties and just basic functions to get variable values.

Asteroid manager was created next. This class creates and destroys asteroids and levels. It also handle collisions between objects and all asteroids on stage.

Once I had the manager and the parent class, it was time to make the asteroids. The asteroids class really doesn’t do much. It just looks after the size of the object a calls back to manager if it needs to be destoryed.

Last up, as per usual, I created the menu screens (and adjusted the HUD). I seem to leave these two things to last due there simplicity (Well the menu at least) and becuase gamplay mechanics are kind of key to a game.

Sorry that this months artical doesn’t contain much detail, I have really been short on time! Anyway, for now, thanks for reading and I shall see you next month :]

Posted in Flash Games, Game A Month, Just Another ... Game