stage.set_background("underwater")
sprite = codesters.Sprite("fish")
sprite.go_to(-100, -220)
stage.disable_floor()
stage.set_gravity(4)
sprite.set_gravity_off()
def right_key():
sprite.move_right(20)
# add other actions...
stage.event_key("right", right_key)
def left_key():
sprite.move_left(20)
# add other actions...
stage.event_key("left", left_key)
score = 0
t = codesters.Teacher()
params = t.get_parameters_for_function('Display')
names = t.find_text('Display')
try:
tval1 = score_board.get_name()
except:
tval1 = "DNE"
try:
tval2 = names[0][1].split("=")[0].replace(' ', '')
except:
tval2 = 'DNE'
try:
tval3 = int(params[0][2])
except:
tval3 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == "score" and tval2 == 'score_board', "Great job!")
t1.add_failure(tval1 == "DNE" and tval2 == "DNE", "Did you create a display for score?")
t1.add_failure(tval1 == "DNE" and tval2 != "score_board", "Did you change the display name to score_board?")
t1.add_failure(tval1 != "score", "Did you use the correct variable in .Display()?")
t2 = TestObjective()
t2.add_success(tval3 == 200, "Great job!")
t2.add_failure(tval3 == 150, "Did you change the y-coordinate of the display?")
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)