![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Doxygen comments added
Dependencies: mbed Gamepad N5110
Diff: FlappyBirdEngine/Scoring.cpp
- Revision:
- 9:b7a3ec1c7217
- Parent:
- 8:d91564c0f337
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FlappyBirdEngine/Scoring.cpp Tue May 07 22:39:48 2019 +0000 @@ -0,0 +1,42 @@ +#include "Scoring.h" + + + +void Scoring::get_score(int score) { + _score=score; + } + bool Scoring::check_for_highscore(int highscore) { + _highscore=highscore; + if (_score>_highscore) + return true; + else + return false; + } + void Scoring::update_highscore(int highscore) { + _highscore=highscore; + } + + int Scoring::add_score(int score, int pipe_x,int bird_x,int pipe_width) { + //_score=score; + if(pipe_x<(bird_x+pipe_width) && pipe_x>(bird_x+pipe_width-2)) { + _score=_score+1; + } + return _score; + } + + void Scoring::display_score(N5110 &lcd, Gamepad &pad) { + 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(); + } + } \ No newline at end of file