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

Committer:
Mpmart08
Date:
Tue Mar 15 01:11:07 2016 +0000
Revision:
0:cd1d2540aaf4
added comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mpmart08 0:cd1d2540aaf4 1 #include "pipe.h"
Mpmart08 0:cd1d2540aaf4 2 #include <stdlib.h>
Mpmart08 0:cd1d2540aaf4 3
Mpmart08 0:cd1d2540aaf4 4 Pipe::Pipe(){
Mpmart08 0:cd1d2540aaf4 5 x = 128; // the pipe starts at the right side of the screen
Mpmart08 0:cd1d2540aaf4 6 int random = rand() % 6; // generates a random number between 0 and 5
Mpmart08 0:cd1d2540aaf4 7 y = (random + 1) * 16; // converts random number to pipe size
Mpmart08 0:cd1d2540aaf4 8 type = static_cast<pipeType>(random); // cast int to pipeType
Mpmart08 0:cd1d2540aaf4 9 }
Mpmart08 0:cd1d2540aaf4 10
Mpmart08 0:cd1d2540aaf4 11 int Pipe::getWidth() {
Mpmart08 0:cd1d2540aaf4 12 return width;
Mpmart08 0:cd1d2540aaf4 13 }
Mpmart08 0:cd1d2540aaf4 14
Mpmart08 0:cd1d2540aaf4 15 int Pipe::getOldX() {
Mpmart08 0:cd1d2540aaf4 16 return oldX;
Mpmart08 0:cd1d2540aaf4 17 }
Mpmart08 0:cd1d2540aaf4 18
Mpmart08 0:cd1d2540aaf4 19 int Pipe::getY() {
Mpmart08 0:cd1d2540aaf4 20 return y;
Mpmart08 0:cd1d2540aaf4 21 }
Mpmart08 0:cd1d2540aaf4 22
Mpmart08 0:cd1d2540aaf4 23 int Pipe::getX() {
Mpmart08 0:cd1d2540aaf4 24 return x;
Mpmart08 0:cd1d2540aaf4 25 }
Mpmart08 0:cd1d2540aaf4 26
Mpmart08 0:cd1d2540aaf4 27 pipeType Pipe::getType() {
Mpmart08 0:cd1d2540aaf4 28 return type;
Mpmart08 0:cd1d2540aaf4 29 }
Mpmart08 0:cd1d2540aaf4 30
Mpmart08 0:cd1d2540aaf4 31 void Pipe::move(int gameSpeed) {
Mpmart08 0:cd1d2540aaf4 32 oldX = x; // store old x position
Mpmart08 0:cd1d2540aaf4 33 x -= gameSpeed; // move the pipe left (distance ranges from 1 to 5)
Mpmart08 0:cd1d2540aaf4 34 }