ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18lg

Dependencies:   mbed

Revision:
7:24a3f13ce36d
Parent:
6:266fb8fc17f4
Child:
9:f3259d652208
diff -r 266fb8fc17f4 -r 24a3f13ce36d main.cpp
--- a/main.cpp	Thu May 28 22:56:46 2020 +0000
+++ b/main.cpp	Sun May 31 14:12:45 2020 +0000
@@ -28,12 +28,15 @@
 Body _b;
 Food _f;
 
+
+
 void init();
 void render();
+void update();
    int main()
 {
      int fps = 6;  // frames per second
-
+    
     init();     // initialise and then display welcome screen...
     
     render();  // first draw the initial frame 
@@ -43,7 +46,7 @@
     // game loop - read input, update the game state and render the display
     while (1) {
         snake.read_input(pad);
-        snake.update(pad, lcd);
+        snake.update(pad, lcd); 
         render();
         wait(1.0f/fps);
          
@@ -51,18 +54,22 @@
 }
 #define HEAD_LENGTH 1
 #define HEAD_SPEED 0.5
+#define FOOD_SIZE 1
+
 // initialies all classes and libraries
 void init()
 {
+
     // need to initialise LCD and Gamepad 
     lcd.init();
     pad.init();
      
     // initialise the game with correct ball and paddle sizes
-    snake.init(HEAD_LENGTH,HEAD_SPEED);
-      
+    snake.init(HEAD_LENGTH,HEAD_SPEED, FOOD_SIZE);
+     
 }
 
+
 // this function draws each frame on the LCD
 void render()
 {
@@ -71,6 +78,7 @@
     snake.draw(lcd);
     lcd.refresh();
 }
+