Space Invaders for mbed

Space Invaders for mbed by Zhe Cheng Lee and David Gaspard

The game is a reproduction of the 70's classic rendered in C++ using the Nokia 6610 LCD display. The game emulates the feel of the original by utilizing an mbed Ministick Sensor as a joystick and an active-high pushbutton as a firing trigger. The game also comes with sound effects. Space Invaders utilizes the mbed RTOS to spawn threads that wait for pushbutton input to generate a sound depending on the state of the game's main state machine.

Device Map

/media/uploads/gas6262/mbed_map.jpg

Connections

/media/uploads/gas6262/mbed_pins.png

The Software

The game is implemented using a large state machine consisting of 4 basic states as displayed in the image below. During the gameplay state, the number of the lives of a player is decremented with each enemy laser that hits the player. The player can move from left to right using the joystick to dodge enemy lasers and use the pushbutton to return fire upon the enemy fleet. When an enemy ship is hit, it completely disappears. If the player can successfully wipe out the entire alien fleet before it reaches Earth (the bottom of the screen) and before they have lost all of their lives, they have successfully won the game. Sound is implemented in a thread separated from the main process. The thread utilizes the enumerated states of the main process to determine whether the start screen music should be played, the pushbotton should create a firing sound, the winning screen music should be played, or the losing screen music should be played.

/media/uploads/gas6262/states.png

Possible Future Additions

Currently the program is incapable of rendering background music smoothly while the firing sound effect is playing. This is due to the simplicity of the waveplayer API used to play sounds. Gameplay music would greatly heighten the intensity of the game. Players could not hide behind large shields as the original game has allowed. The simulation includes fewer aliens than the original game does, though the aliens travel faster initially in the former than in the latter. In addition, the aliens move faster in the original game as their number dwindles, a feature the program does not incorporate..The invaders and the defending ship also lack the detail that was displayed in the original game. One could generate more vivid characters to be moved around during gameplay along with cool animations such as explosions.

The Code

Import programSpaceInvadersFINAL

A reproduction of the 70's classic. Enjoy!

The game and supporting functions: /media/uploads/gas6262/df.pdf

Game Library Code: /media/uploads/gas6262/df2.pdf

Game Library Header: /media/uploads/gas6262/df3.pdf


Please log in to post comments.