我们需要记录按向左键和向下键的次数。

  • 点击Python选项卡然后点击 。将两个 Integer Variable 指令拖动到程序中。

变量可以让我们存储信息,具有名称和值。就像这样: name = value

  • 将一个变量的名称更改为 left_count,另一个更改为 down_count
  • 两个值都更改为 0

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

stage.set_background("halfcourt") sprite = codesters.Sprite("player4") sprite.go_to(215, -175) net = codesters.Sprite("basketballnet") net.go_to(215, 175) ball = codesters.Sprite("basketball") x = random.randint(-100, 150) ball.go_to(x, -25) stage.set_gravity(10) stage.set_bounce(.8) ball.set_gravity_off() net.set_gravity_off()
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)