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

Alien.h

Committer:
mdargie6
Date:
2018-05-02
Revision:
0:aeb7a12718ed

File content as of revision 0:aeb7a12718ed:

#include "uLCD_4DGL.h"
#include "mbed.h"
extern uLCD_4DGL uLCD;

class Alien 
{
    public: 
    int oldx, oldy, x, y; 
    bool alive;
    Alien() {}
    Alien(int xx, int yy) { //starting position
        oldx = xx;
        oldy = yy;
        x = xx;
        y = yy;
        alive = true;
        }
        
    void draw() {
        
//        if (x != oldx) {
//            uLCD.filled_circle(x,y,4,BLACK);
//            uLCD.filled_rectangle(x-5, y+6,x-3, y+4,BLACK);
//            uLCD.filled_rectangle(x+3,y+6,x+5,y+4,BLACK);
//            uLCD.filled_circle(x-2,y-1,1.5,BLACK);
//            uLCD.filled_circle(x+2,y-1,1.5,BLACK);
//            }
//            uLCD.triangle( x-3, y+3 ,x,y, x+3, y+3, GREEN); 
            uLCD.filled_circle(x,y,4,GREEN);
            uLCD.filled_rectangle(x-5, y+6,x-3, y+4,GREEN);
            uLCD.filled_rectangle(x+3,y+6,x+5,y+4,GREEN);
            uLCD.filled_circle(x-2,y-1,1.5,RED);
            uLCD.filled_circle(x+2,y-1,1.5,RED);
        }
        
        void erase() {
//            uLCD.triangle( x-3, y+3 ,x,y, x+3, y+3, GREEN); 
            uLCD.filled_circle(x,y,4,BLACK);
            uLCD.filled_rectangle(x-5, y+6,x-3, y+4,BLACK);
            uLCD.filled_rectangle(x+3,y+6,x+5,y+4,BLACK);
            uLCD.filled_circle(x-2,y-1,1.5,BLACK);
            uLCD.filled_circle(x+2,y-1,1.5,BLACK);
            
        }
    };