STEP 12: Okay, something happened when the player and ball collided but not what we want. Let's fix the result!

  • Delete all of the code indented within head_ball().
  • Click on LOGIC. Go to and drag in Docstring so that it's indented on the first line of head_ball().Edit it to describe the function.
  • In GRAPHICS and , drag Get y Speed in head_ball(). Change sprite to hit_sprite.

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, -180) player.set_size(0.75) 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 head_ball(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() player.event_collision(head_ball) main()