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
bird.cpp@0:cd1d2540aaf4, 2016-03-15 (annotated)
- Committer:
- Mpmart08
- Date:
- Tue Mar 15 01:11:07 2016 +0000
- Revision:
- 0:cd1d2540aaf4
added comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mpmart08 | 0:cd1d2540aaf4 | 1 | #include "bird.h" |
Mpmart08 | 0:cd1d2540aaf4 | 2 | |
Mpmart08 | 0:cd1d2540aaf4 | 3 | Bird::Bird(){ |
Mpmart08 | 0:cd1d2540aaf4 | 4 | x = 16; // the bird starts 16 pixels from the left side of the screen |
Mpmart08 | 0:cd1d2540aaf4 | 5 | y = 64; // the bird starts 64 pixels from the top of the screen |
Mpmart08 | 0:cd1d2540aaf4 | 6 | } |
Mpmart08 | 0:cd1d2540aaf4 | 7 | |
Mpmart08 | 0:cd1d2540aaf4 | 8 | int Bird::getOldY() { |
Mpmart08 | 0:cd1d2540aaf4 | 9 | return oldY; |
Mpmart08 | 0:cd1d2540aaf4 | 10 | } |
Mpmart08 | 0:cd1d2540aaf4 | 11 | |
Mpmart08 | 0:cd1d2540aaf4 | 12 | int Bird::getX(){ |
Mpmart08 | 0:cd1d2540aaf4 | 13 | return x; |
Mpmart08 | 0:cd1d2540aaf4 | 14 | } |
Mpmart08 | 0:cd1d2540aaf4 | 15 | |
Mpmart08 | 0:cd1d2540aaf4 | 16 | int Bird::getY(){ |
Mpmart08 | 0:cd1d2540aaf4 | 17 | return y; |
Mpmart08 | 0:cd1d2540aaf4 | 18 | } |
Mpmart08 | 0:cd1d2540aaf4 | 19 | |
Mpmart08 | 0:cd1d2540aaf4 | 20 | int Bird::getWidth(){ |
Mpmart08 | 0:cd1d2540aaf4 | 21 | return width; |
Mpmart08 | 0:cd1d2540aaf4 | 22 | } |
Mpmart08 | 0:cd1d2540aaf4 | 23 | |
Mpmart08 | 0:cd1d2540aaf4 | 24 | int Bird::getHeight(){ |
Mpmart08 | 0:cd1d2540aaf4 | 25 | return height; |
Mpmart08 | 0:cd1d2540aaf4 | 26 | } |
Mpmart08 | 0:cd1d2540aaf4 | 27 | |
Mpmart08 | 0:cd1d2540aaf4 | 28 | void Bird::move(directionType direction){ |
Mpmart08 | 0:cd1d2540aaf4 | 29 | oldY = y; // store old y position |
Mpmart08 | 0:cd1d2540aaf4 | 30 | switch (direction){ |
Mpmart08 | 0:cd1d2540aaf4 | 31 | case DIRECTION_UP: // the player pressed up |
Mpmart08 | 0:cd1d2540aaf4 | 32 | y -= moveDistance; // the bird moves up by a constant distance |
Mpmart08 | 0:cd1d2540aaf4 | 33 | break; |
Mpmart08 | 0:cd1d2540aaf4 | 34 | case DIRECTION_DOWN: // the player pressed down |
Mpmart08 | 0:cd1d2540aaf4 | 35 | y += moveDistance; // the bird moves down by a constant distance |
Mpmart08 | 0:cd1d2540aaf4 | 36 | break; |
Mpmart08 | 0:cd1d2540aaf4 | 37 | } |
Mpmart08 | 0:cd1d2540aaf4 | 38 | } |