This class is the engine of the program. It encapsulates all the methods to do with managing scores, commands and player states(dead/alive).

Revision:
10:e0e820636025
Parent:
9:54c620f7d736
Child:
11:48190450b7e5
--- a/Operator.cpp	Sun Apr 23 16:36:37 2017 +0000
+++ b/Operator.cpp	Mon Apr 24 09:47:05 2017 +0000
@@ -18,10 +18,10 @@
 
     ctrl.ledsOFF();
     int instruction_val = random_instruction(display, lcd);     //sets instruction_val as the random instruction from display
-    printf("OPP:test_player instruction_val = %d\n", instruction_val);
+    //printf("OPP:test_player instruction_val = %d\n", instruction_val);
     display.drawCircle(ctrl, lcd);                               //Draws circle, displays instruction and allows the circle to be drawn faster with time
     int button_val = ctrl.check_for_buttons();                       //sets button_val as the instruction performed by the user
-    printf("OPP:test_player button_val = %d\n", button_val);
+    //printf("OPP:test_player button_val = %d\n", button_val);
 
 
     if (button_val == instruction_val) {                        //if the user performs the instruction correctly perform:
@@ -36,7 +36,7 @@
 {
 
     int ran = rand() % 7 + 1;
-    printf("OPP ran = %d\n", ran);
+    //printf("OPP ran = %d\n", ran);
     display.display_instruction(lcd, ran);
     return ran;
 }
@@ -46,7 +46,7 @@
     myplayers[next_player].score++;                                                //increment score for player
     score = myplayers[next_player].score;
     double freq_change = score*20;
-    printf("OPP score = %d\n", score);
+    //printf("OPP score = %d\n", score);
     ctrl.led(1,1);
     ctrl.led(2,1);
     ctrl.led(3,1);
@@ -55,15 +55,15 @@
 
 void Operator::InCorrect(int next_player, Controller &ctrl)
 {
-    printf("OPP.Incorrect player = %d\n", next_player);
+    //printf("OPP.Incorrect player = %d\n", next_player);
     ctrl.sound(200,1);
     myplayers[next_player].status = false;                                          //set player to dead (false)
 }
 
 bool Operator::check_dead()
 {
-    printf("OPP.check_dead P1 %d\n", myplayers[0].status);
-    printf("OPP.check_dead P2 %d\n", myplayers[1].status);
+    //printf("OPP.check_dead P1 %d\n", myplayers[0].status);
+    //printf("OPP.check_dead P2 %d\n", myplayers[1].status);
     
     if (!myplayers[0].status && !myplayers[1].status) {                         // if both players false then both dead = true
         return true;
@@ -79,21 +79,21 @@
 {
 
     int mynext_player = next_player;
-    printf("OPP.check_next_player(1) next_player %d\n", mynext_player);
+    //printf("OPP.check_next_player(1) next_player %d\n", mynext_player);
     if (_num_players > 1) {
 
         if ( (myplayers[next_player].score % 10 == 0) || (myplayers[next_player].status == false)) {  //on 0, 10 etc swap player unless other player is dead
             myplayers[next_player].wait = display.get_wait();      //save speed
             lcd.clear();
 
-            if (next_player == 0 && myplayers[1].status) {                             //chagne to next player
+            if (next_player == 0 && myplayers[1].status) {                             //change to next player
                 mynext_player = 1;
             }
 
             if (next_player == 1 && myplayers[0].status) {                             //change to next player
                 mynext_player = 0;
             }
-            printf("OPP.check_next_player(2) next_player %d\n", mynext_player);
+            //printf("OPP.check_next_player(2) next_player %d\n", mynext_player);
             display.put_wait(myplayers[mynext_player].wait);                            //put speed
             DisplayNextPlayer(ctrl,lcd,mynext_player);                                  //Display next player
         }
@@ -154,7 +154,7 @@
     while(ctrl.check_event(Controller::BACK_PRESSED) == false) {
         if (_num_players == 1) {
             Assessment(lcd, myplayers[0].score);                //Display results for single player
-            printf("OPP num of Players = %d\n", _num_players);
+            //printf("OPP num of Players = %d\n", _num_players);
         } else {
             MultiResults(lcd);                                 //display results for multiPlayer
         }
@@ -170,7 +170,7 @@
 
 void Operator::Assessment(N5110 &lcd, int score)
 {
-    printf("OPP.ASSESSMENT score = %d\n", score);
+    //printf("OPP.ASSESSMENT score = %d\n", score);
     lcd.printString("Game Over",16,0);
     char buffer[14];
     if (score < 10) {
@@ -201,7 +201,7 @@
 
 void Operator::MultiResults(N5110 &lcd)
 {
-    printf("OPP.MULTIRESULTS\n");
+    //printf("OPP.MULTIRESULTS\n");
     lcd.clear();
     lcd.printString("Game Over",16,0);
     char buffer[14];