Space Shooter
ABOUT THIS PROJECT
An object-oriented asteroids game that never runs out of waves.
An exercise in clean object-oriented design that turned into a game I kept playing. Ships, bullets, and asteroids are each their own class with velocity, rotation, and screen wrapping, and the difficulty curve lives in a JSON file rather than in the code.
Ship, Bullet and Asteroid
Three model classes over the course's game2d layer. The ship keeps a facing vector separate from its velocity and accumulates momentum through turn and thrusters rather than moving directly, so it drifts and has to be flown against, the way the arcade original does. Bullets carry their own velocity and are culled by an on-screen check rather than a lifetime, and asteroids own their size and direction so a split can construct its children from the parent.
Three-tier fragmentation
A large asteroid becomes three mediums, a medium becomes three smalls, and a small is destroyed outright. The children are launched along 120 degree rotations of the collision vector through a rotation helper, so a hit scatters them evenly around the impact instead of sending all three the same way, which is what makes a large asteroid feel like it broke rather than multiplied.
Waves as data
Each wave is a JSON file giving the ship's starting position and angle and the list of asteroids to place, so a new level is a new data file rather than new code, and the grading wave and the custom ones load through the same path.
A five-state controller
The app runs on INACTIVE, LOADING, ACTIVE, PAUSED and CONTINUE, with the class invariants spelled out and maintained for each, including which fields are permitted to be None in which state. Writing those invariants down is what kept the pause and continue transitions honest, since both touch the same wave object from different directions.