stage.set_background("schoolhallway")
sprite = codesters.Sprite("person8")
stage.set_gravity(4)
stage.disable_floor()
sprite.set_gravity_off()
sprite.go_to(0, -220)
score = 0
score_board = codesters.Display(score)
my_info = ["cellphone", "address", "birthdate"]
def left_key():
sprite.move_left(20)
# add other actions...
stage.event_key("left", left_key)
def right_key():
sprite.move_right(20)
# add other actions...
stage.event_key("right", right_key)
def interval():
x = random.randint(-230, 230)
info_img = random.choice(my_info)
# sprite = codesters.Sprite("image", x, y)
info = codesters.Sprite(info_img, x, 275)
# add any other actions...
stage.event_interval(interval, 3)
t = codesters.Teacher()
try:
tval1 = t.find_block('def')[3][1]
tval1_line = t.find_block('def')[3][0]
tval1a = t.get_indent_at_line(tval1_line)
except:
tval1 = "DNE"
tval1_line = "DNE"
tval1a ="DNE"
try:
tval2 = t.find_text('global')[0][1]
line = t.find_text('global')[0][0]
tval3 = t.get_indent_at_line(line)
except:
tval2 = "DNE"
line = "DNE"
tval3 = "DNE"
t1 = TestObjective()
t1.add_success('collision' in tval1 and tval1a == 0, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add a Collision Event to your program?")
t1.add_failure('collision' not in tval1, "Did you add a Collision Event to your program?")
t1.add_failure(tval1a > 0, "Make sure your Collision Event is outside your Interval Event and not indented at all!")
t2 = TestObjective()
t2.add_success('score' in tval2 and tval3 == 4, "Great job!")
t2.add_failure(tval2 == "DNE", "Did you add a Global Variable to your Collision Event?")
t2.add_failure('score' not in tval2, "Did you change the name of the variable to score?")
t2.add_failure(tval3 < 4, "Make sure your Global Variable is indented inside your Collision Event!")
t2.add_failure(tval3 > 4, "Make sure you indent your Global Variable only 4 spaces inside your Collision Event!")
tester = TestManager()
tester.add_test_list([t1, t2])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Enviar Trabajo
-
Actividad Siguiente
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)