stage.set_background("moon")
sprite = codesters.Sprite("astronaut1")
sprite.go_to(-125, -150)
glorp = codesters.Sprite("alien1")
glorp.go_to(100, -125)
rock = codesters.Sprite("asteroid")
rock.go_to(100, 75)
sprite.say("What do planets read?")
sprite.set_say_color("white")
def click(sprite):
sprite.say("Comet books!")
sprite.turn_left(360)
# add other actions...
sprite.event_click(click)
def space_bar():
rock.set_x_speed(5)
# add other actions...
stage.event_key("space", space_bar)
t = codesters.Teacher()
try:
params = t.find_function('set_y_speed')
tval1a = params[0][1]
tval1b = t.get_indent_at_line(params[0][0])
except:
tval1a = "DNE"
tval1b = "DNE"
t1 = TestObjective()
t1.add_success("rock" in tval1a and tval1b == 4, "Great job!")
t1.add_failure(tval1a == "DNE" or tval1b == "DNE", "Did you add a Set y Speed command to the Space Bar event?")
t1.add_failure(tval1b != 4, "Make sure your Set y Speed command is indented four spaces inside the Space Bar event.")
t1.add_failure('sprite' in tval1a, "Did you change the name in front of Set y Speed to rock?")
t2 = TestObjective()
t2.add_success("2" in tval1a, "Great job!")
t2.add_failure("5" in tval1a, "Did you change the number in the Set Speed command?")
t2.add_failure(tval1a == "DNE", "Did you add a Set y Speed command?")
tester = TestManager()
tester.add_test_list([t1, t2])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)