identifying collision the gameobject class already provides method rect(that will return rect object representing the objectscurrent rectangle with respect to the drawing surface (essentially the box around the object representing its location on the screenthus we can write collision detection method for the game class using the gameobject generated rects and the rect class colliderect(methoddef _check_for_collision(self)""checks to see if any of the meteors have collided with the starship ""result false for meteor in self meteorsif self starship rect(colliderect(meteor rect())result true break return result note that we have followed the convention here of preceding the method name with an underbar indicating that this method should be considered private to the class it should therefore never be called by anything outside of the game class this convention is defined in pep (python enhancement proposalbut is not enforced by the language we can now use this method in the main while loop of the game to check for collisioncheck to see if meteor has hit the ship if self _check_for_collision()starship_collided true this code snippet also introduces new local variable starship_collided we will initially set this to false and is another condition under which the main game playing while loop will terminateis_running true starship_collided false main game playing loop while is_running and not starship_collidedthus the game playing loop will terminate if the user selects to quit or if the starship collides with meteor