Musallam Bseiso / Mbed 2 deprecated nemesis_v1

Dependencies:   Enemy1 Enemy2 Enemy3 Enemy4 Enemy5 Enemy6 Engine Friendly Gamepad N5110 Rocket Stats mbed

Revision:
9:51a357a1178c
Parent:
8:ad3857f100fe
Child:
10:34fa0a4f5513
--- a/main.cpp	Tue May 02 22:14:51 2017 +0000
+++ b/main.cpp	Wed May 03 20:04:32 2017 +0000
@@ -3,59 +3,85 @@
 #include "N5110.h"
 #include "Engine.h"
 
-#define STAGE_ONE 2
-#define STAGE_TWO 3
-#define STAGE_THREE 4
+#define LEVEL_ONE 2
 
 struct UserInput {
     Direction d;
     float mag;
 };
 
-N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
-Gamepad pad;
-Engine engine;
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);  // LCD pin connections.
+Gamepad pad;                                // Gamepad object.
+Engine engine;                              // Engine object.
+
+
+/** Initialize
+*   
+*   Initializes LCD, gamepad, and engine.
+*/
+void init();
+
 
-void init();
-void update_game(UserInput input);
+/** Generate
+*   
+*   Draws all the elements onto the LCD, from the engine.
+*/
 void generate();
+
+
+/** Welcome Screen
+*   
+*   Prints the welcome message to the LCD, and waits for the start button to be pressed
+*   to start the game.
+*/
 void welcome();
 
+
 int main()
 {
-    int fps = 14;
+    int fps = 14;       // Framerate.
 
-    init();
-    welcome();
-    generate();
+    init();             // Initialization.
+    welcome();          // Welcome screen.
     wait(1.0f/fps);  
     
-    while (1) {
-        engine.read_input(pad);
-        engine.check_all(lcd, pad);
-        engine.update_all(lcd, pad);
-        generate();
-        engine.shoot_rocket(lcd, pad);
-        engine.shoot_star(lcd, pad);
+    
+    // Game loop:
+    while (1) {         
+        engine.read_input(pad);         // Reads gamepad input to log changes in analog stick movement.
+        engine.check_all(lcd, pad);     // Checking method for all the elements, from the engine.
+        engine.update_all(lcd, pad);    // Updating method for all the elements, from the engine.
+        generate();                     // Drawing.
+        engine.shoot_rocket(lcd, pad);  // Rocket shooting method, from the engine.
+        engine.shoot_star(lcd, pad);    // Star shooting method, from the engine.
         lcd.refresh();
         wait(1.0f/fps);
     }
 }
 
+
+// Initialization:
+
 void init()
 {
-    lcd.init();
-    pad.init();
-    engine.init(STAGE_ONE, lcd, pad);
+    lcd.init();     // LCD initialization.
+    pad.init();     // Gamepad initialization.
+    engine.init(LEVEL_ONE, lcd, pad, 0, 0, 3, true, 3);     // Engine initialization, using initial values for variables.
 }
 
+
+// Draws everything:
+
 void generate()
 {
     lcd.clear();  
-    engine.draw_all(lcd);       // grid, health
+    engine.draw_all(lcd);   // Draws all the elements to the LCD screen, from the engine.   
     lcd.refresh();
 }
 
+
+// Draws the welcome screen:
+
 void welcome() {
     
     lcd.printString("    NEMESIS    ",0,2);
@@ -64,6 +90,6 @@
     lcd.refresh();
 
     while ( pad.check_event(Gamepad::START_PRESSED) == false) {
-        wait(0.1);
+        wait(0.1);      // Waits till the start button is pressed.
     }
 }
\ No newline at end of file