half-window length beyond the edge of the window boundsleftedge camerax winwidth boundstopedge cameray winheight boundsrect pygame rect(boundsleftedgeboundstopedgewinwidth winheight objrect pygame rect(obj[' ']obj[' ']obj['width']obj['height'] return not boundsrect colliderect(objrect if __name__ ='__main__' main(the usual setup code squirrel eat squirrel ( katamari damacy clone by al sweigart al@inventwithpython com creative commons by-nc-sa us import randomsystimemathpygame from pygame locals import fps frames per second to update the screen winwidth width of the program' windowin pixels winheight height in pixels half_winwidth int(winwidth half_winheight int(winheight grasscolor ( white ( red ( the start of the program assigns several constant variables this program frequently makes use of the half length of the width and height of the window so much that the half_winwidth and half_winheight variables store these numbers cameraslack moving the camera how far from the center the squirrel moves before the --camera slack|is described later basicallyit means that the camera will begin following the player squirrel when it moves pixels away from the center of the window moverate bouncerate how fast the player moves how fast the player bounces (large is slower