← All missions

πŸ‘Ύ Space Invaders

πŸ•ΉοΈ Arcade Game Makers

1) What do I need to do?

🎯 Your mission: Ship and laser

Make a ship turtle at the bottom (y = -170). Write left and right functions that change its x with setx.

Make a hidden laser turtle and a fire function connected to "space".

Write a game_loop that moves the laser up when firing is True, and uses ontimer to repeat.

2) What do I need to know?

Plan the defence

The plan: a hero ship at the bottom moves left and right. Press space to fire a laser upward.

A list of aliens marches side to side. When they reach the edge, they all drop down and turn around.

If a laser hits an alien (distance < 20), the alien vanishes and you score!

It's the same game loop idea as Snake: move, check hits, ontimer again.

🧰 Your toolkit for this mission

Everything you need to know to finish this lesson on your own:

Player moves

Left/right keys slide the ship.

How to write it: Change x with ship.setx(ship.xcor() - 20).

def left():
    ship.setx(ship.xcor() - 20)

Firing

A bullet turtle moves up each timer tick.

How to write it: bullet.sety(bullet.ycor() + 15) inside your timer function.

Hits

Bullet close to an invader = hit.

How to write it: if bullet.distance(invader) < 20: then score and reset.

Many invaders

Keep them in a list and loop through it.

How to write it: for inv in invaders: move and check each.

for inv in invaders:
    inv.sety(inv.ycor() - 1)

Think about it

Look at this code. What happens next, and why? Say it in your own words.

speed = -speed
Watch & explore β–Ά

Power-up: Plan the defence

See it happen

1 / 3
ship.setx(ship.xcor() + 20)
πŸš€ β¬… ➑

The ship slides left and right along the bottom.

3) Run the code & terminal output

Code Lab 🐍Playground β€” experiment freely!
Hero Terminal

Press β–Ά RUN and your program's messages appear here!

Arcade Station
Arcade Station
Your superhero companion

Captain Py

Our next adventure is yours to create.