Flappy Bird game on mbed with a micro LCD screen, class D amp, speaker, SD card reader/writer, 5-button navigation switch, and potentiometer speed control
Dependencies: 4DGL-uLCD-SE PinDetect SDFileSystem mbed-rtos mbed
Diff: bird.cpp
- Revision:
- 0:cd1d2540aaf4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bird.cpp Tue Mar 15 01:11:07 2016 +0000 @@ -0,0 +1,38 @@ +#include "bird.h" + +Bird::Bird(){ + x = 16; // the bird starts 16 pixels from the left side of the screen + y = 64; // the bird starts 64 pixels from the top of the screen +} + +int Bird::getOldY() { + return oldY; +} + +int Bird::getX(){ + return x; +} + +int Bird::getY(){ + return y; +} + +int Bird::getWidth(){ + return width; +} + +int Bird::getHeight(){ + return height; +} + +void Bird::move(directionType direction){ + oldY = y; // store old y position + switch (direction){ + case DIRECTION_UP: // the player pressed up + y -= moveDistance; // the bird moves up by a constant distance + break; + case DIRECTION_DOWN: // the player pressed down + y += moveDistance; // the bird moves down by a constant distance + break; + } +} \ No newline at end of file