# Program variables (DON'T DELETE!!!)
block_speed = -6 # controls how fast the pipes move across the stage
block_gap = 200 # controls the space between the top and bottom of each pipe
block_interval = 1 # controls how often a new pipe appears
gravity = 8 # controls how fast the sprite falls
flappiness = 5 # controls how much the sprite moves up
# Store and display score
score = 0
score_text = codesters.Text("Score: " + str(score), 100, 200, "yellow")
########################################################################
# ADD CODE BELOW THIS LINE #
########################################################################
stage.set_background("space")
stage.disable_all_walls()
sprite = codesters.Sprite("dinosaur")
sprite.set_size(0.4)
sprite.set_say_color("yellow")
sprite.say("TAP THE SPACE BAR TO GUIDE ME THROUGH THE BLOCKS!", 3)
sprite.go_to(-200, 0)
stage.set_gravity(gravity)
def space_bar():
sprite.jump(flappiness)
stage.event_key("space", space_bar)
t = codesters.Teacher()
defs = t.find_block("def")
interval_handlers = t.find_function("event_interval")
try:
tval1 = defs[1][1].lower().replace(' ','')
except:
tval1 = "DNE"
try:
tval2 = interval_handlers[0][1].lower().replace(' ','')
except:
tval2 = "DNE"
t1 = TestObjective()
t1.add_success('definterval()' in tval1, "Great Job!")
t1.add_failure(tval1 == "DNE", "Did you add an Interval Event to the program?")
t1.add_failure(tval1 != "DNE" and 'definterval()' not in tval1, "Are you sure you added an interval event?")
t2 = TestObjective()
t2.add_success(',block_interval)' in tval2, "Great job!")
t2.add_failure(tval2 == "DNE", "Oops, did you delete the event handler for the interval event??")
t2.add_failure(tval2 != "DNE" and ',block_interval)' not in tval2, "Did you change the frequency of the interval event from 2 to the variable block_interval?")
tester = TestManager()
tester.add_test_list([t1, t2])
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)