PREVIEW: Before we get started making our very first program, let's look at an example.

  • Click Run to see an example of the program you will create today.
  • This program has a background image and two sprites or characters that move.
  • Click Submit and Next at the end of every activity to continue.

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
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)