stage.set_axis(8)
stage.create_grid_overlay(1, "black")
hat = codesters.Sprite("fleecehat", 5, -6)
hat.turn_right(75)
hat.set_size(.5)
# flake1 = codesters.Sprite("snowflake1", 5, 0)
# flake1.set_size(.5)
# flake2 = codesters.Sprite("snowflake2", 0, 6)
# flake2.set_size(.5)
# flake3 = codesters.Sprite("snowflake3", -7, 2)
# flake3.set_size(.5)
# sweater = codesters.Sprite("sweater", -7, -4)
# sweater.turn_left(80)
# sweater.set_size(.5)
stage.set_background("winter")
sprite = codesters.Sprite("snowman")
sprite.set_size(.5)
sprite.pen_down()
sprite.glide_to(5, -6)
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[0][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()
-
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)