John Aspinall / Mbed 2 deprecated SpaceGame

Dependencies:   4DGL-uLCD-SE PinDetect mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Star.cpp Source File

Star.cpp

00001 #include "Star.h"
00002 
00003 Star::Star( uLCD_4DGL *uLCD) {
00004         _x = (int)(((float) rand() / (RAND_MAX))*127);
00005         _y = 0;
00006         _dy = 10;
00007         _uLCDptr = uLCD;
00008 }
00009 
00010 void Star::update() {
00011     _y += _dy;
00012     _uLCDptr->pixel(_x, _y, 0xFFFFFF);    
00013 }
00014 
00015 int Star::offScreen() {
00016     if(_y + _dy >= 127) {
00017         return 1;    
00018     }    
00019     else {
00020         return 0;    
00021     }
00022 }