预览:这是你今天要做的篮球比赛的一个例子!

  • 点击运行开始游戏并按照舞台上的说明进行操作。
  • 玩游戏后点击提交接下来就自己搭建吧!


点击提交接下来在本课的每个活动之后移动到下一个活动!

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

stage.set_background("halfcourt") sprite = codesters.Sprite("player4", -175, -150) net = codesters.Sprite("basketballnet", 215, 175) instructions = codesters.Text("Click on the sprite to shoot the basketball. Hit the basket to score a point!", 0, 50, "white") stage.set_gravity(10) sprite.set_gravity_off() score = 0 score_display = codesters.Display(score, -200, 150) def click(sprite): ball = codesters.Sprite("basketball", -150, -100) ball.set_x_speed(10) ball.set_y_speed(10) sprite.event_click(click) def collision(net, hit_sprite): global score my_var = hit_sprite.get_name() if my_var == "basketball": hit_sprite.hide() score += 1 score_display.update(score) net.event_collision(collision) stage.disable_right_wall()
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)