AMPLIAR—PASO 1 : Sería bueno si mantuviéramos la puntuación. ¡Agreguemos un marcador a nuestro programa!

  • En LÓGICA, haga clic en y arrastre Integer Variable hasta la parte inferior de su programa.
  • Cambiemos el nombre de nuestra variable. Cambie el nombre a la izquierda del signo = de my_var a score .
  • Luego, cambie el número a la derecha del signo = de 25 a 0 . (¡No deberíamos simplemente darle a nuestro jugador 25 puntos!)

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

stage.set_background("moon") sprite = codesters.Sprite("alien1") sprite.go_to(-175, -150) net = codesters.Sprite("basketballnet") net.go_to(215, 175) instructions = codesters.Text("Click on the sprite to shoot the basketball. Hit the basket to score a point!") instructions.go_to(0, 50) instructions.set_color("white") stage.set_gravity(10) sprite.set_gravity_off() def click(sprite): ball = codesters.Sprite("basketball") ball.go_to(-175, -125) ball.set_x_speed(10) ball.set_y_speed(10) # add other actions... sprite.event_click(click) stage.disable_right_wall() def collision(net, hit_sprite): my_var = hit_sprite.get_image_name() if my_var == "basketball": sprite.say("Score!") hit_sprite.hide() # add any other actions... net.event_collision(collision)
  • Run Code
  • Enviar Trabajo
  • Actividad Siguiente
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)