the bouncer is represented by dictionary the dictionary has key named 'rect(whose value is pygame rect objectand key named 'dir(whose value is one of the constant direction variables like we had in last animation programas the bouncer bounces around the windowwe check if it collides with any of the food squares if it doeswe delete that food square so that it will no longer be drawn on the screen this will make it look like the bouncer "eatsthe food squares in the window type the following into new file and save it as collisiondetection py if you get errors after typing this code incompare the code you typed to the book' code with the online diff tool at collisiondetection py import pygamesysrandom from pygame locals import def dorectsoverlap(rect rect ) 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 return false def ispointinsiderect(xyrect) if ( rect leftand ( rect topand ( rect bottom) return true else return false set up pygame pygame init( mainclock pygame time clock( set up the window windowwidth windowheight windowsurface pygame display set_mode((windowwidthwindowheight) pygame display set_caption('collision detection'