STEP 15: Great! That will be more of a challenge. Let's add movement controls so we can keep bouncing the ball!

  • In LOGIC and , put Define Function with Parameter between head_ball() and main().
  • Change the function name from my_function() to move_left(). Change the one parameter to sprite.
  • Drag Docstring to the first line of the function and edit it to describe the function.
  • In GRAPHICS, go to and drag Move Left inside move_left().

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): """ Detects collisions between the player and ball """ my_var = hit_sprite.get_y_speed() hit_sprite.set_y_speed(-my_var + 1) my_var = hit_sprite.get_x_speed() hit_sprite.set_x_speed(my_var + 1) def main(): """ Sets up the program and calls other functions """ set_stage() player = add_player() add_ball() player.event_collision(head_ball) main()