submit

Dependencies:   mbed Gamepad N5110

Revision:
1:b49c36604125
Parent:
0:b67614a0c4cf
Child:
2:934daa65f73d
--- a/main.cpp	Tue Apr 02 06:46:47 2019 +0000
+++ b/main.cpp	Sat Apr 13 10:07:50 2019 +0000
@@ -2,17 +2,20 @@
 #include "mbed.h"
 #include "Gamepad.h"
 #include "N5110.h"
+#include "snake.h"
+#include "Engine.h"
 
 /////////////// structs /////////////////
-
 struct UserInput {
     Direction d;
     float mag;
 };
+
 /////////////// objects ///////////////
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
 Gamepad pad;
-
+snake snake;
+Engine engine;
 
 ///////////// prototypes ///////////////
 void init();
@@ -28,16 +31,15 @@
     init(); 
     welcome();  // show welcome display, waiting for the user to start
     
-    run();  // first draw the initial frame     
-    wait(1.0f/fps);  // and wait for one frame period
+
+    while (1) {
+
+    run();
+    wait(5.0f/fps);  // and wait for one frame period
+}
     
      // game loop - read input, update the game state and render the display
-   // while (1) {
-   //     pong.read_input(pad);
-   //    pong.update(pad);
-    //    run();
-    //    wait(1.0f/fps);
-   // }
+
 }
 
 // simple splash screen displayed on start-up
@@ -62,7 +64,10 @@
 {
     // clear screen, re-draw and refresh
     lcd.clear();
-   // snake.draw();
+    int length = snake.get_length();
+    snake.draw(lcd,length);
+    int direction = engine.get_direction(pad);
+    snake.update(direction,length);
     lcd.refresh();
 }
 
@@ -71,7 +76,10 @@
 {
     // need to initialise LCD and Gamepad 
     lcd.init();
-    pad.init();
+    pad.init();    
+    snake.init(1,3);
      
 }
 
+
+