预览:在我们开始制作我们的第一个程序之前,让我们看一个例子。

  • 点击运行以查看您今天将创建的程序的示例。
  • 这个程序有一个背景图像和两个移动的精灵或角色。
  • 点击提交接下来每个活动结束时继续。

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

stage.set_background("schoolentrance") stage.wait(3) stage.set_background("schoolhallway") stage.wait(2) stage.create_grid_overlay(50, "grey") stage.set_background_color("azure") michael = codesters.Sprite("person1") emma = codesters.Sprite("person2") michael.set_size(.5) emma.set_size(.5) michael_x = random.randint(-230,230) michael_y = random.randint(-230,230) michael.go_to(michael_x, michael_y) emma_x = random.randint(-230,230) emma_y = random.randint(-230,230) emma.go_to(emma_x, emma_y) delta_x = michael_x-emma_x delta_y = michael_y-michael_y distance = math.sqrt((delta_x**2)+(delta_y**2)) end_text = codesters.Text(" ", 0, 100) if distance <= 200: end_text.set_text("We need some masks, STAT!") stage.wait(1) emma.load_image("person1_masked") michael.load_image("person2_masked") else: end_text.set_text("Great job social distancing!") michael.say("Social distancing high five!") emma.say("Social distancing high five!")
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)