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.h@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 | #ifndef BIRD_H |
Mpmart08 | 0:cd1d2540aaf4 | 2 | #define BIRD_H |
Mpmart08 | 0:cd1d2540aaf4 | 3 | |
Mpmart08 | 0:cd1d2540aaf4 | 4 | // enumerated type that represents the direction that the bird moves |
Mpmart08 | 0:cd1d2540aaf4 | 5 | enum directionType {DIRECTION_UP, DIRECTION_DOWN}; |
Mpmart08 | 0:cd1d2540aaf4 | 6 | |
Mpmart08 | 0:cd1d2540aaf4 | 7 | // class that represents the bird in the Flappy Bird game |
Mpmart08 | 0:cd1d2540aaf4 | 8 | class Bird |
Mpmart08 | 0:cd1d2540aaf4 | 9 | { |
Mpmart08 | 0:cd1d2540aaf4 | 10 | public: |
Mpmart08 | 0:cd1d2540aaf4 | 11 | // Constructor |
Mpmart08 | 0:cd1d2540aaf4 | 12 | Bird(); |
Mpmart08 | 0:cd1d2540aaf4 | 13 | // Get Functions |
Mpmart08 | 0:cd1d2540aaf4 | 14 | int getX(); // return the bird's current x position |
Mpmart08 | 0:cd1d2540aaf4 | 15 | int getY(); // return the bird's current y position |
Mpmart08 | 0:cd1d2540aaf4 | 16 | int getOldY(); // return the bird's previous y position |
Mpmart08 | 0:cd1d2540aaf4 | 17 | int getWidth(); // return the bird's width |
Mpmart08 | 0:cd1d2540aaf4 | 18 | int getHeight(); // return the bird's height |
Mpmart08 | 0:cd1d2540aaf4 | 19 | // Member Functions |
Mpmart08 | 0:cd1d2540aaf4 | 20 | void move(directionType); // moves the bird in a given direction |
Mpmart08 | 0:cd1d2540aaf4 | 21 | |
Mpmart08 | 0:cd1d2540aaf4 | 22 | private: |
Mpmart08 | 0:cd1d2540aaf4 | 23 | // variables |
Mpmart08 | 0:cd1d2540aaf4 | 24 | int x; // the bird's x position |
Mpmart08 | 0:cd1d2540aaf4 | 25 | int y; // the bird's y position |
Mpmart08 | 0:cd1d2540aaf4 | 26 | int oldY; // the bird's previous y position |
Mpmart08 | 0:cd1d2540aaf4 | 27 | // constants |
Mpmart08 | 0:cd1d2540aaf4 | 28 | static const int width = 16; // the bird's width |
Mpmart08 | 0:cd1d2540aaf4 | 29 | static const int height = 16; // the bird's height |
Mpmart08 | 0:cd1d2540aaf4 | 30 | static const int moveDistance = 8; // the distance that the bird moves |
Mpmart08 | 0:cd1d2540aaf4 | 31 | }; |
Mpmart08 | 0:cd1d2540aaf4 | 32 | |
Mpmart08 | 0:cd1d2540aaf4 | 33 | #endif // BIRD_H |