STEP 13: Let's give our garbage sprite a 25% chance of appearing.

  • Drag another if statement inside the interval event, but outside the other if statements.
  • Test if rand_chance is less than or equal to <= 25. With numbers 1 - 25, garbage has a 25% of appearing.
  • Drag a Sprite at Position inside the new if statement. It should be indented 12 spaces.
  • Name this sprite new_object. Change it's image to "garbage" and position it at (rand_x, 260).

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

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)