STEP 7: This game counts down and constantly creates stars. We'll use one event to do both those things.

  • From add Interval Event to the bottom of the program. Intervals repeat every 2 seconds!
  • In LOGIC from drag out Global Variable. Add it indented inside the interval event.
  • Change my_var to time. This will allow us to change the value of time inside the event.
  • Find and delete ····sprite.turn_left(15)¬. Click Next to keep adding code to the interval event!

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) sprite.set_rotation(rotation+3) # add other actions... stage.event_key("left", left_key) def right_key(): rotation = sprite.get_rotation() print(rotation) sprite.set_rotation(rotation-3) # add other actions... stage.event_key( "right", right_key)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)