Steven Mahasin / Mbed 2 deprecated DreamDungeon

Dependencies:   mbed MotionSensor

Revision:
48:f7d9ae3e554d
Parent:
47:6e31b195ce3c
Child:
49:3f83ed62d123
--- a/Title/Title.cpp	Thu May 09 01:57:49 2019 +0000
+++ b/Title/Title.cpp	Thu May 09 02:46:44 2019 +0000
@@ -21,21 +21,16 @@
             lcd.clear();
             draw_title_screen(lcd);
             lcd.refresh();
-            
             title_options_joystick(gamepad);
-            
             title_count++;
             wait_ms(1000/40); // 1s/framerate
         }
         while(gamepad.check_event(Gamepad::A_PRESSED)){}
-        if(title_option == 0) {
-            break;
-        } else if (title_option == 1) {
-            title_option_option(lcd, gamepad, player, global_contrast);
-        } else if (title_option == 2) {
-            title_option_credit(lcd, gamepad);
-        } else if (title_option == 3) {
-            title_option_tutorial(lcd, gamepad);
+        
+        if(title_option == 0) { break;  // Start game, exit title loop
+        } else if (title_option == 1) { title_option_option(lcd, gamepad, player, global_contrast);
+        } else if (title_option == 2) { title_option_credit(lcd, gamepad);
+        } else if (title_option == 3) { title_option_tutorial(lcd, gamepad);
         }
     }
     player.~Player();
@@ -87,15 +82,14 @@
         player.draw(lcd);
         player.draw_bullets(lcd, player.get_pos_y() + 2);
         lcd.refresh();
-        player.move(1, 0, (char *)level_map[0][0], (bool *)sprite_transparent_player);
-        player.undo_move_x(true);
-        player.buttons(false, true, false, false);
-        player.update_bullets((char *)level_map[0][0], (bool *)sprite_transparent_player);
+        player.move(1, 0, (char *)level_map[0][0], (bool *)sprite_transparent_player);  // Adding animation of walking
+        player.undo_move_x(true);   // Keeping the player in place
+        player.buttons(false, true, false, false);  // Instructing player to shoot right
+        player.update_bullets((char *)level_map[0][0], (bool *)sprite_transparent_player);  // Move the bullets and delete those out of the screen
         wait_ms(1000/40);
     }
     wait(0.05);
-    while(gamepad.check_event(Gamepad::A_PRESSED)) {
-    }
+    while(gamepad.check_event(Gamepad::A_PRESSED)) {}
 }
 
 void Title::title_option_credit(N5110 &lcd, Gamepad &gamepad)
@@ -115,6 +109,25 @@
 
 void Title::title_option_tutorial(N5110 &lcd, Gamepad &gamepad)
 {
+    print_tutorial_page_0(lcd);                         // print page 0 and wait for button toggle
+    wait(0.05);
+    while(!gamepad.check_event(Gamepad::A_PRESSED)) {}
+    wait(0.05);
+    while(gamepad.check_event(Gamepad::A_PRESSED)) {}
+    print_tutorial_page_1(lcd);                         // print page 1 and wait for button toggle
+    wait(0.05);
+    while(!gamepad.check_event(Gamepad::A_PRESSED)) {}
+    wait(0.05);
+    while(gamepad.check_event(Gamepad::A_PRESSED)) {}
+    print_tutorial_page_2(lcd);                         // print page 2 and wait for button toggle
+    wait(0.05);
+    while(!gamepad.check_event(Gamepad::A_PRESSED)) {}
+    wait(0.05);
+    while(gamepad.check_event(Gamepad::A_PRESSED)) {}
+}
+
+void Title::print_tutorial_page_0(N5110 &lcd)
+{
     lcd.clear();
     lcd.printString("Use the joypad", 0, 0);
     lcd.printString("to move the", 0, 1);
@@ -123,12 +136,10 @@
     lcd.printString("ABXY to shoot", 0, 4);
     lcd.printString("directionally", 0, 5);
     lcd.refresh();
-    wait(0.05);
-    while(!gamepad.check_event(Gamepad::A_PRESSED)) {
-    }
-    wait(0.05);
-    while(gamepad.check_event(Gamepad::A_PRESSED)) {
-    }
+}
+
+void Title::print_tutorial_page_1(N5110 &lcd)
+{
     lcd.clear();
     lcd.printString("Hold L to", 0, 0);
     lcd.printString("show player", 0, 1);
@@ -137,21 +148,13 @@
     lcd.printString("to view a", 0, 4);
     lcd.printString("minimap", 0, 5);
     lcd.refresh();
-    wait(0.05);
-    while(!gamepad.check_event(Gamepad::A_PRESSED)) {
-    }
-    wait(0.05);
-    while(gamepad.check_event(Gamepad::A_PRESSED)) {
-    }
+}
+
+void Title::print_tutorial_page_2(N5110 &lcd)
+{
     lcd.clear();
     lcd.printString("Press Start", 0, 0);
     lcd.printString("to pause", 0, 1);
     lcd.printString("the game", 0, 2);
     lcd.refresh();
-    wait(0.05);
-    while(!gamepad.check_event(Gamepad::A_PRESSED)) {
-    }
-    wait(0.05);
-    while(gamepad.check_event(Gamepad::A_PRESSED)) {
-    }
-}
+}
\ No newline at end of file