Mezmure Dargie / Mbed 2 deprecated SPACERACERS

Dependencies:   4DGL-uLCD-SE PinDetect mbed wave_player

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Spaceship.h Source File

Spaceship.h

00001 #include "uLCD_4DGL.h"
00002 
00003 extern uLCD_4DGL uLCD;
00004 class Spaceship 
00005 {
00006     public: 
00007     int x, y, hits; 
00008     bool alive;
00009     
00010     Spaceship() { //starting position
00011         x = 0;
00012         y = 127;
00013         hits = 0;
00014         alive = true;
00015         }
00016     void draw() {
00017         if ( x + 3 < 128) {         //make sure ship doesn't pass right edge
00018         uLCD.filled_circle(x , y , 4 , BLUE); 
00019         }
00020         }
00021     void erase() { 
00022             uLCD.filled_circle(x , y , 4, BLACK); 
00023         }
00024     bool isAlive() {  // Dies if hit 3 times
00025         if (hits >=3)
00026         {   
00027             alive = false;
00028             }
00029         return alive;        }
00030 };
00031