High Level Design
The space-fighter game has always been our favorite. The idea of using an accelerometer as user control comes from one of the past final projects.
An ADXL202AE accelerometer and a 16-key keypad are interfaced with the STK500 board running the ATMEGA32 microcontroller chip. The accelerometer is soldered on to a pcd board and the microcontroller takes the analog output for analog-digital conversion. It is used for movement control of the user. The 16-key keypad is used for shooting and calibration menu. Only the “D” button is used on the keypad. The calculation result of the MCU goes through a DAC and is displayed on a TV screen, while all objects are drawn as white on the screen.
The subject of the game is a fighter that the user can control through the device. There are two objects that the fighter has to avoid: the asteroids and the monsters. The asteroids drop vertical from the top of the screen and the monsters appear from the top of the screen. Monsters can chase the fighters, and fighters can destroy monsters by shooting at them. Each user has a limited number of ammos that can appear on the gaming screen. A monster disappears if it touches the bottom of the screen. If the fighter is too far away on top of the monster it would stop chasing and continue towards the bottom of the screen till it disappears. Each user has a limited number of lives, and a life is lost if the fighter touches the monster or the asteroid. 10 points are awarded for each destroyed monster, and the objective of the game is to get as many points as the user could. The game ends if the user uses up his lives.
The 7x7 fighter and the 8x8 monster is drawn using a bitmap. To avoid flickering, we do not have a bitmap for the 16x16 asteroid. Instead we take advantage of the fact that it is a solid square with round corners and only downward movement is possible. We update its movement by only updating the first three lines and the last three lines. The chasing algorithm of the monster is very simple: to shorten the distance between the monster and the fighter. However, we have to do a lot of checking to ensure that the monster would not crash into asteroids or go beyond the boundaries. Every object of the game has different speed, and we control the speed by specifying how often its position is updated.
Because of limited memory and timing constraint of TV signal, we limit the maximum number of monsters, asteroids and ammos that can appear on the screen.