Final Submission. I have read and agreed with Statement of Academic Integrity.

Dependencies:   mbed Gamepad N5110 Joystick

Revision:
5:23a85b16ee54
Parent:
4:0fc3441556e1
Child:
8:264398d3c610
diff -r 0fc3441556e1 -r 23a85b16ee54 main.cpp
--- a/main.cpp	Thu May 09 07:26:07 2019 +0000
+++ b/main.cpp	Thu May 09 08:33:26 2019 +0000
@@ -13,9 +13,6 @@
 #include "main.h"
 #include "Snake.h"
 #include "Game_engine.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h> 
 
 // Gamepad Peripherals
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
@@ -25,19 +22,23 @@
 // Instances
 GameEngine engine;
 
+bool game_cont = false;
+
 
 int main() {
-    srand(time(NULL));
+    //srand(time(NULL));
     Init(); 
     Welcome();
     engine.init();
-    
+    //bool game_cont = true;
 
     
-    while(1) {
+    while(engine.get_game_cont() == true) {
         render();
         update();
     }
+    lcd.clear();
+    lcd.refresh();
 }
 
 
@@ -55,7 +56,7 @@
     gamepad.check_event(Gamepad::L_PRESSED);
     gamepad.check_event(Gamepad::R_PRESSED);
     gamepad.check_event(Gamepad::BACK_PRESSED);
-    gamepad.check_event(Gamepad::START_PRESSED);  
+    gamepad.check_event(Gamepad::START_PRESSED); 
 }
 
 // Prototype welcome screen
@@ -73,6 +74,8 @@
     lcd.refresh();
 }
 void update() {
+    engine.check_wall_collision();
+    engine.check_snake_collision();
     engine.get_dir(gamepad);
     engine.snake_move();
     engine.food_move();