target = codesters.Sprite("triangle", 100, 0)
target.set_opacity(.5)
text = codesters.Text('target', 110, 100)
text.set_size(.8)
text.set_opacity(.8)
stage.create_grid_overlay(50, "blue")
sprite = codesters.Sprite("triangle")
sprite.set_speed(1)
try:
tval1 = sprite.get_x()
except:
tval1 = "DNE"
try:
tval2 = sprite.get_y()
except:
tval2 = "DNE"
try:
tval3 = int(sprite.get_rotation())
except:
tval3 = "DNE"
try:
tval4 = sprite.get_flip()
except:
tval4 = "DNE"
if tval1 == 100:
text.set_text(' ')
t1 = TestObjective()
t1.add_success(tval1 == 100, "Great Job!")
t1.add_failure(tval1 == 0, "Did you use Translate x?")
t1.add_failure(tval1 == 50, "Correct. Now change the number in translate x to reach the target.")
t1.add_failure(tval1 > 100, "Oops! Too far. Try lowering the number in your translate x command.")
t1.add_failure(tval1 != 100 and tval1 != 50 and tval1 != 0, "That's not quite the right number.")
t1.add_failure(tval1 == "DNE", "Did you delete your sprite?")
t1.add_failure(tval2 != 0 and tval2 != "DNE", "Make sure you haven't used Translate y instead of Translate x.")
t2 = TestObjective()
t2.add_success(tval3 == 0 or tval3 == "DNE", "Great job!")
t2.add_failure(tval3 > 0 and tval4 == False, "Oops! Did you use a rotation command?")
t3 = TestObjective()
t3.add_success(tval4 == False, "Great job!")
t3.add_failure(tval4 == "DNE", "Oops! Did you delete your triangle sprite?")
t3.add_failure(tval4 == True, "Oops! Did you you a reflection command?")
tester = TestManager()
tester.display_graphics = False
tester.add_test_list([t3, t2, t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)