This class is the engine of the program. It encapsulates all the methods to do with managing scores, commands and player states(dead/alive).
Diff: Operator.cpp
- Revision:
- 5:84dfbfb17ef2
- Parent:
- 4:62dcc005f7a7
- Child:
- 6:9882809b0694
diff -r 62dcc005f7a7 -r 84dfbfb17ef2 Operator.cpp --- a/Operator.cpp Fri Apr 14 23:43:24 2017 +0000 +++ b/Operator.cpp Sat Apr 15 15:39:31 2017 +0000 @@ -14,6 +14,7 @@ void Operator::init() { } + int Operator::read_input(Controller &pad) { return(pad.check_for_buttons()); @@ -33,36 +34,44 @@ pad.led(3,1); pad.tone(100.0,0.2); } + void Operator::Game_Over(Controller &pad, N5110 &lcd) { pad.tone(700.0,1); - while(pad.check_event(Controller::BACK_PRESSED) == false) { - char buffer[14]; - if (score < 10) { - sprintf(buffer,"0%d",score); - lcd.printString("Newbie",26,4); - } - else if (score < 20) { - sprintf(buffer,"%2d",score); - lcd.printString("Rookie",26,4); } - else if (score < 30) { - sprintf(buffer,"%2d",score); - lcd.printString("Semi-Pro",24,4); } - else if (score < 30) { - sprintf(buffer,"%2d",score); - lcd.printString("Professional",20,4); } - else if (score < 40) { - sprintf(buffer,"%2d",score); - lcd.printString("World Class",20,4); } - else { - sprintf(buffer,"%2d",score); - lcd.printString("Legendary",22,4); } - lcd.printString(buffer,37,2); - lcd.drawCircle(42,20,10,FILL_TRANSPARENT); - lcd.refresh(); - pad.leds_off(); - pad.led(4,1); - pad.led(5,1); - pad.led(6,1); + while(pad.check_event(Controller::BACK_PRESSED) == false) { + Assessment(lcd, score); + pad.leds_off(); + pad.led(4,1); + pad.led(5,1); + pad.led(6,1); } score = 0; +} + +void Operator::Assessment(N5110 &lcd, int score) { + lcd.printString("Game Over",16,0); + char buffer[14]; + if (score < 10) { + sprintf(buffer,"0%d",score); + lcd.printString("Newbie",26,4); } + else if (score < 20) { + sprintf(buffer,"%2d",score); + lcd.printString("Amuteur",25,4); } + else if (score < 30) { + sprintf(buffer,"%2d",score); + lcd.printString("Semi-Pro",24,4); } + else if (score < 30) { + sprintf(buffer,"%2d",score); + lcd.printString("Professional",20,4); } + else if (score < 40) { + sprintf(buffer,"%2d",score); + lcd.printString("Expert",26,4); } + else if (score < 50) { + sprintf(buffer,"%2d",score); + lcd.printString("Legendary",20,4); } + else { + sprintf(buffer,"%2d",score); + lcd.printString("World Class",18,4); } + lcd.printString(buffer,37,2); + lcd.drawCircle(42,20,10,FILL_TRANSPARENT); + lcd.refresh(); } \ No newline at end of file