stage.set_background("space")
sprite = codesters.Sprite("spaceship")
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():
top_height = random.randint(1,10)
# sprite = codesters.Sprite("image", x, y)
top_rock = codesters.Sprite("asteroid", 0, 0)
top_rock.set_height(top_height)
# add any other actions...
stage.event_interval(interval, 2)
t = codesters.Teacher()
try:
params = t.get_parameters_for_function('randint')
ln_params = t.find_text("top_height")
tval1 = t.get_indent_at_line(ln_params[0][0])
tval2 = int(params[0][0])
tval2a = int(params[0][1])
except:
params = "DNE"
tval1 = "DNE"
tval2 = "DNE"
tval2a = "DNE"
# print params
# print tval2, tval1, tval2a
t1 = TestObjective()
t1.add_success(tval2 == 50 and tval2a == 300 and tval1 == 4, "Great job!")
t1.add_failure(tval2 == 1, "Did you change the first parameter in randint to 50?")
t1.add_failure(tval2a == 10, "Did you change the second parameter in randint to 300?")
t1.add_failure(tval1 != 4, "Did you unindent your random variable? It needs to be indented four spaces.")
t1.add_creative(tval2 !=1 and tval2 < 50, "Your top block's minimum height is less than 50. Creative choice!")
t1.add_creative(tval2a != 10 and tval2a > 300, "Your top block's maximum possible height is greater than 100. Creative choice!")
# ds1 = codesters.Display(tval2)
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()