
Simple vertical scrolling space shooter game using navigation switch (joystick), uLCD-144-G2, and a pushbutton switch.
Dependencies: 4DGL-uLCD-SE PinDetect mbed
Diff: Display/Star.cpp
- Revision:
- 0:5c666e5cd22d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Display/Star.cpp Thu Mar 17 20:47:11 2016 +0000 @@ -0,0 +1,22 @@ +#include "Star.h" + +Star::Star( uLCD_4DGL *uLCD) { + _x = (int)(((float) rand() / (RAND_MAX))*127); + _y = 0; + _dy = 10; + _uLCDptr = uLCD; +} + +void Star::update() { + _y += _dy; + _uLCDptr->pixel(_x, _y, 0xFFFFFF); +} + +int Star::offScreen() { + if(_y + _dy >= 127) { + return 1; + } + else { + return 0; + } +} \ No newline at end of file