if movedown is set to true (and the bottom of the player' square isn' below the bottom edge of the window)then line moves the player' square down by adding movespeed to the player' current top attribute lines to do the same thing for the other three directions the colliderect(method check if the player has intersected with any food squares for food in foods[:]if player colliderect(food)foods remove(foodin the previous collision detection programthe dorectsoverlap(function to check if one rectangle had collided with another that function was included in this book so you could understand how the code behind collision detection works in this programyou can use the collision detection function that comes with pygame the colliderect(method for pygame rect objects is passed another pygame rect object as an argument and returns true if the two rectangles collide and false if they do not mainclock tick( the rest of the code is similar to the code in the input and collision detection programs summary this introduced the concept of collision detectionwhich is in many graphical games detecting collisions between two rectangles is easycheck if the four corners of either rectangle are within the other rectangle this is such common thing to check for that pygame provides its own collision detection method named colliderect(for pygame rect objects the first several games in this book were text-based the program output was text printed to the screen and the input was text typed by the user on the keyboard but graphical programs can accept keyboard and mouse inputs furthermorethese programs can respond to single keystrokes when the user pushes down or lets up single key the user doesn' have to type in an entire response and press enter this allows for immediate feedback and much more interactive games post questions to