# sprite = codesters.Rectangle(x, y, width, height, "color")
start = codesters.Rectangle(0, -250, 500, 50, "red")
# sprite = codesters.Rectangle(x, y, width, height, "color")
finish = codesters.Rectangle(0, 250, 500, 50, "green")
my_list = [-150, -50, 50, 150]
for value in my_list:
pass # delete after adding indented code
# add code here
# sprite = codesters.Rectangle(x, y, width, height, "color")
sprite = codesters.Rectangle(0, value, 500, 50, "gray")
# sprite = codesters.Sprite("image", x, y)
sprite = codesters.Sprite("turtle1", 0, -240)
sprite.set_size(.2)
sprite.turn_left(90)
def interval():
my_var = random.choice(my_list)
if my_var == -150 or my_var == 50:
pass # delete after adding indented code
# add your code here
sprite = codesters.Sprite("car1", -400, my_var)
sprite.turn_right(90)
sprite.set_size(0.5)
sprite.set_x_speed(2)
if my_var == -50 or my_var == 150:
pass # delete after adding indented code
# add your code here
sprite = codesters.Sprite("car2", 400, my_var)
sprite.turn_left(90)
sprite.set_size(0.5)
sprite.set_x_speed(-2)
stage.event_interval(interval, 0.5)
stage.disable_all_walls()
t = codesters.Teacher()
functions = t.find_block("def")
try:
tval0 = functions[1][1].lower().replace(' ','')
tval0_indent = t.get_indent_at_line(functions[1][0])
except:
tval0 = "DNE"
tval0_indent = "DNE"
try:
tval1 = functions[2][1].lower().replace(' ','')
tval1_indent = t.get_indent_at_line(functions[2][0])
except:
tval1 = "DNE"
tval1_indent = "DNE"
try:
tval2 = functions[3][1].lower().replace(' ','')
tval2_indent = t.get_indent_at_line(functions[3][0])
except:
tval2 = "DNE"
tval2_indent = "DNE"
try:
tval3 = functions[4][1].lower().replace(' ','')
tval3_indent = t.get_indent_at_line(functions[4][0])
except:
tval3 = "DNE"
tval3_indent = "DNE"
t0 = TestObjective()
t0.add_success('defup_key():' in tval0 and tval0_indent == 0, "Great job!")
t0.add_failure(tval0 == "DNE", "Did you add Up Key to the bottom of the program?")
t0.add_failure(tval0 != "DNE" and tval0_indent != 0, "Make sure Up Key is not indented!")
t0.add_failure(tval0 != "DNE" and 'defup_key():' not in tval0, "Are you sure you added the Up Key event?")
t1 = TestObjective()
t1.add_success('defdown_key():' in tval1 and tval1_indent == 0, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add Down Key to the bottom of the program?")
t1.add_failure(tval1 != "DNE" and tval1_indent != 0, "Make sure Down Key is not indented!")
t1.add_failure(tval1 != "DNE" and 'defdown_key():' not in tval1, "Are you sure you added the Down Key event?")
t2 = TestObjective()
t2.add_success('defleft_key():' in tval2 and tval2_indent == 0, "Great job!")
t2.add_failure(tval2 == "DNE", "Did you add Left Key to the bottom of the program?")
t2.add_failure(tval2 != "DNE" and tval2_indent != 0, "Make sure Left Key is not indented!")
t2.add_failure(tval2 != "DNE" and 'defleft_key():' not in tval2, "Are you sure you added the Left Key event?")
t3 = TestObjective()
t3.add_success('defright_key():' in tval3 and tval3_indent == 0, "Great job!")
t3.add_failure(tval3 == "DNE", "Did you add Right Key to the bottom of the program?")
t3.add_failure(tval3 != "DNE" and tval3_indent != 0, "Make sure Right Key is not indented!")
t3.add_failure(tval3 != "DNE" and 'defright_key():' not in tval3, "Are you sure you added the Right Key event?")
tester = TestManager()
tester.add_test_list([t0, t1, t2, t3])
tester.run_tests()
tester.display_first_feedback()