STEP 11: Let's add the event handler back in for our new collision function.

Event handlers determine when a function should happen to a sprite or the stage.

  • Rename the collision() function to head_ball().
  • Go to and drag Collision Event Handler into the last line of the main function.
  • Change sprite to player and, inside the parentheses, change collision to head_ball.

def set_stage(): """ Sets up the stage for the game """ stage.set_background("soccerfield") stage.disable_floor() def add_player(): """ Adds a player to the stage for the user to control """ player = codesters.Sprite("player1") player.go_to(0, -155) return player def add_ball(): """ Adds a ball to the stage and sets its attributes """ ball = codesters.Sprite("soccerball") ball.set_y_speed(-8) def collision(sprite, hit_sprite): sprite.go_to(0, 0) hit_sprite.hide() # add any other actions... def main(): """ Sets up the program and calls other functions """ set_stage() player = add_player() add_ball() main()