CHECK FOR UNDERSTANDING: Here are a few questions for you to check what you've learned!

  • This game is very similar to the one you just made! Click Run and play the game.
  • Use the code in the editor to answer the questions.
  • Answer the questions by clicking on the correct answer.
  • Click Submit and Next to move on.

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("space") stage.disable_all_walls() instructions = codesters.Text("Use <- and -> to avoid the spikes!", 0, 200, "orange") ship = codesters.Sprite("ufo", 0, -225) ship.set_size(.5) stage.wait(2) def left_key(): ship.move_left(20) stage.event_key("left", left_key) def right_key(): ship.move_right(20) stage.event_key("right", right_key) score = 0 spike_interval = 1 spike_speed = -4 spike_gap = 200 def make_spikes(): random_left_length = random.randint(50, 350) left_spike = codesters.TriangleIso(0, 300, 50, random_left_length, "red") left_spike.set_rotation(-90) left_spike.set_left(-250 + .5*random_left_length-25) left_spike.set_y_speed(spike_speed) right_length = 500 - (random_left_length + spike_gap) right_spike = codesters.TriangleIso(0, 300, 50, right_length, "red") right_spike.set_rotation(90) right_spike.set_right(250 - .5*right_length+25) right_spike.set_y_speed(spike_speed) def interval(): global score make_spikes() score += 1 stage.event_interval(interval, spike_interval) def collision(sprite, hit_sprite): ship.set_physics_off() stage.event_interval(None) ship.set_say_color("orange") ship.say("You scored " + str(score) + " points!") ship.event_collision(collision)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)