PASO 13: Vamos a calcular la pendiente real de la recta. Para hacerlo, necesitaremos la subida (cambio entre las coordenadas y) y la carrera (cambio entre las coordenadas x)

  • Haga clic en la pestaña LÓGICA, luego y arrastre Delta X .
  • Cambie el nombre de la variable de delta_x a run .
  • ¡Cambia x2 a netx y x1 a ballx para restar las dos coordenadas x y obtener la carrera!

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

stage.set_axis(100) stage.create_grid_overlay(10, "grey") stage.set_background("soccerfield") ballx = -80 bally = random.randint(-100,100) # sprite = codesters.Sprite("image", x, y) ball = codesters.Sprite("soccerball", ballx, bally) netx = 90 nety = random.randint(-100,100) # sprite = codesters.Sprite("image", x, y) net = codesters.Sprite("soccernet", netx, nety) net.flip_right_left() #sprite = codesters.Line(x-start, y-start, x-end, y-end, "color") line = codesters.Line(ballx, bally, netx, nety, "blue") slopeguess = float(line.ask("What is the slope of this line?")) rise = nety - bally
  • Run Code
  • Enviar Trabajo
  • Actividad Siguiente
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)