Rex Raj / Mbed 2 deprecated el17rrrs

Dependencies:   mbed Gamepad N5110 mbed-rtos

Revision:
5:016a7315b75d
Parent:
3:bf9624e5b0c3
Child:
6:1fcfd331c047
diff -r 4d673fb2d9dc -r 016a7315b75d Instruction/Instruction.cpp
--- a/Instruction/Instruction.cpp	Sun May 05 17:41:46 2019 +0000
+++ b/Instruction/Instruction.cpp	Mon May 06 18:29:49 2019 +0000
@@ -9,18 +9,18 @@
 {
 
 }
-
+// sprite of the instruction page
 int instruction1 [47][83] = {
     
 {0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
 {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},
-{0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},
-{0,0,0,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0},
-{0,0,0,0,0,1,0,0,1,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},
 {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},
 {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},
@@ -62,6 +62,7 @@
 
 };
 
+//sprite of the game rules page
 int game_rules [8] [74] = {
 
 {0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,0,0,0,0,0,0},
@@ -75,12 +76,14 @@
 
 };
 
+// sprite of the game rules top border
 int game_top [1][82] = {
 
 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
 
 };
 
+// sprite of the game rules side border
 int game_side [48][1] = {
 
 {1},
@@ -133,7 +136,8 @@
 {1},
 
 };    
-        
+
+// sprite of the instruction page side border        
 int instruction_side [37][1] = {
     
 {1},
@@ -176,6 +180,7 @@
 
 };    
 
+// sprite of rule one
 int rule_one [13] [75] = {
     
 {0,0,1,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0,0,1,1,1,1,1,0,1,1,1,1,1,0,0,0,0,0,0,0},
@@ -193,7 +198,8 @@
 {0,0,0,0,0,0,0,1,1,1,1,1,0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
 
 };
-    
+
+// sprite of rule two    
 int  rule_two [13] [69] = {
     
 {1,1,1,1,0,0,0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,0,1,1,1,1,1,0,1,1,1,1,1,0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1},
@@ -212,6 +218,7 @@
 
 };       
 
+// sprite of rule three
 int  rule_three [31] [76] = {
     
 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
@@ -248,6 +255,7 @@
 
 };    
 
+//sprite of rule four
 int  rule_four [31] [76] = {
     
 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
@@ -284,6 +292,7 @@
 
 };    
 
+// sprite of rule five
 int rule_five [31][76] = {
     
 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
@@ -320,6 +329,7 @@
 
 };    
 
+// sprite of rule six page one
 int rule_six [31][76] = {
     
 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
@@ -356,6 +366,7 @@
 
 };
 
+// sprite of rule six page two
 int rule_six_two [13] [76] = {
     
 {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
@@ -374,6 +385,7 @@
 
 };
 
+// sprite of goodluck
 int goodluck [14] [76] = {        
 
 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0},
@@ -393,6 +405,7 @@
 
 };
 
+// sprite of press start 
 int press_start [14][43] = {
     
 {0,0,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,0,0,1,0,0,0,0,0,0,0},
@@ -412,6 +425,7 @@
 
 };    
 
+// sprite of a captain's hat
 int hat [14][22] = {
     
 {0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
@@ -431,16 +445,17 @@
 
 };
 
-enum States { Life1,Life2,Life3,Life4,Life5,Life6,Life7,Life8,Life9,Life10,Life11,Life12 };
+enum States { Life1,Life2,Life3,Life4,Life5,Life6,Life7,Life8,Life9,Life10,Life11,Life12 }; // enum state for instruction and game page
 
 void Instruction::rules(N5110 &lcd,Gamepad &pad){ 
 
-int fps = 8;
-States currentInstruction = Life1;
+int fps = 5; // set the frames per second to 5
+States currentInstruction = Life1; // current instruction is Life 1
         
-     while(currentInstruction != Life12) {
+     while(currentInstruction != Life12) { 
         switch(currentInstruction){
               case Life1:
+                // draws the first instrcution 
                 lcd.clear();
                 lcd.drawSprite(1,0,47,83 ,(int *)instruction1);
                 lcd.printString(" Destroy the",4,1);
@@ -454,6 +469,7 @@
               break;
               case  Life2:
                 lcd.clear();
+                // draws the second instrcution
                 lcd.drawSprite(1,0,47,83 ,(int *)instruction1);
                 lcd.printString(" There are",4,1);
                 lcd.printString(" three'",4,2);
@@ -465,6 +481,7 @@
                 }
               break;
               case  Life3:
+                // draws the third instrcution
                 lcd.clear();
                 lcd.drawSprite(1,0,47,83 ,(int *)instruction1);
                 lcd.printString(" Each with",4,1);
@@ -477,6 +494,7 @@
                 }
               break;
               case  Life4:
+                // draws the fourth instrcution
                 lcd.clear();
                 lcd.drawSprite(1,0,47,83 ,(int *)instruction1);
                 lcd.printString(" Your goal",4,1);
@@ -489,6 +507,7 @@
                 }
               break;
               case Life5:
+                // draws the first and second game rules
                 lcd.clear();
                 lcd.drawSprite(6,5,8,74 ,(int *)game_rules);
                 lcd.drawSprite(2,2,1,82 ,(int *)game_top);
@@ -499,11 +518,12 @@
                 lcd.drawSprite(7,32,13,69 ,(int *)rule_two);
                 lcd.refresh(); 
                 if(pad.get_direction() ==  E){ 
-                currentInstruction = Life6;
+                currentInstruction = Life6;    // sets current instruction = Life6 if joystick moves to the right
                 } 
                 wait(1.0f/fps);
               break;   
               case Life6:
+                // draws the third game rule
                 lcd.clear();
                 lcd.drawSprite(6,5,8,74 ,(int *)game_rules);
                 lcd.drawSprite(2,2,1,82 ,(int *)game_top);
@@ -513,14 +533,15 @@
                 lcd.drawSprite(2,46,1,82 ,(int *)game_top);
                 lcd.refresh(); 
                 if(pad.get_direction() ==  W){ 
-                currentInstruction = Life5;
+                currentInstruction = Life5;    // sets current instruction = Life5if joystick moves to the left
                 }
                 if(pad.get_direction() ==  E){ 
-                currentInstruction = Life7;
+                currentInstruction = Life7;    // sets current instruction = Life7if joystick moves to the right
                 }  
                 wait(1.0f/fps);
               break;
              case Life7:
+                // draws the fourth game rule
                 lcd.clear();
                 lcd.drawSprite(6,5,8,74 ,(int *)game_rules);
                 lcd.drawSprite(2,2,1,82 ,(int *)game_top);
@@ -530,14 +551,15 @@
                 lcd.drawSprite(81,1,48,1 ,(int *)game_side);
                 lcd.refresh();
                 if(pad.get_direction() ==  W){ 
-                currentInstruction = Life6;
+                currentInstruction = Life6;    // sets current instruction = Life6 if joystick moves to the left
                 }
                 if(pad.get_direction() ==  E){ 
-                currentInstruction = Life8;
+                currentInstruction = Life8;    // sets current instruction = Life8if joystick moves to the right
                 } 
                 wait(1.0f/fps);
               break;
               case Life8:
+                // draws the fifth game rule
                 lcd.clear();
                 lcd.drawSprite(6,5,8,74 ,(int *)game_rules);
                 lcd.drawSprite(2,2,1,82 ,(int *)game_top);
@@ -547,14 +569,15 @@
                 lcd.drawSprite(81,1,48,1 ,(int *)game_side);
                 lcd.refresh();
                 if(pad.get_direction() ==  W){ 
-                currentInstruction = Life7;
+                currentInstruction = Life7;    // sets current instruction = Life7 if joystick moves to the left
                 }
                 if(pad.get_direction() ==  E){ 
-                currentInstruction = Life9;
+                currentInstruction = Life9;    // sets current instruction = Life9 if joystick moves to the right
                 } 
                 wait(1.0f/fps);
               break;
               case Life9:
+                // draws the page one of the sixth game rule
                 lcd.clear();
                 lcd.drawSprite(6,5,8,74 ,(int *)game_rules);
                 lcd.drawSprite(2,2,1,82 ,(int *)game_top);
@@ -564,14 +587,15 @@
                 lcd.drawSprite(81,1,48,1 ,(int *)game_side);
                 lcd.refresh(); 
                 if(pad.get_direction() ==  W){ 
-                currentInstruction = Life8;
+                currentInstruction = Life8;    // sets current instruction = Life8 if joystick moves to the left
                 }
                 if(pad.get_direction() ==  E){ 
-                currentInstruction = Life10;
+                currentInstruction = Life10;   // sets current instruction = Life10 if joystick moves to the right
                 } 
                 wait(1.0f/fps);
               break;
               case Life10:
+              // draws the page two of the sixth game rule
                 lcd.clear();
                 lcd.drawSprite(6,5,8,74 ,(int *)game_rules);
                 lcd.drawSprite(2,2,1,82 ,(int *)game_top);
@@ -581,15 +605,16 @@
                 lcd.drawSprite(81,1,48,1 ,(int *)game_side);
                 lcd.refresh();
                 if(pad.get_direction() ==  W){ 
-                currentInstruction = Life9;
+                currentInstruction = Life9;    // sets current instruction = Life9 if joystick moves to the left
                 }
                 if(pad.get_direction() ==  E){ 
-                currentInstruction = Life11;
+                currentInstruction = Life11;   // sets current instruction = Life11 if joystick moves to the right
                 } 
                 wait(1.0f/fps);
               break;
               case Life11:
                 while(pad.check_event(Gamepad::A_PRESSED) == false){
+                    // draws the goodluck page & makes the hat flash
                     lcd.clear();
                     lcd.drawSprite(6,5,8,74 ,(int *)game_rules);
                     lcd.drawSprite(2,2,1,82 ,(int *)game_top);
@@ -612,11 +637,11 @@
                     lcd.refresh();
                     wait(0.5);
                     if(pad.get_direction() ==  W){ 
-                    currentInstruction = Life10;
+                    currentInstruction = Life10;   // sets current instruction = Life10 if joystick moves to the left
                     break;
                     }
                     if(pad.check_event(Gamepad::A_PRESSED) == true){ 
-                    currentInstruction = Life12;
+                    currentInstruction = Life12;   // sets current instruction = Life12 if joystick moves to the right
                     break;
                     }
                     wait(1.0f/fps);
@@ -629,49 +654,6 @@
     }   
 }
 
-//void Instruction::instruction(N5110 &lcd,Gamepad &pad)
-//{
-//    while(pad.check_event(Gamepad::A_PRESSED) == false){
-//        lcd.clear();
-//        lcd.drawSprite(1,0,47,83 ,(int *)instruction1);
- //       lcd.printString(" Destroy the",4,1);
-  //      lcd.printString(" enemies'",4,2);
- //       lcd.printString(" spacecraft",4,3);
- //       lcd.drawSprite(6,4,37,1,(int *)instruction_side);
- //       lcd.refresh();
-  //  }
-//}
-
-//void Instruction::instruction6(N5110 &lcd,Gamepad &pad)
-//{
- //   while(pad.check_event(Gamepad::A_PRESSED) == false){
-   //     lcd.clear();
-    //    lcd.drawSprite(1,0,47,83 ,(int *)game_rules);
-     //   lcd.printString(" You have 6",2,2);
-     //   lcd.printString(" lives,shown",2,3);
-     //   lcd.printString(" by the LEDs",2,4);
-      //  lcd.drawSprite(2,11,37,1 ,(int *)instruction_side);
-        //lcd.printString(" the LEDs",2,5);
-     //   lcd.refresh();
-     //   if(pad.check_event(Gamepad::A_PRESSED) == true){break;}
-   // }
-//}
-
-//void Instruction::instruction7(N5110 &lcd,Gamepad &pad)
-//{
- //   while(pad.check_event(Gamepad::A_PRESSED) == false){
- //       lcd.clear();
- //       lcd.drawSprite(1,0,48,83 ,(int *)game_rules);
- //       lcd.printString("Enemy's health",0,2);
- //       lcd.printString(" bar is at",0,3);
- //       lcd.printString(" bottom right",0,4);
- //       lcd.printString(" corner",0,5);
- //       lcd.drawSprite(2,11,37,1 ,(int *)instruction_side);
- //       lcd.drawSprite(1,46,1,83 ,(int *)instruction_top);
- //       lcd.refresh();
- //       if(pad.check_event(Gamepad::A_PRESSED) == true){break;}
- //   }
-//}