Doxygen comments added

Dependencies:   mbed Gamepad N5110

Committer:
rafeh
Date:
Wed May 08 20:59:02 2019 +0000
Revision:
10:75de0f4da176
Parent:
9:b7a3ec1c7217
Child:
14:9a9ac55616c4
doxygen comments added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rafeh 0:43364ffd7cf6 1 /*
rafeh 0:43364ffd7cf6 2 ELEC2645 Embedded Systems Project
rafeh 0:43364ffd7cf6 3 School of Electronic & Electrical Engineering
rafeh 0:43364ffd7cf6 4 University of Leeds
rafeh 0:43364ffd7cf6 5 Name: Rafeh Ishtiaq
rafeh 0:43364ffd7cf6 6 Username: el17ri
rafeh 0:43364ffd7cf6 7 Student ID Number: 201062291
rafeh 0:43364ffd7cf6 8 Date: 20/03/2019
rafeh 0:43364ffd7cf6 9 */
rafeh 0:43364ffd7cf6 10
rafeh 0:43364ffd7cf6 11 #include "mbed.h"
rafeh 0:43364ffd7cf6 12 #include "N5110.h"
rafeh 0:43364ffd7cf6 13 #include "Gamepad.h"
rafeh 3:5409b50b01b0 14 #include "Pipes.h"
rafeh 6:bc580b480ac8 15 #include "Bird.h"
rafeh 7:05f433e196d6 16 #include "Entrance.h"
rafeh 9:b7a3ec1c7217 17 #include "Scoring.h"
rafeh 8:d91564c0f337 18 #define PIPE_WIDTH 8
rafeh 8:d91564c0f337 19 #define BIRD_X 25
rafeh 0:43364ffd7cf6 20 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
rafeh 0:43364ffd7cf6 21 Gamepad pad;
rafeh 6:bc580b480ac8 22 Bird bird;
rafeh 3:5409b50b01b0 23 Pipes pipes;
rafeh 7:05f433e196d6 24 Entrance entrance;
rafeh 9:b7a3ec1c7217 25 Scoring flappy;
rafeh 3:5409b50b01b0 26
rafeh 7:05f433e196d6 27
rafeh 7:05f433e196d6 28 int yaxis=20; //y position of the bird
rafeh 3:5409b50b01b0 29
rafeh 0:43364ffd7cf6 30 int main() {
rafeh 0:43364ffd7cf6 31 lcd.init();
rafeh 0:43364ffd7cf6 32 pad.init();
rafeh 0:43364ffd7cf6 33 lcd.clear();
rafeh 1:beceda7046fb 34 lcd.setContrast(0.5);
rafeh 10:75de0f4da176 35 entrance.welcome_page(lcd,pad);
rafeh 2:9f5714571c41 36 if (pad.check_event(Gamepad::START_PRESSED) == false) {
rafeh 2:9f5714571c41 37 lcd.clear();
rafeh 2:9f5714571c41 38
rafeh 10:75de0f4da176 39 int xvalue=84; //initialising the x value of the pipes
rafeh 10:75de0f4da176 40 int height = pipes.generate_height(); //initialising the height of the top pipe
rafeh 3:5409b50b01b0 41 int score = 0;
rafeh 7:05f433e196d6 42 int highscore = 0;
rafeh 10:75de0f4da176 43 char scoredisplay[3]; //to display
rafeh 2:9f5714571c41 44 while(1) {
rafeh 10:75de0f4da176 45
rafeh 10:75de0f4da176 46
rafeh 7:05f433e196d6 47 lcd.drawRect(0,45,84,3,FILL_BLACK); //draw the floor
rafeh 3:5409b50b01b0 48
rafeh 7:05f433e196d6 49 pipes.init(xvalue,height); // draw the pipes
rafeh 3:5409b50b01b0 50 pipes.draw(lcd);
rafeh 10:75de0f4da176 51 bird.init(BIRD_X,yaxis); //draw the bird
rafeh 10:75de0f4da176 52 bird.draw(lcd);
rafeh 7:05f433e196d6 53 //xvalue=xvalue-1;
rafeh 7:05f433e196d6 54 sprintf(scoredisplay,"%d",score);
rafeh 10:75de0f4da176 55 lcd.printString(scoredisplay,60,0); //display the score on the top right
rafeh 8:d91564c0f337 56
rafeh 10:75de0f4da176 57 flappy.set_score(score);
rafeh 10:75de0f4da176 58 score=flappy.add_score(score,xvalue,BIRD_X,PIPE_WIDTH); //add score if the pipe has gone further left of the bird
rafeh 3:5409b50b01b0 59
rafeh 10:75de0f4da176 60 if(xvalue<1) { //generates a new pipe
rafeh 10:75de0f4da176 61 height=pipes.generate_height(); //a new height is generated for the new pipe (i.e. the placement of the gap is different)
rafeh 3:5409b50b01b0 62 xvalue=84;
rafeh 3:5409b50b01b0 63 }
rafeh 3:5409b50b01b0 64
rafeh 7:05f433e196d6 65
rafeh 3:5409b50b01b0 66 wait(0.075);
rafeh 10:75de0f4da176 67 yaxis=bird.get_position(yaxis,pad); //gets new vertical position for the bird
rafeh 10:75de0f4da176 68 xvalue=xvalue-2; //moves the pipes towards the left
rafeh 10:75de0f4da176 69
rafeh 10:75de0f4da176 70 if (flappy.check_collisions(yaxis,xvalue,height)) { //checking for collisions
rafeh 5:3a0948f56de0 71 wait(1);
rafeh 7:05f433e196d6 72 if (flappy.check_for_highscore(highscore)) {
rafeh 10:75de0f4da176 73 highscore=score;}
rafeh 7:05f433e196d6 74 flappy.update_highscore(highscore);
rafeh 10:75de0f4da176 75 while (pad.check_event(Gamepad::START_PRESSED) == false) {
rafeh 10:75de0f4da176 76 lcd.clear();
rafeh 7:05f433e196d6 77 flappy.display_score(lcd,pad);
rafeh 10:75de0f4da176 78 lcd.refresh();
rafeh 10:75de0f4da176 79 wait(0.05);
rafeh 10:75de0f4da176 80 }
rafeh 7:05f433e196d6 81 score=0;
rafeh 5:3a0948f56de0 82 }
rafeh 2:9f5714571c41 83 lcd.refresh();
rafeh 2:9f5714571c41 84 lcd.clear();
rafeh 2:9f5714571c41 85 }
rafeh 2:9f5714571c41 86 }
rafeh 10:75de0f4da176 87 }
rafeh 3:5409b50b01b0 88
rafeh 10:75de0f4da176 89
rafeh 2:9f5714571c41 90
rafeh 10:75de0f4da176 91
rafeh 10:75de0f4da176 92
rafeh 10:75de0f4da176 93