Yang Zhenye 201199680

Dependencies:   mbed

Revision:
2:baca89f466bc
Child:
3:30c81344beff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Menu/Menu.cpp	Thu Apr 30 07:08:09 2020 +0000
@@ -0,0 +1,68 @@
+#include "Menu.h"
+
+int _sprite[30][80]= {
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+void Menu::init() {
+     _state = 0;
+     engine.init(); }
+    
+     
+void Menu::run(N5110 &lcd, Gamepad &gamepad) {
+    input(gamepad.check_event(Gamepad::START_PRESSED,gamepad.check_event(Gamepad::BACK_PRESSED),gamepad.check_event(Gamepad::X_PRESSED))
+    _output = fsm[_state].output;
+    output();
+    _state = fsm[_state].next_state[_input]; }
+    
+void input(bool start, bool back, bool x) {
+    if (!start && !back && !x) {
+        _input = 0;}
+        else if (start && !back && !x) {
+            _input = 1;}
+            else if (x && !start && !back) {
+                _input = 2;}
+                else if (!start && back) {
+                    _input = 3;} }
+ void output() {
+  if (_output == 0) {
+      display_page1; }
+      else if(_output == 1) {
+          display_page2;
+          run_engine(); }
+          else if(_output == 2) {
+              display_page3; } }
+
+State fsm[3] = {
+    {0,{0,1,2,0}},
+    {1,{1,1,1,0}},
+    {2,{2,2,2,0}}
+    }
+    
+display_page1(N5110 &lcd, Gamepad &gamepad) {
+   lcd.printString("Start - playgame!",0,4);
+   lcd.printSrting("X - instruction",0,5);
+   lcd.drawSptire(1,60,30,80,(int*)_sprite); }
+   
+display_page2(N5110 &lcd, Gamepad &gamepad) {
+   lcd.printString("love you Tim!",0,0)
+   lcd.refresh; wait(0.5);}
+   
+display_page3(N5110 &lcd, Gamepad &gamepad) {
+   lcd.printString("joystick - ",0,1);
+   lcd.printString("control Roony - ",0,3);
+   lcd.printString("Be a hero! - ",0,4);
+   lcd.printString("Save England! - ",0,1); }
+   
+   
+    
\ No newline at end of file