stage.set_background("city")
sprite = codesters.Sprite("bike")
sprite.set_size(0.5)
sprite.go_to(-200, 0)
stage.set_gravity(10)
stage.disable_all_walls()
def space_bar():
sprite.jump(5)
# add other actions...
stage.event_key("space", space_bar)
def interval():
# add any other actions...
top_height = random.randint(1, 10)
# sprite = codesters.Rectangle(x, y, width, height, "color")
top_block = codesters.Rectangle(0, 0, 100, 50, "blue")
stage.event_interval(interval, 2)
t = codesters.Teacher()
try:
params = t.get_parameters_for_function('Rectangle')
ln_params = t.find_text("top_block")
tval1 = t.get_indent_at_line(ln_params[0][0])
tval2 = params[0][3]
except:
params = "DNE"
tval1 = "DNE"
tval2 = "DNE"
# print params
# print tval2, tval1
t1 = TestObjective()
t1.add_success(tval2 == "top_height" and tval1 == 4, "Great job!")
t1.add_failure(tval2 == 50, "Did you change the rectangle's height to top_height?")
t1.add_failure(tval2 != "top_height", "Did you use the variable top_height for the rectangle's height?")
t1.add_failure(tval1 != 4, "Did you unindent your rectangle? It needs to be indented four spaces.")
# ds1 = codesters.Display(tval2)
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()