dorectsoverlap(is passed two pygame rect objects the function will return true if they do and false if they don' there is simple rule to follow to determine if rectangles collide look at each of the four corners on both rectangles if at least one of these eight corners is inside the other rectanglethen you know that the two rectangles have collided you can use this fact to determine if dorectsoverlap(returns true or false for ab in [(rect rect )(rect rect )]check if ' corners are inside if ((ispointinsiderect( lefta topb)or (ispointinsiderect( lefta bottomb)or (ispointinsiderect( righta topb)or (ispointinsiderect( righta bottomb)))return true lines to check if one rectangle' corners are inside another later you will create function called ispointinsiderect(that returns true if the xy coordinates of the point are inside the rectangle call this function for each of the eight cornersand if any of these calls return truethe or operators will make the entire condition true the parameters for dorectsoverlap(are rect and rect first check if rect ' corners are inside rect then check if rect ' corners are in rect you don' need to repeat the code that checks all four corners for both rect and rect insteaduse and on lines to the for loop on line uses multiple assignment on the first iterationa is set to rect and is set to rect on the second iteration through the loopit is the oppositea is set to rect and is set to rect return false line never returns truethen none of the eight corners checked are in the other rectangle in that casethe rectangles didn' collide and line returns false determining if point is inside rectangle def ispointinsiderect(xyrect) if ( rect leftand ( rect topand ( rect bottom) return true the ispointinsiderect(function is called from dorectsoverlap(the ispointinsiderect(function will return true if the xy coordinates passed are located inside the pygame rect object passed as the third parameter otherwisethis function returns false