printf("Thoughts");

Adventures in C, Linux, and open source


Simple Asteroids


A simple clone of the old Asteroids arcade game, written entirely in ANSI C. The game uses an OpenGL renderer through SDL.

screenshot of the game
Visually distinct from the original

The collision physics are very rudimentary. There is some conservation of momentum, but asteroids just bounce back in the opposite direction they came from.

The game contains a basic audio synthesizer that generates the sound effects. The generated audio is 8-bit unsigned and sampled at 8KHz.

Upon running the game, it generates a configuration file called 'asteroids.conf' that sits in the same directory as the program. This configuration file contains a number of ways to tweak the game. These options can also be defined on the command line (use ./asteroids -h for more info).

Among these options is a 2-player mode. For the sake of simplicity, both players use the same keyboard. Keybindings are configurable in the configuration file.

screenshot of 2-player mode
Player 1 collides with an asteroid