Doxygen comments added

Dependencies:   mbed Gamepad N5110

Committer:
rafeh
Date:
Thu May 09 10:25:47 2019 +0000
Revision:
14:9a9ac55616c4
Parent:
10:75de0f4da176
Child:
15:fc6b40fceb4f
can now generate two pipes on screen at the same time

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rafeh 9:b7a3ec1c7217 1 #include "Scoring.h"
rafeh 10:75de0f4da176 2 Scoring::Scoring()
rafeh 10:75de0f4da176 3 {
rafeh 10:75de0f4da176 4
rafeh 10:75de0f4da176 5 }
rafeh 10:75de0f4da176 6
rafeh 10:75de0f4da176 7 Scoring::~Scoring()
rafeh 10:75de0f4da176 8 {
rafeh 10:75de0f4da176 9
rafeh 10:75de0f4da176 10 }
rafeh 7:05f433e196d6 11
rafeh 7:05f433e196d6 12
rafeh 7:05f433e196d6 13
rafeh 10:75de0f4da176 14 void Scoring::set_score(int score) {
rafeh 7:05f433e196d6 15 _score=score;
rafeh 7:05f433e196d6 16 }
rafeh 14:9a9ac55616c4 17 bool Scoring::check_for_highscore(int score,int highscore) { //checks if the score is higher than the highscore
rafeh 14:9a9ac55616c4 18 _score=score;
rafeh 7:05f433e196d6 19 _highscore=highscore;
rafeh 7:05f433e196d6 20 if (_score>_highscore)
rafeh 7:05f433e196d6 21 return true;
rafeh 7:05f433e196d6 22 else
rafeh 7:05f433e196d6 23 return false;
rafeh 7:05f433e196d6 24 }
rafeh 10:75de0f4da176 25 void Scoring::update_highscore(int highscore) { //updates the highscore
rafeh 10:75de0f4da176 26 _highscore=highscore; //if a highscore is scored, then a new value for the _highscore is a new value
rafeh 7:05f433e196d6 27 }
rafeh 7:05f433e196d6 28
rafeh 10:75de0f4da176 29 int Scoring::add_score(int score, int pipe_x,int bird_x,int pipe_width) { //checks if score should be added
rafeh 10:75de0f4da176 30 if(pipe_x<(bird_x+pipe_width) && pipe_x>(bird_x+pipe_width-2)) { //if the pipes have moved further left of the bird, then score is added
rafeh 8:d91564c0f337 31 _score=_score+1;
rafeh 8:d91564c0f337 32 }
rafeh 8:d91564c0f337 33 return _score;
rafeh 8:d91564c0f337 34 }
rafeh 10:75de0f4da176 35
rafeh 10:75de0f4da176 36 bool Scoring::check_collisions(int bird_y, int pipe_x, int pipe_height) { //checks for collisions by looking for
rafeh 14:9a9ac55616c4 37 if((pipe_x>17 && pipe_x<29)&&((bird_y<(pipe_height)) || ((bird_y+5)>(pipe_height+26))) || (bird_y>43)) { //overlaps between the bird and the pipe
rafeh 10:75de0f4da176 38 return true; } //return true if there is a collision
rafeh 10:75de0f4da176 39 else {
rafeh 10:75de0f4da176 40 return false;
rafeh 10:75de0f4da176 41 }
rafeh 10:75de0f4da176 42 }
rafeh 10:75de0f4da176 43
rafeh 8:d91564c0f337 44
rafeh 10:75de0f4da176 45 void Scoring::display_score(N5110 &lcd, Gamepad &pad) { //displays the score and highscore after the player has lost
rafeh 7:05f433e196d6 46 lcd.clear();
rafeh 7:05f433e196d6 47 char score_display[16];
rafeh 7:05f433e196d6 48 char highscore_display[20];
rafeh 7:05f433e196d6 49 sprintf(score_display,"Score : %d",_score);
rafeh 7:05f433e196d6 50 lcd.printString(score_display,0,0);
rafeh 7:05f433e196d6 51 sprintf(highscore_display,"High Score : %d",_highscore);
rafeh 7:05f433e196d6 52 lcd.printString(highscore_display,1,1);
rafeh 7:05f433e196d6 53 while ( pad.check_event(Gamepad::A_PRESSED) == false) {
rafeh 7:05f433e196d6 54 pad.leds_on();
rafeh 7:05f433e196d6 55 wait(0.1);
rafeh 7:05f433e196d6 56 pad.leds_off();
rafeh 7:05f433e196d6 57 wait(0.1);
rafeh 7:05f433e196d6 58 lcd.refresh();
rafeh 7:05f433e196d6 59 }
rafeh 14:9a9ac55616c4 60 }
rafeh 14:9a9ac55616c4 61
rafeh 14:9a9ac55616c4 62
rafeh 14:9a9ac55616c4 63
rafeh 14:9a9ac55616c4 64
rafeh 14:9a9ac55616c4 65
rafeh 14:9a9ac55616c4 66