ELEC2645 (2017/18) / Mbed OS el16ajm
Revision:
2:9ca5e1c221c3
Parent:
1:a14415de3ad5
Child:
3:6253a2d374fa
diff -r a14415de3ad5 -r 9ca5e1c221c3 main.cpp
--- a/main.cpp	Mon Apr 16 09:07:17 2018 +0000
+++ b/main.cpp	Mon Apr 16 10:55:00 2018 +0000
@@ -2,10 +2,10 @@
 ELEC2645 Embedded Systems Project
 School of Electronic & Electrical Engineering
 University of Leeds
-Name:
-Username:
-Student ID Number:
-Date:
+Name: Andrew Moore
+Username: el16ajm
+Student ID Number: 201042893
+Date: 
 */
 
 #include "mbed.h"
@@ -33,8 +33,21 @@
 ///////////// functions ////////////////
 int main()
 {
+    int fps = 8;  // frames per second
+    
     init();
     welcome();
+    
+    wait(1.0f/fps);  // and wait for one frame period
+
+
+    // game loop - read input, update the game state and render the display
+    while (1) {
+        gameEngine.read_input(pad);
+        gameEngine.update(pad);
+        render();
+        wait(1.0f/fps);
+    }
 }
 
 void welcome()
@@ -59,3 +72,11 @@
     pad.init();     
 
 }
+
+void render()
+{
+    // clear screen, re-draw and refresh
+    lcd.clear();  
+    gameEngine.draw(lcd);
+    lcd.refresh();
+}