introduction

Asteroids is a fascinating game, not just for the gameplay but also for the way that the game works. I could write a tutorial that shows you how to code the game, focussing solely on the code. However, making the game work also involves math (trigonometry and geometry) and physics (kinematics – a branch of mechanics concerned with the motion of objects). I want to explain all of this as well, so that you can also understand these points. If you don’t like math, then you can ignore these parts and still follow along with the code explanations. However, if you have ever struggled with or would like to learn topics such as trigonometry, then I suggest that you follow along. I’m a big believer in learning by practical examples. Trigonometry is so much easier to grasp if you take a real-world example. In this tutorial, we will use trigonometry to calculate how the ship moves.

  • draw space
  • draw ship
  • move ship forwards
  • rotate ship anti-clockwise
  • rotate ship clockwise
  • ship fires misiles
  • ship moves into hyperspace
  • draw asteroids
  • break asteroid when hit with misile
  • lose life when ship hits asteroid
  • draw small saucer
  • make small saucer fire
  • lose life if misile from small saucer hits ship
  • draw large saucer
  • make large saucer fire
  • lose life if misile from large saucer hits ship