PASO 14: En este momento nuestro número aleatorio unicamente puede ser un número entre 1 y 10, así que nuestras rocas son realmente pequeñas.

  • Encuentra el comando .randint().
  • Cambia sus parámetros a (50, 300).

Ahora nuestras rocas tendrán una altura aleatoria entre 50 y 300 píxeles.

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

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)
  • Run Code
  • Enviar Trabajo
  • Actividad Siguiente
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)