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)
sprite.pen_down()
sprite.glide_to(-100, -100)
def collision(sprite, hit_sprite):
sprite.go_to(0,0)
hit_sprite.hide()
# add any other actions...
sprite.event_collision(collision)
t = codesters.Teacher()
turns = t.find_function('turn_left')
gotos = t.find_function('go_to')
hides = t.find_function('hide')
try:
tval1 = turns[0][0]
except:
tval1 = "DNE"
try:
tval4 = gotos[1][0]
except:
tval4 = "DNE"
try:
tval2 = hides[0][1]
tval3 = t.get_indent_at_line(hides[0][0])
except:
tval2 = "DNE"
tval3 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == "DNE" and tval4 == "DNE", "Great job!")
t1.add_failure(tval1 != "DNE", "Did you delete the Turn Left command?")
t1.add_failure(tval4 != "DNE", "Did you delete the Go To command inside the event?")
t2 = TestObjective()
t2.add_success('hit_sprite.' in tval2 and tval3 == 4, "Great job!")
t2.add_failure(tval2 == "DNE", "Oops! Did you delete the Hide command from your Collision event?")
# t2.add_failure('hit_sprite.' not in tval2, "Did you change the name in front of .hide() to hit_sprite?")
t2.add_failure(tval3 < 4, "Make sure your Hide command is indented 4 spaces inside the Collision event!")
t2.add_failure(tval3 > 4, "Oops! Make sure your Hide command is indented only 4 spaces inside the Collision event!")
tester = TestManager()
tester.add_test_list([t1, t2])
tester.run_tests()
tester.display_first_feedback()