Rex Raj / Mbed 2 deprecated el17rrrs

Dependencies:   mbed Gamepad N5110 mbed-rtos

Revision:
11:c3817962923d
Parent:
7:574c66ebd8b0
Child:
12:6017b3f30ad4
--- a/main.cpp	Thu May 09 12:37:58 2019 +0000
+++ b/main.cpp	Thu May 09 12:53:09 2019 +0000
@@ -62,7 +62,6 @@
 void mini_rules();
 void intro();
 void instruction();
-//void intro_song();
 
 bool end = false;
 bool finish = false;
@@ -76,8 +75,8 @@
     init();               // Initialise all the parameters in GameEngine
     
     MainPage currentState = TitleScreen;              // Initial state of MainPage
-    MissionState currentMission = Mission3;    // Initial state of MissionState 
-    MiniState currentMini = Alive;             // Initial state of MiniState
+    MissionState currentMission = Mission1;           // Initial state of MissionState 
+    MiniState currentMini = Alive;                    // Initial state of MiniState
     
     
      while(1) {
@@ -89,7 +88,6 @@
                 thread.start(welcome);
                 intro();
                 thread.terminate(); 
-                // instruction page for the game
                 render_nothing();
                 wait(1.0f/fps);
                 currentState = Menu;
@@ -105,19 +103,21 @@
                 if (pad.check_event(Gamepad::X_PRESSED) == true){
                     currentState = Mission;
                      end = false;
-                    instruction(); 
+                     // instruction page for the game
+                     instruction(); 
                 } else if (pad.check_event(Gamepad::Y_PRESSED) == true){
                     currentState = Mini_Game;
                     finish = false;
+                    // rules page for the mini game
                     mini_rules();
                 }
             break;
             
-            case Mission:
-                // instruction page for the game  
-                currentMission = Mission3;
+            case Mission: 
+                currentMission = Mission1;
                 while(!end){
                     switch(currentMission){
+                      // First Mission
                       case Mission1:
                         shoot.read_input(pad);
                         shoot.update_mission_one(pad,lcd);
@@ -134,11 +134,14 @@
                             currentMission = Mission1;
                         }    
                       break;
+                      // Mission One Failed
                       case Mission1Fail:
+                        // output the mission fail page
                         lcd.clear();
                         lcd.drawSprite(6,5,42,73,(int *)mission_fail);
                         lcd.drawSprite(51,11,7,19,(int *)m_one);
                         lcd.refresh();
+                        // play the mission failure song
                         play.mission_fail(pad);
                         if (pad.check_event(Gamepad::B_PRESSED) == true){
                             currentMission = Mission1;
@@ -147,10 +150,12 @@
                         }
                       break;
                       case Mission1Pass:
+                        // outputs the mission pass page
                         lcd.clear();
                         lcd.drawSprite(0,0,48,84,(int *)mission_pass);
                         lcd.drawSprite(51,11,7,19,(int *)m_one);
                         lcd.refresh();
+                        // plays the mission success song
                         play.mission_success(pad);
                         if (pad.check_event(Gamepad::A_PRESSED) == true){
                             currentMission = Mission2;
@@ -158,6 +163,7 @@
                             init();
                         }
                       break;
+                      // Mission two
                       case Mission2:
                         shoot.read_input(pad);
                         shoot.update_mission_two(pad,lcd);
@@ -171,10 +177,12 @@
                         }
                       break;
                       case Mission2Fail:
+                        // outputs the mission fail page 
                         lcd.clear();
                         lcd.drawSprite(6,5,42,73,(int *)mission_fail);
                         lcd.drawSprite(51,12,5,18,(int *)m_two);
                         lcd.refresh();
+                        // play mission failure song
                         play.mission_fail(pad);
                         if (pad.check_event(Gamepad::B_PRESSED) == true){
                             currentMission = Mission1;
@@ -183,10 +191,12 @@
                         }
                       break;
                       case Mission2Pass:
+                        // outputs the mission pass page 
                         lcd.clear();
                         lcd.drawSprite(0,0,48,84,(int *)mission_pass);
                         lcd.drawSprite(51,12,5,18,(int *)m_two);
                         lcd.refresh();
+                        // plays the mission success song
                         play.mission_success(pad);
                         if (pad.check_event(Gamepad::A_PRESSED) == true){
                             currentMission = Mission3;
@@ -194,6 +204,7 @@
                             init();
                         }
                       break; 
+                      // Mission three
                       case Mission3:
                         shoot.read_input(pad);
                         shoot.update_mission_three(pad,lcd);
@@ -207,6 +218,7 @@
                         }
                       break;
                       case Mission3Fail:
+                        // outputs a mission fail page
                         lcd.clear();
                         lcd.drawSprite(6,5,42,73,(int *)mission_fail);
                         lcd.drawSprite(48,12,5,29,(int *)m_three);
@@ -219,6 +231,7 @@
                         }
                       break;
                       case Mission3Pass:
+                        // outputs a mission pass page
                         lcd.clear();
                         lcd.drawSprite(0,0,48,84,(int *)mission_pass);
                         lcd.drawSprite(48,12,5,29,(int *)m_three);
@@ -295,7 +308,8 @@
     }
 }
 
-void init(){
+void init()
+{
     // need to initialise LCD,Gamepad and the Game
     lcd.init();
     pad.init();
@@ -304,7 +318,8 @@
 
 }
 
-void mini_init(){
+void mini_init()
+{
     // need to initialise LCD,Gamepad and the Game
     lcd.init();
     pad.init();
@@ -363,29 +378,6 @@
     }
     pad.leds_off();
 }
-/*void welcome() 
-{
-     
-    // draws the sprites until the Start button is pressed 
-    
-    while (!music_end) {
-        if(pad.check_event(Gamepad::START_PRESSED) == true){music_end = true; break;}
-        pad.leds_on();
-        lcd.drawSprite(6,0,48,71,(int *)screen);
-        lcd.drawSprite(21,43,5,40,(int *)start);
-        lcd.refresh();
-        wait(0.8);
-        if(pad.check_event(Gamepad::START_PRESSED) == true){music_end = true; break;}
-        pad.leds_off();
-        lcd.drawSprite(6,0,48,71,(int *)screen);
-        lcd.refresh();
-        wait(0.8);
-        if(pad.check_event(Gamepad::START_PRESSED) == true){music_end = true; break;}
-
-    }
-    pad.leds_off();
-}*/
-
 
 void intro() 
 { 
@@ -406,6 +398,7 @@
 
 void mini_rules()
 {
+    // clears, draws the mini game rules page and refreshes the page
     lcd.clear();
     instruct.mini_rules(lcd,pad);
     lcd.refresh();
@@ -425,22 +418,4 @@
     lcd.clear();  
     lcd.refresh();
 }    
-     
-/*void intro_song() // introduction song for the game
-{
-    while(!music_end){ 
-        pad.tone(293.665, 2); 
-        if(music_end == true){break;} // break if start button has been pressed
-        thread.wait(1000); // thread wait so that two loops can simulatneously run
-        pad.tone(311.127, 2);
-        if(music_end == true){break;}
-        thread.wait(1000);
-        pad.tone(329.628, 2);
-        if(music_end == true){break;}
-        thread.wait(1000);
-        pad.tone(349.228, 2);
-        if(music_end == true){break;}
-        thread.wait(1000);
-    }
-}*/