microbit = codesters.Microbit()
microbit.show_string("hello")
stage.set_background("soccerfield")
sprite = codesters.Sprite("athlete2")
sprite.move_down(150)
def button_a():
sprite.move_left(50)
microbit.event_button_a(button_a)
def button_b():
sprite.move_right(50)
microbit.event_button_b(button_b)
ball = codesters.Sprite("soccerball")
ball.set_x_speed(5)
ball.set_y_speed(5)
def collision(sprite, hit_sprite):
hit_sprite.set_y_speed(5)
sprite.event_collision(collision)
stage.disable_floor()
t = codesters.Teacher()
try:
tval1 = stage.get_image_name()
except:
tval1 = "DNE"
try:
tval2 = ball.get_image_name()
except:
tval2 = "DNE"
try:
tval3 = sprite.get_image_name()
except:
tval3 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 != "soccerfield", "Great job!")
t1.add_failure(tval1 == "soccerfield", "Did you change your background image?")
t2 = TestObjective()
t2.add_success(tval2 != "soccerball", "Great job!")
t2.add_failure(tval2 == "soccerball", "Did you change your the ball image?")
t3 = TestObjective()
t3.add_success(tval3 != "athlete2", "Great job!")
t3.add_failure(tval3 == "athlete2", "Did you change the sprite image?")
tester = TestManager()
tester.add_test_list([t1, t2, t3])
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)