STEP 11: Let's create a function so that the player and ball can interact!

Codesters are actually special functions! An important difference is that events require event handlers which decide when to call the function.

  • Create blank lines between add_ball() and main(). Go to and drag Collision here.
  • Find the event handler looking like this: sprite.event_collision(collision)¬ Delete the entire line!

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 main(): """ Sets up the program and calls other functions """ set_stage() player = add_player() add_ball() main()