Gregory Boudreau / Mbed 2 deprecated Lab6_2036_turkey_greg

Dependencies:   4DGL-uLCD-SE PinDetect mbed

Revision:
0:56c7173428ac
diff -r 000000000000 -r 56c7173428ac gobbleBuzz.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gobbleBuzz.cpp	Tue Nov 22 16:42:02 2022 +0000
@@ -0,0 +1,34 @@
+#include "gobbleBuzz.h"
+#include "uLCD_4DGL.h"
+
+
+#define TURKEY_HEIGHT 8
+#define TURKEY_WIDTH 11
+
+extern uLCD_4DGL uLCD;
+
+bool GobbleBuzz::overlap(int upperLX, int upperLY, int lowerRX, int lowerRY)
+{
+    
+    int lrxpos = xpos+TURKEY_WIDTH;
+    int lrypos = ypos+TURKEY_HEIGHT;
+    
+    //first check to see if in the upper left corner of turkey is in rectangle
+    if (((xpos >= upperLX) && (xpos <= lowerRX)) //then x pos satisfied
+       && ((ypos >= upperLY) && (ypos <=lowerRY)))
+        return true;
+    //now check to see if the lower right corner of the turkey is in the rectangle
+    else if ( ((lrxpos >= upperLX) && (lrxpos <= lowerRX)) //then x pos satisfied
+       && ((lrypos >= upperLY) && (lrypos <= lowerRY)) )
+        return true;
+    //now check to see if the upper right corner of turkey is in rectangle
+    else if ( ((lrxpos >= upperLX) && (lrxpos <= lowerRX)) //then x pos satisfied
+       && ((ypos >= upperLY) && (ypos <= lowerRY)) )
+        return true;
+    //now check to see if the lower left corner of the turkey is in rectangle
+    else if ( ((xpos >= upperLX) && (xpos <= lowerRX)) //then x pos satisfied
+       && ((lrypos >= upperLY) && (lrypos <= lowerRY)) )
+        return true;
+    else //no overlap
+        return false;
+}
\ No newline at end of file