stage.set_background("underwater")
diver = codesters.Sprite("scubadiver1", 100, -100)
toothy = codesters.Sprite("shark", -200, -200)
def space_bar():
sprite.jump(5)
sprite.move_right(500)
stage.event_key("space", space_bar)
t = codesters.Teacher()
try:
tval1 = t.find_function('jump')[0][1]
except:
tval1 = "DNE"
try:
tval2 = t.find_function('move_right')[0][1]
except:
tval2 = "DNE"
t1 = TestObjective()
t1.add_success('diver' in tval1 and 'toothy' in tval2, "Great job debugging the program!")
t1.add_failure(tval1 == "DNE" or tval2 == "DNE", "Oops! Did you delete one of the commands?")
t1.add_failure('toothy' in tval1 or 'diver' in tval2, "Make sure you change the program so that toothy moves right and diver jumps!")
t1.add_failure('diver' not in tval1, "Put diver's name in front of the jump command to make him jump!")
t1.add_failure('toothy' not in tval2, "Put toothy's name in front of the move right command to make him move right!")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
提交作品
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)