ELEC2645 (2017/18) / Mbed OS el16ajm
Revision:
17:2a909f7da973
Parent:
15:130900e5c268
--- a/Menu/Menu.cpp	Tue May 08 14:41:56 2018 +0000
+++ b/Menu/Menu.cpp	Tue May 08 14:52:29 2018 +0000
@@ -14,7 +14,7 @@
 void Menu::init()
 {
     // initialises the default values
-    
+
     _start = false;
 
     _mainSelection = 1;
@@ -30,6 +30,8 @@
     _buttonPressed = false;
 
     _menuScreen = "main";
+
+    printf("Menu initialised\n");
 }
 
 void Menu::update()
@@ -46,11 +48,11 @@
 void Menu::moveArrow()
 {
     //each part of the menu has different selection tracker, this means that it will remember what was selected before moving between menu screens
-    
+
     if (_menuScreen == "main" ) {
         if (_d == N && _mainSelection > 1) {    //checks the menu arrow location and direction wanting to be moved
             _mainSelection -= 1;                //if there is still a postion to be moved to in that direction, the currently selected menu item changes
-                                                //all the menu navigation functions in the same way
+            //all the menu navigation functions in the same way
         } else if (_d == S && _mainSelection < 3) {
             _mainSelection += 1;
         }
@@ -74,10 +76,13 @@
     if (_menuScreen == "main" ) {           //checks the menu screen
         if (_mainSelection == 1) {          //checks what the current selection is
             _start = true;                  //applies the needed change depending on the selection
+            printf("Game Start\n");
         } else if (_mainSelection == 2) {
             _menuScreen = "lvl";
+            printf("Menu Screen Changed\n");
         } else if (_mainSelection == 3) {
             _menuScreen = "dif";
+            printf("Menu Screen Changed\n");
         }
     } else {                                //an else is used as the other two menu screen MUST return to the main menu once a selection is made
         if (_menuScreen == "dif" ) {
@@ -101,7 +106,7 @@
         }
 
         _menuScreen = "main";               //returns to the main menu
-
+        printf("Menu Screen Changed\n");
     }
 }
 
@@ -113,8 +118,12 @@
     //checks if any button on the top of the gamepad has been pressed, there is no need to limit the user to one type of button
     if ( pad.check_event(Gamepad::START_PRESSED) || pad.check_event(Gamepad::A_PRESSED) || pad.check_event(Gamepad::B_PRESSED) || pad.check_event(Gamepad::X_PRESSED) || pad.check_event(Gamepad::Y_PRESSED) ||pad.check_event(Gamepad::BACK_PRESSED)) {
         _buttonPressed = true;
+        
+        printf("Button Pressed\n");
+        
         pad.tone(750.0,0.1);    //plays a noise to show the user that the item has been selected
-            wait(0.1);          //waits to reduce 'ghosting' of inputs
+        wait(0.1);          //waits to reduce 'ghosting' of inputs
+        
     }
     _d = pad.get_direction();   //gets the current direction of the joystick for later use
 
@@ -124,7 +133,7 @@
 {
     lcd.drawRect(0,0,84,48,FILL_TRANSPARENT);       //draws an outline
     if (_menuScreen == "main" ) {                   //checks the currently selected screen
-                
+
         lcd.printString(" Start",2,1);              //draws the related elements
         lcd.printString(" Level Select",2,2);
         lcd.printString(" Difficulty",2,3);
@@ -178,3 +187,5 @@
 {
     return _level;
 }
+
+