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
Menus/Menu.cpp
- Committer:
- jiaxinZHOU
- Date:
- 2019-05-09
- Revision:
- 4:0f2006e9c8f8
- Parent:
- 0:07c4fef6c0af
File content as of revision 4:0f2006e9c8f8:
#include "Menu.h" Menu::Menu() { } Menu::~Menu() { } int Menu::input( int select,Gamepad &pad) { Direction d; d = pad.get_direction(); if(d == N) { select= select - 1; } if (d == S) { select = select + 1; } return select; } void Menu::menus(N5110 &lcd, Gamepad &pad) { go_on = 0; sel = 0; while(go_on == 0) { sel = input(sel,pad); wait_ms(200); switch (sel) { case 0: lcd.clear(); lcd.printString(" MENU ",0,0); lcd.printString(" (PRASS A) ",0,1); lcd.printString(">PLAY GAME",0,2); lcd.printString("TUTORIAL",0,3); lcd.printString("VERSION",0,4); lcd.refresh(); if (pad.check_event(Gamepad::A_PRESSED)){ go_on = 1; } break; case 1: lcd.clear(); lcd.printString(" MENU ",0,0); lcd.printString(" (PRASS A) ",0,1); lcd.printString("PLAY GAME",0,2); lcd.printString(">TUTORIAL",0,3); lcd.printString("VERSION",0,4); lcd.refresh(); // either clicking joystick or pressing A selects function if (pad.check_event(Gamepad::A_PRESSED)) { lcd.clear(); lcd.printString("PUSH JOYSTICK ",0,1); lcd.printString(" TO CTRL ",0,2); lcd.printString(" DIRCTION ",0,3); lcd.refresh(); //printf("Direction = %i\n"); wait_ms (1000); } break; case 2: lcd.clear(); lcd.printString(" MENU ",0,0); lcd.printString(" (PRASS A) ",0,1); lcd.printString("PLAY GAME",0,2); lcd.printString("TUTORIAL",0,3); lcd.printString(">VERSION",0,4); lcd.refresh(); if (pad.check_event(Gamepad::A_PRESSED)) { lcd.clear(); lcd.printString(" V1.0.0 ",0,1); lcd.printString(" Auther ",0,3); lcd.printString(" ZHOU JIAXIN ",0,4); lcd.refresh(); wait_ms(1000); //printf("Direction = %i\n"); } break; } } } int Menu::difficulty(N5110 &lcd, Gamepad &pad) { go_on = 0; while(go_on == 0) { sel = input(sel,pad); wait_ms(200); switch (sel) { case 0: lcd.clear(); lcd.printString(" (PRASS A) ",0,1); lcd.printString("> EASY ",0,2); lcd.printString(" MEDIUM ",0,3); lcd.printString(" HARD ",0,4); lcd.refresh(); if (pad.check_event(Gamepad::A_PRESSED)) { go_on = 1; _fps = 6; } break; case 1: lcd.clear(); lcd.printString(" (PRASS A) ",0,1); lcd.printString(" EASY ",0,2); lcd.printString("> MEDIUM ",0,3); lcd.printString(" HARD ",0,4); lcd.refresh(); if (pad.check_event(Gamepad::A_PRESSED)) { go_on = 1; _fps = 8; } break; case 2: lcd.clear(); lcd.printString(" (PRASS A) ",0,1); lcd.printString(" EASY ",0,2); lcd.printString(" MEDIUM ",0,3); lcd.printString("> HARD ",0,4); lcd.refresh(); if (pad.check_event(Gamepad::A_PRESSED)) { go_on = 1; _fps = 12; } break; } } return _fps; }