Skip to content
CppCooperProgramming Portfolio
Selected projectProject year 2014

Space Invaders

A 2014 C++ arcade project combining formation control, weighted enemy volleys, fixed-step updates, collisions, assets, and scorekeeping.

Version
Original project
Status
Historical project
Built with
C++
My work
Coursework game programming
The case study

Project overview

Space Invaders is a C++ arcade shooter from a 2014 Comparative Programming Languages assignment. The player moves along the bottom of the screen and shoots into an advancing formation while avoiding enemy fire. Behind that familiar arrangement are several interacting systems: input, object movement, formation control, collisions, asset loading, and scorekeeping.

The assignment called for object-oriented design, string handling, file I/O, parameter passing, and exception handling, with graphics as an additional requirement. A small shooter gave those requirements something concrete to work together on. The project documents are dated November 24, 2014; the archived implementation also preserves the older graphics-framework integration.

Choosing when, how much, and where to fire

Enemy shooting is split into three decisions. A Bernoulli distribution decides whether a volley happens. A piecewise-linear distribution weights the number of shots, and a uniform distribution selects their columns. The volley selection avoids choosing the same column twice.

Those choices can be adjusted separately. Weighting volley sizes gives some sizes more influence than others without making every attack identical. The firing probability also incorporates elapsed time and a bullet-count term. This is the part of the game where C++’s distribution objects describe behavior directly, with the decisions kept together in the bullet manager.

The formation is organized into columns, which also gives shooting and collision code a useful structure. Enemy shots come from the frontmost surviving invader in a selected column. The player has one active bullet at a time; the enemy side can put several shots into play.

Advancing the world in small steps

World updates use a 15-millisecond time slice. Elapsed time is carried between calls, but each call admits at most ten slices of work. That bounds the amount of catch-up processing after a delay, at the cost of discarding excess elapsed time. The cap trades elapsed-time fidelity for a bounded amount of catch-up work.

Each step moves objects, advances the formation, updates bullets, checks hits, and cleans up objects marked for removal. Drawing and updating coordinate through atomic flags, with mutexes around parts of the shared state. It is an early synchronization design, closely tied to the graphics framework and the lifetime of objects shared between managers.

Connecting hits to the rest of the game

Collision checks compare overlap on the horizontal and vertical axes using each object’s dimensions. A hit connects the bullet system to an enemy’s death handling and score changes. A separate screen manager draws the registered objects, while the game draws the player and the score, lives, and high-score text.

Textures, sprite definitions, shaders, and fonts are loaded through the asset system. This historical version depends on the older GFX/GF framework and platform headers; its source and assignment documents preserve the coursework design. Its timing and threading design have not been benchmarked or validated as thread-safe.

By Joshua Cooper Published Updated

Keep exploring

More projects

View the portfolio