target = codesters.Sprite("triangle")
target.set_opacity(.5)
target.reflect_y_axis()
text = codesters.Text('target', -50, -25)
text.set_size(.8)
text.set_opacity(.8)
stage.set_background("grid")
sprite = codesters.Sprite("triangle")
sprite.set_speed(1)
t = codesters.Teacher()
reflections = t.find_text('reflect')
try:
tval1 = t.find_text('reflect')[0][1]
except:
tval1 = "DNE"
try:
tval2 = t.find_text('rotate')
except:
tval2 = "DNE"
try:
tval3 = t.find_text('translate')
except:
tval3 = "DNE"
if 'y_axis' in tval1 and len(reflections) == 1:
text.set_text(' ')
t1 = TestObjective()
t1.add_success('y_axis' in tval1 and len(reflections) == 1, "Great job!")
t1.add_failure(tval1 == "DNE", "Try adding a reflection command to map your sprite to the target triangle!")
t1.add_failure('x_axis' in tval1 and len(reflections) == 1, "Oops! That's not the right way. Try the other type of reflection!")
t1.add_failure(len(reflections) > 1, "Make sure you're using only 1 reflection on this mission.")
t2 = TestObjective()
t2.add_failure(tval2 != [], "Oops! Did you use a Rotate command by mistake?")
t2.add_failure(tval3 != [], "Oops! Did you use a translate command by mistake?")
tester = TestManager()
tester.display_graphics = False
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)