Asteroids was one of my favorite arcade games back in the day.
I had to make a version for myself.
I have kept true to the basic features of the classic game, except for the vector graphics that is.
This game is setup so that nearly all of the game data is read from text files when the program starts.
The user can modify the data in these text files to change almost any aspect of the play and/or the images and sounds used.
I first introduce the game itself.
I will then give a detailed description of the configuration files (mentioned above).
You will find a link to 3 zip files at the end of this article containing everything.
** Asteroids **
The program starts with a welcome menu. There are 2 buttons for choosing the control mode.
The game can be played with either mouse or keyboard. Instructions appear on the welcome menu.
Play can go indefinitely, as long as you score enough points to earn ships faster than you wreck them.
A couple of more screenshots. Busting rocks:
Finally, when the game ends, a game over menu appears.
What's that ufo shooting at?
The options here are to quit or return to the welcome menu for another game.
** The configuration files **
I have used a system of several text files for storing most of the game data.
I will cover them as they apply to each of several areas.
1) Adjusting ship properties and designing levels.
I put the data for all of this in the file "levels_config.txt" located in the main folder.
The first 3 lines look like this:
10000 6 10.0 20.0 0.3 0.01
100 200 300
The 1st line has all the data for the good guy ship.
The 6 numbers are:
# of points per new ship (10000)
max. # of shots in flight at once (6)
speed of shots in pixels per frame (px/fr) (10.0)
maximum ship speed (20.0)
acceleration rate in px/fr^2 (0.3)
speed damping rate (0.01)
The 2nd line is the data for the bad guy ships.
score value (1000)
speed of shots (10.0)
The 3rd line is for the score values of the asteroids
Large(100) medium(200) small(300)
The rest of the file is for defining the levels.
First, the number of levels is given (4).
Then, data for each level is given:
1) Number of asteroids (3)
1 line of data for each asteroid
2) Number of bad ships (2)
1 line of data for each bad ship.
Example from file:
4 <- number of levels
0 4 200.0 700.0 0.1 -1.4
0 4 -80.0 200.0 1.0 1.1
0 4 820.0 100.0 -1.1 1.0
0 2 80 700 -50.0 100.0 3.0 0.0
1 2 60 500 850.0 500.0 -4.0 0.0
The data above is for level 1.
The data for each asteroid consists of six numbers. Example values are from the 1st ship.
Which frame set on the sprite sheet (0)
Number of frames to delay animation (asteroids tumble slowly) (4)
Initial x position (200.0)
Initial y position (700.0)
Initial x speed (0.1)
Initial y speed (-1.4)
The data for each bad ship consists of eight numbers. Example values are from the 1st ship.
Which frame set on the sprite sheet, normal animation. (0)
Which frame set on the sprite sheet, explosion animation. (2)
Firing period (in frames) (80)
Launch period (in frames) (700)
Initial x position (-50.0)
Initial y position (100.0)
Initial x speed (3.0)
Initial y speed (0.0)
There will be 4 blocks of data like this. The file supplied has 5,3 7,4 9,3 (asteroids, bad ships)
for the remaining 3 levels.
The last bad ship is repeated as long as the level lasts.
The last level repeats indefinitely.
** end description of "levels_config.txt" **
Most of the data that affects the game play is located n the above described file, but I wanted it to be
possible to change which image and sound files are used.
The sound is easiest.
In the folder "AudioClips" is a text file "list_audio_files.txt" is a list of the filenames for the 5
sounds used in this game. The existing files are all .wav but other formats should also work (except
mp3-there is a proprietary issue).
The order must be preserved and there must be 5 filenames.
The 5 sounds listed are, in order:
Good ship weapon sound
Bad ship weapon sound
Welcome menu music (looping)
Game over menu music (looping)
The file for each sprite sheet contains data about the frames on the sheet.
The list of config. filenames for the sprite sheets is in "bmpImages/list_config_files.txt"
Presently these are:
We'll look at the 1st of these (for good ship) to see how the data is organized
Content of "bmpImages/goodShip_config.txt" is:
3 4 48 48
0 4 24 34
1 4 24 19
2 14 48 48
First line = name of image file.
Second line = 4 numbers.
# of frame sets (3)
# of columns of frames on sheet (4)
size of frames, width (48)
size of frames, height (48)
Then ,one line for each frame set (3), Four numbers per line:
Which row the frame set begins on (0,1,2)
The number of frames in the set (4,4,14)
Actual width of the frames in this set (24,24,48)
Actual height of the frames in this set (34,19,48)
** end of configuration file explanations **
Here are the files for the game.
It seems that there is a 1Mb upload size limit for attached files, so I had to split up the files into 3 files:
contains: 3 folders - source_code, bmpImages, AudioClips
and 2 files: Asteroids_stat.exe, levels_config.txt
The folder "AudioClips" contains only a text file "list_audio_files.txt".
The 5 .wav files on this list must go into the AudioClips folder.
contains: 2 dlls for audio - openal32.dll, libsndfile-1.dll
and 4 of the .wav files
The dlls go in the same folder as Asteroids_stat.exe.
The 4 .wav files go in the folder "AudioClips"
contains: The 5th .wav file "levelBK3.wav"
I hope you have fun tinkering with the game play.
If you develop any killer levels please share them with me!
I accept (and respond to) PMs.