STEP 5: Now that we've stored the sprite's rotation amount in the rotation variable, it's time to rotate more!

  • If you click the Console button, you can see the current rotation printed! Click again to close the console.
  • Add Set Rotation indented inside the left_key() event.
  • Change 45 to rotation+3. Run your code and press the left arrow key. You spin left!

When you press the left key, the code checks the current rotation of the hedgehog, then adds 3.

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("moon") sprite = codesters.Sprite("hedgehog", 0, -210) score = 0 #my_display = codesters.Display(my_var, x, y) score_display = codesters.Display(score, -210, -210) time = 60 #my_display = codesters.Display(my_var, x, y) time_display = codesters.Display(time, 210, -210) def left_key(): rotation = sprite.get_rotation() print(rotation) # add other actions... stage.event_key("left", left_key)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)