ELEC2645 (2017/18) / Mbed 2 deprecated ll13jrm

Dependencies:   mbed

Revision:
12:9f2f64016f56
Parent:
11:e260c17a0489
Child:
13:72bc2579e85e
--- a/Snake/Snake.cpp	Fri Apr 06 15:15:50 2018 +0000
+++ b/Snake/Snake.cpp	Mon Apr 09 10:16:58 2018 +0000
@@ -11,6 +11,16 @@
 
 }
 
+Vector2D g_snake_position()
+{
+    
+    extern Vector2D g_p;
+    
+    return g_p;
+    
+}
+
+
 void Snake::init()
 {
     
@@ -305,54 +315,61 @@
 void Snake::set_snake_position(Direction next)
 {
     next = get_snake_direction();
-    Vector2D p;
+    // Vector2D p;
+    
+    extern Vector2D g_p;
+    
+    // extern int g_x;
+    // extern int g_y;
     
     switch(next) {
         
             case(N):
         
-            p.x = p.x;
-            --p.y;
+            g_p.x = g_p.x;
+            --g_p.y;
         
             break;
         
             case(E):
         
-            ++p.x;
-            p.y = p.y;
+            ++g_p.x;
+            g_p.y = g_p.y;
         
             break;
         
             case(S):
         
-            p.x = p.x;
-            ++p.y;
+            g_p.x = g_p.x;
+            ++g_p.y;
         
             break;
         
             case(W):
         
-            --p.x;
-            p.y = p.y;
+            --g_p.x;
+            g_p.y = g_p.y;
         
             break;
             
             default:
             
-            p.x = p.x;
-            p.y = p.y;
+            g_p.x = g_p.x;
+            g_p.y = g_p.y;
             
             break;
             
             }
             
-            _x = p.x;
-            _y = p.y;
-    
+        
+            _x = g_p.x;
+            _y = g_p.y;
+        
 }
 
 Vector2D Snake::get_snake_position()
 {
+    
     Vector2D pos = {_x, _y};
     
     return pos;