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: pipe.cpp
- Revision:
- 0:cd1d2540aaf4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pipe.cpp Tue Mar 15 01:11:07 2016 +0000 @@ -0,0 +1,34 @@ +#include "pipe.h" +#include <stdlib.h> + +Pipe::Pipe(){ + x = 128; // the pipe starts at the right side of the screen + int random = rand() % 6; // generates a random number between 0 and 5 + y = (random + 1) * 16; // converts random number to pipe size + type = static_cast<pipeType>(random); // cast int to pipeType +} + +int Pipe::getWidth() { + return width; +} + +int Pipe::getOldX() { + return oldX; +} + +int Pipe::getY() { + return y; +} + +int Pipe::getX() { + return x; +} + +pipeType Pipe::getType() { + return type; +} + +void Pipe::move(int gameSpeed) { + oldX = x; // store old x position + x -= gameSpeed; // move the pipe left (distance ranges from 1 to 5) +} \ No newline at end of file