Mochu Yao explorer game

Dependencies:   mbed

Revision:
19:14c5427b30d1
Parent:
17:1b4ecc01b79f
Child:
20:20e6ba54e15c
--- a/menu/menu.cpp	Tue Apr 28 12:52:16 2020 +0000
+++ b/menu/menu.cpp	Tue Apr 28 13:37:26 2020 +0000
@@ -31,9 +31,9 @@
 //there are three pages so we have three output and we cna press the start, back and y button to change the page.These are the input
 //
 State fsm[3] = {
-  {0,0.5,{0,2,0,0}},
-  {1,0.5,{2,2,0,1}},
-  {2,0.5,{1,2,1,0}}
+   {0,0.5,{0,2,0,0}},
+   {1,0.5,{2,2,0,1}},
+   {2,0.5,{1,2,1,0}}
 };
 
 menu::menu() {}
@@ -52,29 +52,29 @@
   _output = fsm[_state].output;  
         // implement required delay
         wait(fsm[_state].time);
-        // set the next state depending on direction
-        _state = fsm[_state].next_state[_input_value]; 
-  if (_output == 0) {
+    if (_output == 0) {
     run_game(lcd, gamepad);  // Runs the main game loop.
   } else if (_output == 1) {
     display_page1(lcd, gamepad);  // Displays the main menu.
   } else {
     display_page2(lcd, gamepad);  // Displayes the control page.
   }
+        // set the next state depending on direction
+  _state = fsm[_state].next_state[_input_value]; 
 }
 
 void menu::get_input_value(Gamepad &gamepad) {
     if(!START_flag && !BACK_flag && !B_flag) {
         _input_value = 0;
         gamepad.tone(200, 0.5);}
-    else if (START_flag && !BACK_flag && !B_flag) {
-        _input_value = 1;
+    else if (START_flag && !BACK_flag) {
+        _input_value = 2;
         gamepad.tone(400, 0.5);}
-    else if (!START_flag && BACK_flag && !B_flag) {
-        _input_value = 2;
+    else if (!START_flag && BACK_flag) {
+        _input_value = 1
         gamepad.tone(600, 0.5);}
-    else if (!START_flag && !BACK_flag && B_flag) {
-                     _input_value = 3;}
+    else if (B_flag) {
+        _input_value = 3;}
 }
     
 void menu::display_page1(N5110 &lcd, Gamepad &gamepad) {