Declaration: I have read the University Regulations on Plagiarism [1] and state that the work covered by this declaration is my own and does not contain any unacknowledged work from other sources. I understand that my code will be run through a source code plagiarism detection engine and will be compared to all code submitted in this module (both in Leeds and at the Joint School in China). I confirm my consent to the University copying and distributing any or all of my work in any form and using third parties (who may be based outside the EU/EEA) to monitor breaches of regulations, to verify whether my work contains plagiarised material, and for quality assurance purposes. I confirm that details of any mitigating circumstances or other matters which might have affected my performance and which I wish to bring to the attention of the examiners, have been submitted to the Student Support Office. [1] Available on the School Student Intranet

Dependencies:   mbed Gamepad N5110 Joystick

Revision:
5:23a85b16ee54
Parent:
4:0fc3441556e1
Child:
8:264398d3c610
--- 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();