stage.create_grid_overlay(50, 'greenyellow')
size = .3
planet = codesters.Sprite("mars", -200, -200)
planet.set_size(.4)
planet.collision_off()
stop1 = codesters.Sprite("codester", -100, -100)
stop1.set_size(size)
stage.set_background("space")
sprite = codesters.Sprite("ufo")
sprite.set_size(0.4)
sprite.go_to(-200, -200)
t = codesters.Teacher()
glides = t.get_parameters_for_function('glide_to')
try:
tval3 = t.find_function("pen_down")[0][1]
except:
tval3 = "DNE"
try:
tval1 = int(glides[0][0])
except:
tval1 = "DNE"
try:
tval2 = int(glides[0][1])
except:
tval2 = "DNE"
try:
tval4 = sprite.get_size()
except:
tval4 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == -100, "Great job!")
t1.add_failure(tval1 == "DNE", "There's the Codester! Now add a Glide To command.")
t1.add_failure(tval1 > 250 or tval1 < -250, "Oops! You moved your sprite off the stage!")
t1.add_failure(tval4 > 1 or tval4 <0, "Oops! Did you accidentally change the size of your sprite?")
t1.add_creative(tval1 != -100 and tval1 != "DNE" and tval1 >=-250 and tval1<=250, "That's a good place for your sprite, also!")
t2 = TestObjective()
t2.add_success(tval2 == -100, "Great job!")
t2.add_failure(tval2 == "DNE", "Did you add a Glide To command?")
t2.add_failure(tval2 == 50, "Did you change the y-coordinate to -100?")
t2.add_failure(tval2 > 250 or tval2 < -250, "Oops! You moved your sprite off the stage!")
t2.add_creative(tval2 != -100 and tval2 != "DNE" and tval2 >=-250 and tval2<=250, "That's a good place for your sprite, also!")
t3 = TestObjective()
t3.add_success('sprite' in tval3 ,"Great Job!")
t3.add_failure(tval3 == "DNE", "Did you add a Pen Down command?")
t3.add_failure('sprite' not in tval3, "Oops! Did you change the name in front of the Pen Down command?")
tester = TestManager()
tester.add_test_list([t3, 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)