stage.set_background("halfcourt")
sprite = codesters.Sprite("player4")
sprite.go_to(215, -175)
net = codesters.Sprite("basketballnet")
net.go_to(215, 175)
ball = codesters.Sprite("basketball")
x = random.randint(-100, 150)
ball.go_to(x, -25)
stage.set_gravity(10)
stage.set_bounce(.8)
ball.set_gravity_off()
net.set_gravity_off()
left_count = 0
down_count = 0
def left_key():
ball.move_left(10)
# add other actions...
stage.event_key("left", left_key)
t = codesters.Teacher()
try:
tval1 = t.find_text('global')[0][1]
tval2 = t.find_text('global')[0][0]
tval2 = t.get_indent_at_line(tval2)
except:
tval1 = "DNE"
tval2 = "DNE"
t1 = TestObjective()
t1.add_success('left_count' in tval1 and tval2 == 4, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add a Global Variable to your Left Key event?")
t1.add_failure('left_count' not in tval1, "Make sure you change the name of the variable after global to left_count.")
t1.add_failure(tval2 < 4, "Make sure you indent all commands inside your Left KEy event by 4 spaces.")
t1.add_failure(tval2 > 4 , "Oops! You indented too far. Make sure your Global keyword is only 4 spaces in your event.")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()