扩展你的程序!

  • 你可以尝试更改精灵、背景或精灵收集的物体。
  • 创建一个计时器可以使你的游戏更具挑战性(提示:参考示例活动中的第42至48行)
  • 尝试随着时间推移,使游戏加速(提示:尝试使用变量来控制间隔事件的速度)
  • 让你的角色发射前说一个短语来捕捉星星。

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) points = 0 score_board = codesters.Display(points, -209, -209) 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() global points points += 1 score_board.update(points) # add any other actions... sprite.event_collision(collision)
  • Run Code
  • 提交作品
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)