STEP 7: Time to make our car obstacles! The cars will appear and move across the stage infinitely.

An Interval Event repeats an action infinitely and we can set the frequency -- how often the event happens!

  • From the toolkit, drag out Interval Event to the bottom of the program.
  • Change the frequency of the interval on this line: stage.event_interval(interval,·2) Change 2 to 0.5!
  • Click Run to see what happens! What action repeats infinitely? We'll change the action in the next activities.

# sprite = codesters.Rectangle(x, y, width, height, "color") start = codesters.Rectangle(0, -250, 500, 50, "red") # sprite = codesters.Rectangle(x, y, width, height, "color") finish = codesters.Rectangle(0, 250, 500, 50, "green") my_list = [-150, -50, 50, 150] for value in my_list: pass # delete after adding indented code # add code here # sprite = codesters.Rectangle(x, y, width, height, "color") sprite = codesters.Rectangle(0, value, 500, 50, "gray") # sprite = codesters.Sprite("image", x, y) sprite = codesters.Sprite("turtle1", 0, -240) sprite.set_size(.2) sprite.turn_left(90)