Dependencies:   mbed FATFileSystem

Revision:
16:c8d68cbd1ae2
Parent:
15:d855e8c666e7
Child:
17:98127ac75195
--- a/Menu/Menu.cpp	Wed May 08 18:51:59 2019 +0000
+++ b/Menu/Menu.cpp	Thu May 09 09:58:51 2019 +0000
@@ -1,43 +1,5 @@
 #include "Menu.h"
 
-int mini_logo[15][60] =   { //mini part of logo shown on welcome screen
-    { 0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0 },
-    { 0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0 },
-    { 0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0 },
-    { 0,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0 },
-    { 0,0,0,1,0,0,0,1,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0 },
-    { 0,0,0,1,0,0,0,1,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0 },
-    { 0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0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clear();
+        pad.leds_off();
         lcd.drawSprite(0, 4, 15, 60, (int *)mini_logo);
         lcd.drawSprite(22, 21, 15, 60, (int *)golf_logo);
         lcd.refresh();
         wait(0.3);
         lcd.clear();
+        pad.leds_on();
         lcd.drawSprite(0, 6, 15, 60, (int *)mini_logo);
         lcd.drawSprite(24, 21, 15, 60, (int *)golf_logo);        
         lcd.printString("PRESS START",12,5);
@@ -102,17 +66,19 @@
 
 void Menu::start_loop(Gamepad &pad, N5110 &lcd) //prints start screen and returns true when game started
 {
-    while(pad.check_event(Gamepad::A_PRESSED) == false) { //does nothing until A button pressed and game loop begins
+    while(pad.check_event(Gamepad::A_PRESSED) == false) { //flashes leds and displays messaged until a pressed and game begins
         lcd.clear();
+        pad.leds_on(); //turns gamepad leds on
         lcd.printString(" PRESS A ",16,2);
         lcd.printString(" TO START!",14,3);
         lcd.refresh();
         wait(0.3);
+        pad.leds_off(); //turns gamepad leds off
         lcd.clear();
         lcd.refresh();
         wait(0.3);
     }
-    _start_game_flag = true;
+    _start_game_flag = true; //this causes code to enter main game loop
     pad.tone(659.25 , 0.25); //play note (E5)
     lcd.clear();
 }
@@ -134,7 +100,7 @@
         lcd.refresh();
     }
     pad.tone(392.00 , 0.25); //play note (G4)
-    _start_game_flag = false;
+    _start_game_flag = false; //this causes code to return back to main menu loop
 }
 
 void Menu::settings_loop(Gamepad &pad, N5110 &lcd)//prints settings screen
@@ -150,7 +116,7 @@
         read_input(pad); //reads joystick and pot inputs 
     }
     pad.tone(392.00 , 0.25); //play note (G4)
-    _start_game_flag = false;
+    _start_game_flag = false; //this causes code to return back to main menu loop
 }
 
 int Menu::get_frame_rate() //returns frame rate 5-50
@@ -159,22 +125,22 @@
     return frame_rate;
 }
 
-float Menu::get_brightness()
+float Menu::get_brightness() //returns brightness private variable from class
 {
     return _brightness;    
 }
 
-bool Menu::get_start_game_flag() 
+bool Menu::get_start_game_flag()  //returns start game flag
 {
     return _start_game_flag;
 }
 
-void Menu::reset_start_game_flag()
+void Menu::reset_start_game_flag() //resets start game flag to false
 {
     _start_game_flag = false;    
 }
 
-MenuChoice Menu::get_screen()
+MenuChoice Menu::get_screen() //gets screen choice
 {
     return _screen;    
 }
@@ -221,14 +187,14 @@
 void Menu::change_screen() //moves changes menu screen to screen of cursor position
 {
     switch(_cursor_pos) { //uses cursor position to change screen variable to 
-        case 0:
-            _screen = START;
+        case 0: //if cursor is in position 0 (top)
+            _screen = START;  //sets screen to START
             break;
-        case 1:
-            _screen = HIGHSCORES;
+        case 1: //if cursor is in position 1 (middle)
+            _screen = HIGHSCORES; //sets screen to HIGHSCORES
             break;
-        case 2:
-            _screen = SETTINGS;
+        case 2: //if cursor is in position 2 (bottom)
+            _screen = SETTINGS; //sets screen to SETTINGS
             break;
     }
 }
@@ -295,13 +261,13 @@
 {
     switch(_joy_direction) {
         case 0: //joystick centered
-            _cursor_pos = 0;
+            _cursor_pos = 0; //set cursor position to 0
             break;
         case 1: //joystick up
-            _cursor_pos = 2;
+            _cursor_pos = 2; //set cursor position to 2
              break;
         case 5: //joystick down
-            _cursor_pos = 1;
+            _cursor_pos = 1; //set cursor position to 1
             break;
     }
 }
@@ -310,13 +276,13 @@
 {
     switch(_joy_direction) {
         case 0: //joystick centered
-            _cursor_pos = 1;
+            _cursor_pos = 1; //set cursor position to 1
             break;
         case 1: //joystick up
-            _cursor_pos = 0;
+            _cursor_pos = 0; //set cursor position to 0
             break;
         case 5: //joystick down
-            _cursor_pos = 2;
+            _cursor_pos = 2; //set cursor position to 2
             break;
     }    
 }
@@ -325,13 +291,13 @@
 {
     switch(_joy_direction) {
         case 0: //joystick centered
-            _cursor_pos = 2;
+            _cursor_pos = 2; //set cursor position to 2
             break;
         case 1: //joystick up
-            _cursor_pos = 1;
+            _cursor_pos = 1; //set cursor position to 1
             break;
         case 5: //joystick down
-            _cursor_pos = 0;
+            _cursor_pos = 0; //set cursor position to 0
             break;
     }
 }
@@ -340,13 +306,13 @@
 {
     switch(_cursor_pos) {
         case 0: //cursor on position 0
-            lcd.drawRect(0,9,6,6,FILL_TRANSPARENT); 
+            lcd.drawRect(0,9,6,6,FILL_TRANSPARENT);  //draw cursor in position 0
             break;
         case 1: //cursor on position 1
-            lcd.drawRect(0,25,6,6,FILL_TRANSPARENT);
+            lcd.drawRect(0,25,6,6,FILL_TRANSPARENT); //draw cursor in position 1
             break;
         case 2: //cursor on position 2
-            lcd.drawRect(0,41,6,6,FILL_TRANSPARENT);
-            break;
+            lcd.drawRect(0,41,6,6,FILL_TRANSPARENT); //draw cursor in position 2
+            break; 
     }
 }
\ No newline at end of file