Step 10: We have just used loops to create the firework. Now, we will use another loop to start each particle moving!

  • From drag out Enumerate. It should be indented once!
  • Change index, value to count, p and change my_list to particle_list.

This code will pick each particle p stored in particle_list and let us do things to it! We will finally be able to set each particle in motion!

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

stage.set_background_color("black") amount = 10 speed = 5 color_list = ["purple", "yellow", "red"] stage.disable_all_walls() def click(): x = stage.click_x() y = stage.click_y() particle_list = [] for color in color_list: for counter in range(amount): sprite = codesters.Circle(x, y, 10, color) particle_list.append(sprite) angle = 0 # add other actions... stage.event_click(click)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)