Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: MenuClasses/StartScreen/StartScreen.cpp
- Revision:
- 63:205f0ca48473
- Parent:
- 62:ebf6ecf8a6d5
- Child:
- 64:540aa1602372
--- a/MenuClasses/StartScreen/StartScreen.cpp Tue Apr 30 14:53:38 2019 +0000 +++ b/MenuClasses/StartScreen/StartScreen.cpp Wed May 01 22:35:40 2019 +0000 @@ -137,7 +137,7 @@ void StartScreen::init() { - fps = 40; //sets the default frames per second to a certain value. + fps = 15; //sets the default frames per second to a certain value. i = 16; //main menu selection arrow position g_mode = 1; //game mode selection (joystick/motion control). gs = 2; //game speed page selection. @@ -165,7 +165,7 @@ wait(0.2); } if (Start_Pressed == 0) { - wait(0.3); //dont wait anymore if start is pressed. + wait(0.3); //dont wait anymore if start is pressed. (this is to allow for quick skip towards menu) } pad.leds_off(); lcd.clear(); @@ -176,6 +176,7 @@ void StartScreen::instruct(N5110 &lcd, Gamepad &pad) { //pad.init(); + wait(1/cs); //to avoid race condition of the following while loop being skipped. while ((pad.check_event(Gamepad::START_PRESSED) == false)&&(pad.check_event(Gamepad::A_PRESSED) == false)&&(Start_Pressed == 0)) { lcd.printString("Please Press",5,1); //Function used to promt the user to start. lcd.printString("Start",25,3); @@ -205,7 +206,7 @@ lcd.clear(); } -void StartScreen::read_stats(SDFileSystem &sd) +void StartScreen::read_stats(SDFileSystem &sd) //to read the data from the SD card at the start of the game to be able to display before starting game. { _stats.read(sd); } @@ -245,7 +246,7 @@ void StartScreen::NextMenu(N5110 &lcd, Gamepad &pad) { - switch (i) { + switch (i) { //this i saves the value from the coordinates of arrow in main menu, and allows us to select the next menu accordingly. case 16: game_mode(lcd, pad); break; @@ -287,11 +288,10 @@ if(back_pressed) { main_menu(lcd, pad); } else { - if (g_mode == 2) { - StartScreen::motionControlInstructions(lcd); - } else { - pad.tone(1000.0,0.1); + if (g_mode == 2) { //show instructions to handle motion control. + StartScreen::motionControlInstructions(lcd); //this only comes up on the screen is the user selects motion control from menu options. } + //Condition to go to next menu page. lcd.clear(); game_speed(lcd, pad); }