Mochu Yao explorer game
Dependencies: mbed
Diff: menu/Menu.cpp
- Revision:
- 32:47d98959b4ef
- Parent:
- 31:8e92b65e0779
- Child:
- 36:cdfba51a0a44
diff -r 8e92b65e0779 -r 47d98959b4ef menu/Menu.cpp --- a/menu/Menu.cpp Wed Apr 29 04:49:10 2020 +0000 +++ b/menu/Menu.cpp Wed Apr 29 12:19:12 2020 +0000 @@ -30,10 +30,10 @@ //*using the UPDown counter example in class 201. //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,2,0,0}}, - {1,{2,2,0,1}}, - {2,{1,2,1,0}} +State _fsm[3] = { + {0,{0,1,0,0}}, + {1,{1,1,0,2}}, + {2,{2,1,2,0}} }; Menu::Menu() {} @@ -46,34 +46,34 @@ _game_engine.init(); } void Menu::run_engine(N5110 &lcd, Gamepad &gamepad) { - get_input(gamepad.check_event(Gamepad::START_PRESSED), gamepad.check_event(Gamepad::BACK_PRESSED),gamepad.check_event(Gamepad::B_PRESSED)); - _output = fsm[_state].output; + get_input(gamepad.check_event(Gamepad::START_PRESSED), gamepad.check_event(Gamepad::BACK_PRESSED),gamepad.check_event(Gamepad::A_PRESSED)); + _output = _fsm[_state].output; 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 { + } else if (_output == 2) { display_page2(lcd, gamepad); // Displayes the control page. } // implement required delay // set the next state depending on direction - _state = fsm[_state].next_state[_input_value]; + _state = _fsm[_state].next_state[_input_value]; } -void Menu::get_input(bool start, bool back, bool b) { - if(!start && !back && !b) { +void Menu::get_input(bool start, bool back, bool a) { + if(!start && !back && !a) { _input_value = 0;} else if (!start && back) { _input_value = 1;} else if (start && !back) { _input_value = 2;} - else if (b) { + else if (a) { _input_value = 3;} } void Menu::display_page1(N5110 &lcd, Gamepad &gamepad) { lcd.printString("START - Play!",0,0); - lcd.printString("B - Controls",0,2); + lcd.printString("A - Controls",0,2); lcd.drawSprite(1,25,25,80,(int*)page1_sprite);} void Menu::display_page2(N5110 &lcd, Gamepad &gamepad) {