cloud2

Web Apps - Asteroids


Asteroids

Here's my initial rendition on the 1979 Atari classic video game, Asteroids. In this project, I focused on implementing all the components of the game using an object-oriented design. I started with creating a base class called SpaceObject, which implemented methods for drawing wire-framed objects to the canvas. From there, I made sub-classes that represent the ship, asteroids, missiles, etc. Each class has its own update and draw methods, making the animation loop a lot more clean. In addition, I implemented an auxillary class called Vector2D, which represents a two-dimensional vector object, and handles all the usual vector operations and arithmetic.

All collisions in the game are represented as simple circle-circle collisions, but for some added flair, I decided to integrate a basic asteroid-on-asteroid ellastic collision system where the sizes of the asteroids represent their respective masses. I also added an explosive factor to the missiles. So, when a missile hits an asteroid, it provides a small pushing force to any of the asteroids near the explosion site.

Overall, I really enjoyed creating this project as I got to work with affine transformations, basic two-dimensional kinematics, and object-oriented programming.

See the code on GitHub