Space Racers! is a Space Invaders clone for the MBED. The goal is to avoid the oncoming alien onslaught by shooting them with your missiles. The aliens traverse the screen getting lower and lower until they either reach the bottom of the screen or shoot your spaceship player 3 times. To win the game, the user has to shoot all 9 of the enemy aliens. The controls can be handled either with the navigation switch or the Adafruit Bluetooth Connect app Control Pad on your mobile device. Left and Right arrows are used to move the player, the up arrow is used to shoot at the aliens.

Dependencies:   4DGL-uLCD-SE PinDetect mbed wave_player

Committer:
mdargie6
Date:
Wed May 02 18:49:04 2018 +0000
Revision:
0:aeb7a12718ed
okay

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mdargie6 0:aeb7a12718ed 1 #include "uLCD_4DGL.h"
mdargie6 0:aeb7a12718ed 2
mdargie6 0:aeb7a12718ed 3 extern uLCD_4DGL uLCD;
mdargie6 0:aeb7a12718ed 4 class Spaceship
mdargie6 0:aeb7a12718ed 5 {
mdargie6 0:aeb7a12718ed 6 public:
mdargie6 0:aeb7a12718ed 7 int x, y, hits;
mdargie6 0:aeb7a12718ed 8 bool alive;
mdargie6 0:aeb7a12718ed 9
mdargie6 0:aeb7a12718ed 10 Spaceship() { //starting position
mdargie6 0:aeb7a12718ed 11 x = 0;
mdargie6 0:aeb7a12718ed 12 y = 127;
mdargie6 0:aeb7a12718ed 13 hits = 0;
mdargie6 0:aeb7a12718ed 14 alive = true;
mdargie6 0:aeb7a12718ed 15 }
mdargie6 0:aeb7a12718ed 16 void draw() {
mdargie6 0:aeb7a12718ed 17 if ( x + 3 < 128) { //make sure ship doesn't pass right edge
mdargie6 0:aeb7a12718ed 18 uLCD.filled_circle(x , y , 4 , BLUE);
mdargie6 0:aeb7a12718ed 19 }
mdargie6 0:aeb7a12718ed 20 }
mdargie6 0:aeb7a12718ed 21 void erase() {
mdargie6 0:aeb7a12718ed 22 uLCD.filled_circle(x , y , 4, BLACK);
mdargie6 0:aeb7a12718ed 23 }
mdargie6 0:aeb7a12718ed 24 bool isAlive() { // Dies if hit 3 times
mdargie6 0:aeb7a12718ed 25 if (hits >=3)
mdargie6 0:aeb7a12718ed 26 {
mdargie6 0:aeb7a12718ed 27 alive = false;
mdargie6 0:aeb7a12718ed 28 }
mdargie6 0:aeb7a12718ed 29 return alive; }
mdargie6 0:aeb7a12718ed 30 };
mdargie6 0:aeb7a12718ed 31