Gregory Boudreau / Mbed 2 deprecated Lab6_2036_turkey_greg

Dependencies:   4DGL-uLCD-SE PinDetect mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers gobbleBuzz.cpp Source File

gobbleBuzz.cpp

00001 #include "gobbleBuzz.h"
00002 #include "uLCD_4DGL.h"
00003 
00004 
00005 #define TURKEY_HEIGHT 8
00006 #define TURKEY_WIDTH 11
00007 
00008 extern uLCD_4DGL uLCD;
00009 
00010 bool GobbleBuzz::overlap(int upperLX, int upperLY, int lowerRX, int lowerRY)
00011 {
00012     
00013     int lrxpos = xpos+TURKEY_WIDTH;
00014     int lrypos = ypos+TURKEY_HEIGHT;
00015     
00016     //first check to see if in the upper left corner of turkey is in rectangle
00017     if (((xpos >= upperLX) && (xpos <= lowerRX)) //then x pos satisfied
00018        && ((ypos >= upperLY) && (ypos <=lowerRY)))
00019         return true;
00020     //now check to see if the lower right corner of the turkey is in the rectangle
00021     else if ( ((lrxpos >= upperLX) && (lrxpos <= lowerRX)) //then x pos satisfied
00022        && ((lrypos >= upperLY) && (lrypos <= lowerRY)) )
00023         return true;
00024     //now check to see if the upper right corner of turkey is in rectangle
00025     else if ( ((lrxpos >= upperLX) && (lrxpos <= lowerRX)) //then x pos satisfied
00026        && ((ypos >= upperLY) && (ypos <= lowerRY)) )
00027         return true;
00028     //now check to see if the lower left corner of the turkey is in rectangle
00029     else if ( ((xpos >= upperLX) && (xpos <= lowerRX)) //then x pos satisfied
00030        && ((lrypos >= upperLY) && (lrypos <= lowerRY)) )
00031         return true;
00032     else //no overlap
00033         return false;
00034 }