Doxygen comments added
Dependencies: mbed Gamepad N5110
main.cpp
- Committer:
- rafeh
- Date:
- 2019-05-07
- Revision:
- 8:d91564c0f337
- Parent:
- 7:05f433e196d6
- Child:
- 9:b7a3ec1c7217
File content as of revision 8:d91564c0f337:
/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds Name: Rafeh Ishtiaq Username: el17ri Student ID Number: 201062291 Date: 20/03/2019 */ #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "Pipes.h" #include "Bird.h" #include "Entrance.h" #include "FlappyBirdEngine.h" #define PIPE_WIDTH 8 #define BIRD_X 25 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad pad; Bird bird; Pipes pipes; Entrance entrance; FlappyBirdEngine flappy; bool check_collisions(int f, int xx, int yy); int xaxis=25; int yaxis=20; //y position of the bird int main() { lcd.init(); pad.init(); lcd.clear(); lcd.setContrast(0.5); entrance.welcome_page(lcd,pad); if (pad.check_event(Gamepad::START_PRESSED) == false) { lcd.clear(); int xvalue=84; int height = pipes.generate_height(); int score = 0; int highscore = 0; char scoredisplay[3]; while(1) { lcd.drawRect(0,45,84,3,FILL_BLACK); //draw the floor pipes.init(xvalue,height); // draw the pipes pipes.draw(lcd); //xvalue=xvalue-1; sprintf(scoredisplay,"%d",score); lcd.printString(scoredisplay,60,0); //display the score on the up right flappy.get_score(score); score=flappy.add_score(score,xvalue,BIRD_X,PIPE_WIDTH); if(xvalue<1) { height=pipes.generate_height(); xvalue=84; } bird.init(xaxis,yaxis); bird.draw(lcd); yaxis=bird.get_position(yaxis,pad); wait(0.075); xvalue=xvalue-2; if (check_collisions(yaxis,xvalue,height)) { wait(1); if (flappy.check_for_highscore(highscore)) { highscore=score;} flappy.update_highscore(highscore); flappy.display_score(lcd,pad); score=0; } lcd.refresh(); lcd.clear(); } } } bool check_collisions(int f, int xx, int yy) { if((xx>17 && xx<32)&&((f<(yy-3)) || (f>(yy+26))) || (f>45)) return true; else return false; }