test 1 doc

Dependencies:   mbed Gamepad2

Revision:
11:b3024ab59fa5
Parent:
7:530ca713d2b2
Child:
12:eb8d30593e95
--- a/main.cpp	Wed May 27 02:00:08 2020 +0000
+++ b/main.cpp	Wed May 27 03:52:11 2020 +0000
@@ -16,14 +16,14 @@
 #include "Bitmap.h"
 #include "Player.h"
 #include "Engine.h"
-    
+
 // objects
 Gamepad pad;
 N5110 lcd;
 Player player;
 Engine engine;
 
-// input 
+// input
 struct UserInput {
     Direction d;
     float mag;
@@ -33,7 +33,8 @@
 void init();
 void display();
 
-
+// variables
+bool gameState = 0;
 
 int main()
 {
@@ -44,14 +45,17 @@
     int fps = 10;  // frames per second
     display();  // first draw the initial frame
     wait(1.0f/fps);  // and wait for one frame period
-    // game loop 
-    while (1) {
+    // game loop
+    while (gameState == 0) {
         lcd.setContrast( pad.read_pot1()); //contrast set by pot1
         engine.read_input(pad);            //reads input from pad
         engine.update(pad);                //update physics and calculations
         display();                         //display on screen
         wait(1.0f/fps);                    //wait for fps
-    }      
+        gameState = engine.enemyCollide();
+    }
+    engine.gameOver(lcd);
+    lcd.refresh();
 }
 
 //initialisation