Activity: Bigger Rocks
I'M FINISHED WITH HOUR OF CODE!
img

STEP 14: Right now our random number can only be a number between 1 and 10, so our rocks are really short.

  • Find the .randint() command.
  • Change its parameters to (50, 300).

Now our rocks will have a random height between 50 and 300 pixels.

stage.set_background("space") sprite = codesters.Sprite("spaceship") sprite.set_size(0.5) sprite.go_to(-200, 0) stage.set_gravity(10) stage.disable_all_walls() def space_bar(): sprite.jump(5) # add other actions... stage.event_key("space", space_bar) def interval(): top_height = random.randint(1,10) # sprite = codesters.Sprite("image", x, y) top_rock = codesters.Sprite("asteroid", 0, 0) top_rock.set_height(top_height) # add any other actions... stage.event_interval(interval, 2)
Support