Joe Shotton / ll16j23s_test_docs

Files at this revision

API Documentation at this revision

Comitter:
JoeShotton
Date:
Sun Apr 05 21:15:07 2020 +0000
Parent:
25:ec8f4bea154c
Child:
27:68cc4ef820f4
Commit message:
collision detection implemented and added to SnakeEngine source and header files

Changed in this revision

SnakeEngine.cpp Show annotated file Show diff for this revision Revisions of this file
SnakeEngine.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SnakeEngine.cpp	Sun Apr 05 21:15:07 2020 +0000
@@ -0,0 +1,12 @@
+        
+bool collision(int state, int x, int y,) {
+    if ((lcd.getPixel(x, y) == 1 && ((state == 1) || (state == 4))) || (lcd.getPixel(x+1, y+1) == 1 && ((state == 2) || (state == 3)))) {
+        // checks infront of head to see if pixel is set
+        // due to the size of the head, there is an offset for the check for North and Eastward directions
+        pad.led(1,0.9);
+        return true; 
+    } else {
+        pad.led(1,0.0);
+        return = false;
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SnakeEngine.h	Sun Apr 05 21:15:07 2020 +0000
@@ -0,0 +1,9 @@
+
+
+
+    /** Play a single tone for the specifed duration
+    *@param state of movement fsm
+    *@param current x value of head
+    *@param current y value of head
+    */
+    bool collision(int state, int x, int y,);
\ No newline at end of file