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:
- 7:5d9b9d0bc6e7
- Parent:
- 6:9882809b0694
- Child:
- 8:93f18f1c1241
--- a/Operator.cpp Sun Apr 16 13:45:15 2017 +0000 +++ b/Operator.cpp Sun Apr 16 19:37:55 2017 +0000 @@ -10,12 +10,6 @@ } - -void Operator::init() -{ -} - - int Operator::random_instruction(Display &display, N5110 &lcd) { int ran = rand() % 7 + 1; @@ -24,25 +18,26 @@ return ran; } -void Operator::Correct(Controller &pad) +void Operator::Correct(Controller &ctrl) { score++; + double freq_change = score*20; printf("OPP score = %d\n", score); - pad.led(1,1); - pad.led(2,1); - pad.led(3,1); - pad.sound(100.0,0.2); + ctrl.led(1,1); + ctrl.led(2,1); + ctrl.led(3,1); + ctrl.sound(50.0 + freq_change,0.2); } -void Operator::Game_Over(Controller &pad, N5110 &lcd) +void Operator::Game_Over(Controller &ctrl, N5110 &lcd) { - pad.sound(700.0,1); - while(pad.check_event(Controller::BACK_PRESSED) == false) { + ctrl.sound(200,1); + while(ctrl.check_event(Controller::BACK_PRESSED) == false) { Assessment(lcd, score); - pad.ledsOFF(); - pad.led(4,1); - pad.led(5,1); - pad.led(6,1); + ctrl.ledsOFF(); + ctrl.led(4,1); + ctrl.led(5,1); + ctrl.led(6,1); } score = 0; } @@ -57,22 +52,22 @@ lcd.printString("Newbie",26,4); } else if (score < 20) { sprintf(buffer,"%2d",score); - lcd.printString("Amuteur",25,4); + lcd.printString("Amuteur",24,4); } else if (score < 30) { sprintf(buffer,"%2d",score); - lcd.printString("Semi-Pro",24,4); + lcd.printString("Semi-Pro",23,4); } else if (score < 30) { sprintf(buffer,"%2d",score); - lcd.printString("Expert",15,4); + lcd.printString("Expert",26,4); } else if (score < 40) { sprintf(buffer,"%2d",score); - lcd.printString("Professional",14,4); + lcd.printString("Professional",10,4); } else if (score < 50) { sprintf(buffer,"%2d",score); lcd.printString("Legendary",16,4); } else { sprintf(buffer,"%2d",score); - lcd.printString("World Class",15,4); + lcd.printString("World Class",14,4); } lcd.printString(buffer,37,2); lcd.drawCircle(42,20,10,FILL_TRANSPARENT);