Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Menu.cpp
00001 #include "Menu.h" 00002 00003 Menu::Menu() 00004 { 00005 00006 } 00007 00008 Menu::~Menu() 00009 { 00010 00011 } 00012 00013 void Menu::init() 00014 { 00015 00016 } 00017 00018 void Menu::main(N5110 &lcd, Gamepad &pad) 00019 { 00020 // while not playing then main menu will display // 00021 play = false; 00022 while (play == false) { 00023 lcd.clear(); 00024 lcd.printString("NEW GAME(X)", 10, 1); 00025 lcd.printString("GAME INFO(Y)", 10, 2); 00026 lcd.printString("CREDITS(B)", 10, 3); 00027 lcd.refresh(); 00028 newGame(lcd,pad); 00029 wait_ms(1000/60); 00030 } 00031 00032 } 00033 00034 void Menu::newGame(N5110 &lcd, Gamepad &pad){ 00035 // different path dependent on button press // 00036 // (so either new game, info or credits) // 00037 if (pad.check_event(Gamepad::X_PRESSED) == true){ 00038 play = true; 00039 } else if (pad.check_event(Gamepad::Y_PRESSED) == true){ 00040 info(lcd,pad); 00041 } else if(pad.check_event(Gamepad::B_PRESSED) == true){ 00042 credits(lcd,pad); 00043 } else { 00044 play = false; 00045 } 00046 } 00047 00048 void Menu::info(N5110 &lcd, Gamepad &pad) 00049 { 00050 // stays in menu until L is pressed // 00051 while (pad.check_event(Gamepad::L_PRESSED) == false){ 00052 lcd.clear(); 00053 lcd.printString("MOVE(J-STICK)", 5, 1); 00054 lcd.printString("10 HEALTH", 15, 2); 00055 lcd.printString("COLLECT COINS", 5, 3); 00056 lcd.printString("BACK(L)", 20, 4); 00057 lcd.refresh(); 00058 // corrects error with pressing button that was unused // 00059 // which would have an effect when returning to main menu // 00060 if (pad.check_event(Gamepad::X_PRESSED) == true){ 00061 } 00062 if (pad.check_event(Gamepad::Y_PRESSED) == true){ 00063 } 00064 if (pad.check_event(Gamepad::B_PRESSED) == true){ 00065 } 00066 } 00067 } 00068 00069 void Menu::credits(N5110 &lcd, Gamepad &pad) 00070 { 00071 // stays in menu until L is pressed // 00072 while (pad.check_event(Gamepad::L_PRESSED) == false){ 00073 lcd.clear(); 00074 lcd.printString("CREATED BY", 10, 1); 00075 lcd.printString("SPENCER", 20, 2); 00076 lcd.printString("TINGLE", 20, 3); 00077 lcd.printString("BACK(L)", 20, 4); 00078 lcd.refresh(); 00079 // corrects error with pressing button that was unused // 00080 // which would have an effect when returning to main menu // 00081 if (pad.check_event(Gamepad::X_PRESSED) == true){ 00082 pad.check_event(Gamepad::L_PRESSED) == false; 00083 } 00084 if (pad.check_event(Gamepad::Y_PRESSED) == true){ 00085 pad.check_event(Gamepad::L_PRESSED) == false; 00086 } 00087 if (pad.check_event(Gamepad::B_PRESSED) == true){ 00088 pad.check_event(Gamepad::L_PRESSED) == false; 00089 } 00090 } 00091 }
Generated on Wed Jul 13 2022 21:10:10 by
