Dependencies:   mbed FATFileSystem

Revision:
15:d855e8c666e7
Parent:
14:08ac9aaa34c3
Child:
16:c8d68cbd1ae2
--- a/Menu/Menu.cpp	Wed May 08 14:54:19 2019 +0000
+++ b/Menu/Menu.cpp	Wed May 08 18:51:59 2019 +0000
@@ -1,16 +1,43 @@
 #include "Menu.h"
 
-int logo[8][5] =   {
-    { 0,0,1,0,0 },
-    { 0,1,1,1,0 },
-    { 0,0,1,0,0 },
-    { 0,1,1,1,0 },
-    { 1,1,1,1,1 },
-    { 1,1,1,1,1 },
-    { 1,1,0,1,1 },
-    { 1,1,0,1,1 },
+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,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0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0 },
+
+};
+
+
 // constructor
 
 Menu::Menu()
@@ -32,26 +59,28 @@
     reset_start_game_flag(); //resets start flag to make sure game enters menu loop when first run
     _cursor_pos = 0; //cursor begins on position 0
     _frame_rate = 40; //frame rate, contrast and brightness can be changed in settings
-    _contrast = 0.5f;
+    _contrast = 0.55f;
     _brightness = 1.0f; //full brightness makes ball easier to see when moving
 
 }
 
 void Menu::welcome_loop(Gamepad &pad, N5110 &lcd) //prints welcome screen
-{
-    lcd.clear();
-    lcd.drawSprite(0, 0, 8, 5, (int *)logo);
-    lcd.printString("By Ellis ",24,3);
-    lcd.printString("Blackford",24,4);
-    lcd.printString(" Stroud",24,5);
-    lcd.refresh();
-    wait(3);
-    lcd.clear();
-    lcd.printString("  Use joystick",10,0);
-    lcd.printString(" and START/BACK",10,1);
-    lcd.printString(" to navigate menu !",10,2);
-    lcd.refresh();
-    wait(1);
+{   
+    while(pad.check_event(Gamepad::START_PRESSED) == false) {
+        lcd.clear();
+        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();
+        lcd.drawSprite(0, 6, 15, 60, (int *)mini_logo);
+        lcd.drawSprite(24, 21, 15, 60, (int *)golf_logo);        
+        lcd.printString("PRESS START",12,5);
+        lcd.refresh();
+        wait(0.3);
+    }
+    pad.tone(659.25 , 0.25); //play note (E5)
+    lcd.setBrightness(_brightness); //set brightness to 100% to counter tone function messing with screen backlight 
 }
 
 void Menu::menu_loop(Gamepad &pad, N5110 &lcd) //prints menu creen and controls cursor and choices
@@ -68,16 +97,20 @@
         wait(0.2);
     }
     pad.tone(523.25, 0.1); //play note when button pressed (middle C) - buzzer effects frequency of pwn pins which changes brightness
-    change_screen();                                                  //note when brightness set in settings is stays constant
+    change_screen();                                                
 }
 
 void Menu::start_loop(Gamepad &pad, N5110 &lcd) //prints start screen and returns true when game started
 {
-    lcd.clear();
-    lcd.printString("PRESS A ",16,2);
-    lcd.printString("TO START",16,3);
-    lcd.refresh();
     while(pad.check_event(Gamepad::A_PRESSED) == false) { //does nothing until A button pressed and game loop begins
+        lcd.clear();
+        lcd.printString(" PRESS A ",16,2);
+        lcd.printString(" TO START!",14,3);
+        lcd.refresh();
+        wait(0.3);
+        lcd.clear();
+        lcd.refresh();
+        wait(0.3);
     }
     _start_game_flag = true;
     pad.tone(659.25 , 0.25); //play note (E5)
@@ -86,8 +119,7 @@
 
 void Menu::highscores_loop(Gamepad &pad, N5110 &lcd, SDFileSystem &sd) //highscores screen loop
 { 
-    sd_read(sd); //reads values from highscores.txt file and sorts asc in array
-
+    sd_read(sd); //reads values from highscores.txt file and sorts in ascending order
     while(pad.check_event(Gamepad::BACK_PRESSED) == false) {   //loops until back pressed
     
         lcd.clear();