Doxygen comments added

Dependencies:   mbed Gamepad N5110

Scoring/Scoring.cpp

Committer:
rafeh
Date:
2019-05-08
Revision:
10:75de0f4da176
Parent:
FlappyBirdEngine/Scoring.cpp@ 9:b7a3ec1c7217
Child:
14:9a9ac55616c4

File content as of revision 10:75de0f4da176:

#include "Scoring.h"
Scoring::Scoring()
{

}

Scoring::~Scoring()
{

}



void Scoring::set_score(int score) {
        _score=score;
        }
        bool Scoring::check_for_highscore(int highscore) { //checks if the score is higher than the highscore
            _highscore=highscore;
            if (_score>_highscore) 
            return true;
            else 
            return false;
            }
    void Scoring::update_highscore(int highscore) {  //updates the highscore
        _highscore=highscore;                        //if a highscore is scored, then a new value for the _highscore is a new value
        }
        
        int Scoring::add_score(int score, int pipe_x,int bird_x,int pipe_width) {   //checks if score should be added
            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
          _score=_score+1;
          }
          return _score;
         }
    
     bool Scoring::check_collisions(int bird_y, int pipe_x, int pipe_height) {                             //checks for collisions by looking for 
    if((pipe_x>17 && pipe_x<32)&&((bird_y<(pipe_height-3)) || (bird_y>(pipe_height+26))) || (bird_y>45)) { //overlaps between the bird and the pipe
    return true; }                                                                                         //return true if there is a collision
    else {
    return false;
    }
    }

        
    void Scoring::display_score(N5110 &lcd, Gamepad &pad) {        //displays the score and highscore after the player has lost
        lcd.clear();
        char score_display[16];
        char highscore_display[20];
        sprintf(score_display,"Score : %d",_score);
        lcd.printString(score_display,0,0);
        sprintf(highscore_display,"High Score : %d",_highscore);
        lcd.printString(highscore_display,1,1);
         while ( pad.check_event(Gamepad::A_PRESSED) == false) {
        pad.leds_on();
        wait(0.1);
        pad.leds_off();
        wait(0.1);
        lcd.refresh();
        }
        }