STEP 13: Nice! Let's make our ball bounce up and down as well.

  • Still in and drag in Set y Speed to the bottom of your code editor.
  • Change the name in front of .set_y_speed(5) from sprite to ball.
  • Click Run. You should now see your soccer player bounce diagonally back and forth.
  • When you're ready, click Submit and Next to move on.

microbit = codesters.Microbit() microbit.show_string("hello") stage.set_background("soccerfield") sprite = codesters.Sprite("athlete2") sprite.move_down(150) def button_a(): sprite.move_left(50) microbit.event_button_a(button_a) def button_b(): sprite.move_right(50) microbit.event_button_b(button_b) ball = codesters.Sprite("soccerball") ball.set_x_speed(5)