Joe Shotton / Mbed 2 deprecated ELEC2645_Project_ll16j23s

Dependencies:   mbed ll16j23s_test_docs

Revision:
6:6c9453397f4a
Parent:
5:06fa7674622a
Child:
7:dd84e0fab346
diff -r 06fa7674622a -r 6c9453397f4a SnakeEngine/SnakeEngine.cpp
--- a/SnakeEngine/SnakeEngine.cpp	Sat May 23 17:16:44 2020 +0000
+++ b/SnakeEngine/SnakeEngine.cpp	Sat May 23 20:01:00 2020 +0000
@@ -25,6 +25,7 @@
 */
 void SnakeEngine::init(FXOS8700CQ &mag){
     _food.init(mag);
+    _body.init();
     //_food.rand_pos(_food._x, _food._y);
 }
 
@@ -46,23 +47,45 @@
     pad.led(3,0.9);
     _length += 5;
     score++;
-    
-    /*
-    for(int i = 1; i < _length; i++) {
-        if (_x_head == _body_x[i] && _y_head == _body_y[i]) { //checks if head coord is the same as any of the body coords
-            pad.led(1,0.9);
-            //printf("DEAD \n");
-            _state = 0;
-            death = true;
-            //return true;
-        } else {
-            //pad.led(1,0.0);
-            //printf("ALIVE \n");
-            //return false;
-        }
-    */
-    
-    
     }
 }
 
+void SnakeEngine::transition_black(N5110 &lcd) {
+    //lcd.clear();
+    for (int j = 0; j < 21; j += 4) {
+        printf("j: %d\n", j);
+        for (int i = 1; i < 84 - (2*j); i += 2) {
+            lcd.drawRect(j, j, i + 1, 4, FILL_BLACK);
+            lcd.drawRect(83 - j - i, 44 - j, i + 1, 4, FILL_BLACK);  
+            wait_ms(5);   
+            lcd.refresh();
+        }
+        for (int i = 1; i < 43 - (2*j); i += 2) {
+            lcd.drawRect(80 - j, 4 + j, 4, i,FILL_BLACK);
+            lcd.drawRect(j, 44 - i - j, 4, i,FILL_BLACK); 
+            wait_ms(5);   
+            lcd.refresh();
+        }
+    }
+    wait_ms(500);      
+}
+
+void SnakeEngine::transition_white(N5110 &lcd) {
+    //lcd.clear();
+    for (int j = 0; j < 21; j += 4) {
+        printf("j: %d\n", j);
+        for (int i = 1; i < 84 - (2*j); i += 2) {
+            lcd.drawRect(j, j, i + 1, 4, FILL_WHITE);
+            lcd.drawRect(83 - j - i, 44 - j, i + 1, 4, FILL_WHITE);  
+            wait_ms(5);   
+            lcd.refresh();
+        }
+        for (int i = 1; i < 43 - (2*j); i += 2) {
+            lcd.drawRect(80 - j, 4 + j, 4, i,FILL_WHITE);
+            lcd.drawRect(j, 44 - i - j, 4, i,FILL_WHITE); 
+            wait_ms(5);   
+            lcd.refresh();
+        }
+    }
+    //wait_ms(500);      
+}