Mochu Yao explorer game

Dependencies:   mbed

Committer:
el17my
Date:
Tue Apr 28 16:58:19 2020 +0000
Revision:
22:f8ba0ab7465c
Parent:
21:349c70c8a7de
Child:
23:7be9701fc1b8
4.28

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17my 21:349c70c8a7de 1 #ifndef MENU_H
el17my 21:349c70c8a7de 2 #define MENU_H
el17my 21:349c70c8a7de 3
el17my 21:349c70c8a7de 4 #include "mbed.h"
el17my 21:349c70c8a7de 5 #include "N5110.h"
el17my 21:349c70c8a7de 6 #include "Gamepad.h"
el17my 21:349c70c8a7de 7 #include "Gameengine.h"
el17my 21:349c70c8a7de 8 //*using the UpDown_counter example in class 201.
el17my 21:349c70c8a7de 9 struct State {
el17my 21:349c70c8a7de 10 int output; // output value for current state
el17my 21:349c70c8a7de 11 int next_state[4]; // next state (depending on direction 0 - UP, 1 - DOWN)
el17my 21:349c70c8a7de 12 };
el17my 21:349c70c8a7de 13
el17my 21:349c70c8a7de 14 /** Menu class
el17my 21:349c70c8a7de 15 1 build three page to choose
el17my 21:349c70c8a7de 16 2 build a good welcome_page
el17my 21:349c70c8a7de 17 3 connect with the gamepad and makesure the game is working
el17my 21:349c70c8a7de 18 * @date April 27th 2020
el17my 21:349c70c8a7de 19 * @author Yaomochu
el17my 21:349c70c8a7de 20
el17my 21:349c70c8a7de 21 *@code
el17my 21:349c70c8a7de 22
el17my 21:349c70c8a7de 23 #include "N5110.h"
el17my 21:349c70c8a7de 24 #include "Gamepad.h"
el17my 21:349c70c8a7de 25 #include "mbed.h"
el17my 21:349c70c8a7de 26 #include "menu.h"
el17my 21:349c70c8a7de 27
el17my 21:349c70c8a7de 28 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
el17my 21:349c70c8a7de 29 Gamepad gamepad;
el17my 21:349c70c8a7de 30 menu _menu;
el17my 21:349c70c8a7de 31
el17my 21:349c70c8a7de 32 int main() {
el17my 21:349c70c8a7de 33 gamepad.init();
el17my 21:349c70c8a7de 34 _menu.init();
el17my 21:349c70c8a7de 35 lcd.init();
el17my 21:349c70c8a7de 36 lcd.normalMode();
el17my 21:349c70c8a7de 37 lcd.setBrightness(0.5);
el17my 21:349c70c8a7de 38 while(1) {
el17my 21:349c70c8a7de 39
el17my 21:349c70c8a7de 40 // clear, refresh lcd and run the menu.
el17my 21:349c70c8a7de 41 lcd.clear();
el17my 21:349c70c8a7de 42 _menu.run_engine(lcd, gamepad);
el17my 21:349c70c8a7de 43 lcd.refresh();
el17my 21:349c70c8a7de 44 wait(0.01);
el17my 21:349c70c8a7de 45 }
el17my 21:349c70c8a7de 46 }
el17my 21:349c70c8a7de 47
el17my 21:349c70c8a7de 48 *@endcode
el17my 21:349c70c8a7de 49 */
el17my 21:349c70c8a7de 50
el17my 21:349c70c8a7de 51 class Menu {
el17my 21:349c70c8a7de 52 public:
el17my 21:349c70c8a7de 53 Menu();
el17my 21:349c70c8a7de 54 ~Menu();
el17my 21:349c70c8a7de 55 void init();
el17my 22:f8ba0ab7465c 56 void run_engine(N5110 &lcd, Gamepad &gamepad);
el17my 22:f8ba0ab7465c 57 void run_game(N5110 &lcd, Gamepad &gamepad);
el17my 22:f8ba0ab7465c 58
el17my 22:f8ba0ab7465c 59
el17my 22:f8ba0ab7465c 60 private:
el17my 21:349c70c8a7de 61 void display_page1(N5110 &lcd, Gamepad &gamepad);
el17my 21:349c70c8a7de 62 void display_page2(N5110 &lcd, Gamepad &gamepad);
el17my 22:f8ba0ab7465c 63 void get_output(N5110 &lcd, Gamepad &gamepad);
el17my 21:349c70c8a7de 64 void get_input(bool start, bool back, bool b);
el17my 21:349c70c8a7de 65 Gameengine _game_engine;
el17my 21:349c70c8a7de 66 int _input_value;
el17my 21:349c70c8a7de 67 int _output;
el17my 21:349c70c8a7de 68 int _state;
el17my 21:349c70c8a7de 69 };
el17my 21:349c70c8a7de 70 #endif
el17my 21:349c70c8a7de 71
el17my 21:349c70c8a7de 72