让我们设置一个记分板!

  • 点击 ,将 Integer Variable 拖动到程序中所有事件的上方。
  • 将变量命名为 points ,将值更改为 0
  • 中,将 Variable Display 拖动到程序中整数变量的正下方。
  • 将展示命名为 score_board。将变量更改为 points,并将位置更改为 (-209, -209)

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

stage.set_background("moon") sprite = codesters.Sprite("hedgehog") sprite.go_to(0, -210) def left(): sprite.turn_left(20) stage.event_left_key(left) def right(): sprite.turn_right(20) stage.event_right_key(right) def up(): sprite.move_forward(600) stage.wait(1) sprite.go_to(0, -210) stage.event_up_key(up) def interval(): rand_x = random.randint(-250, 250) rand_y = random.randint(-100, 250) goal_star = codesters.Star(rand_x, rand_y, 5, 15, "yellow") # add any other actions... stage.event_interval(interval, 2) def collision(sprite, hit_sprite): hit_sprite.hide() # add any other actions... sprite.event_collision(collision)
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)