🎮 Turtle Arcade — Target Practice

Your first program in VS Code. Go one step at a time and run it after every step.

Built for the Video Game Design team — and everyone else
Start here

Three minutes of setup

This is your first time writing code in a real editor instead of a web page. VS Code runs exactly what you typed — nothing more, nothing less. That is the whole point, and it is also why the first run usually fails for a small reason. That is normal. Everyone here will hit at least one error today.

  1. Make a folder. On your Desktop, make a new folder called turtle_arcade. Underscore, no spaces.
  2. Open the folder in VS Code. File → Open Folder → pick that folder → Open. Open the folder, not a file.
  3. Install the Python extension. Click the Extensions icon (four squares) on the left, search Python, install the one by Microsoft. If it already says "Installed," skip this.
  4. Pick your Python. Press Ctrl+Shift+P (Mac: Cmd+Shift+P), type Select Interpreter, press Enter, and choose anything starting with Python 3.
  5. Make your file. In the left panel, click the new-file icon next to your folder name. Name it turtle_arcade.py exactly.
Name it right, or nothing works. Do not call your file turtle.py. Python would load your file instead of the real turtle library and give you AttributeError: module 'turtle' has no attribute 'Turtle'. It looks like the library is broken, but it is just the name. Use turtle_arcade.py.
Do this before anything else

✅ Step 0 — prove it works

Type these three lines into turtle_arcade.py and press the ▶ Run button in the top-right corner.

import turtle turtle.forward(150) turtle.done()

A window should open and an arrow should draw a line across it. That is it. If that works, your laptop is ready and everything else today is just more lines.

Nothing happened? Go to the Stuck? tab. Find your error message there before you type anything else. Do not skip ahead — every later step needs this one working.

Once the line draws, delete those three lines and start Level 1 on a clean file.

What you are building

A game someone can actually play

It asks the player their name, draws a target, and then waits. Every time the player clicks, it measures how close they got to the middle and adds up points.

That measuring step is the reason this task exists. A click comes in with an x and a y, you check the distance to the centre, and you turn that distance into points. That is hit detection. Every game you have played does some version of it.

You already know most of this

  • input() and int() — Activity 1.1.2
  • circle() — the Arc Lab
  • fillcolor / begin_fill / end_fill
  • penup, pendown, goto
TURTLE ARCADE Player: JorMi Score: 21

Three rings and a score. Your colours can be whatever you want.

🎯 Scoring rings

RingRadiusColourPoints
Bullseye40gold10
Middle80red5
Outer120white1
Anywhere else——0
Draw the rings biggest first. Each new one covers the middle of the last one, and that is how you get a bullseye instead of three separate circles.

How today is graded

Levels 1 to 4 are the assignment. Finish those and you are done — you will have a working, clickable game. The Stretch tab is extra, for anyone who gets there.

Run your program after every level. Four small errors you catch one at a time are easy. Forty lines of untested code is not.

Level 1 • Required

Open the window

Type this at the top of your empty file. The grey lines starting with # are comments — Python ignores them, so you can skip them if you are short on time.

# Turtle Arcade - your name here import turtle screen = turtle.Screen() screen.title("Turtle Arcade") screen.bgcolor("midnightblue") pen = turtle.Turtle() pen.hideturtle() pen.color("white") pen.penup() pen.goto(0, 250) pen.write("TURTLE ARCADE", align="center", font=("Arial", 28, "bold")) turtle.done()
▶ Run it now. You should get a dark blue window with white text near the top. turtle.done() is what keeps the window open — it always stays the last line of your program. Everything you add goes above it.
Every line is the same shape: object.method(value). pen is the object you made, .write is the action, and what is in the brackets tells it how. That is the sentence you labelled in the review game.
Level 2 • Required

Ask the player who they are

Add these lines above turtle.done().

player = input("Enter your gamertag: ") shots = int(input("How many shots? ")) pen.goto(0, 215) pen.write("Player: " + player + " Shots: " + str(shots), align="center", font=("Arial", 14, "normal"))
▶ Run it now. The window opens, then look at the terminal panel at the bottom of VS Code — that is where the questions appear. Type an answer and press Enter for each one. Your name shows up under the title.
If it looks frozen, it is waiting for you. The program stops at input() until you type in the terminal at the bottom. Click down there first.
Why str(shots)? int() turned the answer into a number, and Python will not glue a number onto text. str() turns it back into text just for writing on screen. Leave it out and you get TypeError — the exact error from the Do Now.
Level 3 • Required

Draw the target

Three filled circles, biggest first. Here is the first ring, complete. Add it above turtle.done().

target = turtle.Turtle() target.hideturtle() target.speed(0) target.penup() # Outer ring - 1 point target.goto(0, -120) target.pendown() target.fillcolor("white") target.begin_fill() target.circle(120) target.end_fill() target.penup()
▶ Run it now. One big white circle in the middle of the screen.

Now copy those seven lines twice more and change only the numbers and colours:

# Middle ring - 5 points target.goto(0, -80) target.pendown() target.fillcolor("red") target.begin_fill() target.circle(80) target.end_fill() target.penup() # Bullseye - 10 points target.goto(0, -40) target.pendown() target.fillcolor("gold") target.begin_fill() target.circle(40) target.end_fill() target.penup()
▶ Run it now. A real target: white, then red, then gold in the middle.
Why goto(0, -120) and not (0, 0)? The centre of a turtle circle sits one radius to the turtle's left. Facing east at (0, -120), left is straight up — so the centre lands on (0, 0). Same rule as the Arc Lab.
Writing nearly the same seven lines three times is annoying. Hold that thought — that annoyance is exactly why functions exist, and you write your first one next.
Level 4 • Required • the payoff

Make it clickable

Everything so far ran once, top to bottom. Now you write a block that waits and runs every time the player clicks.

A function is a named block that waits to be called. def shoot(x, y): creates one named shoot. The x and y get filled in with wherever the player clicked. The last line hands your function to the screen — with no brackets after shoot, because you are handing it over, not running it.

Type this exactly. The indents matter — every line inside shoot is pushed in four spaces.

marker = turtle.Turtle() marker.hideturtle() marker.penup() hud = turtle.Turtle() hud.hideturtle() hud.color("white") hud.penup() hud.goto(0, -260) score = 0 def shoot(x, y): global score marker.goto(x, y) marker.dot(10, "black") distance = marker.distance(0, 0) if distance <= 40: points = 10 elif distance <= 80: points = 5 elif distance <= 120: points = 1 else: points = 0 score = score + points hud.clear() hud.write("Score: " + str(score), align="center", font=("Arial", 16, "bold")) screen.onscreenclick(shoot) turtle.done()
▶ Run it and click the target. A black dot appears where you clicked and the score at the bottom goes up. Hit the gold middle and it jumps by 10. That is the assignment. You built a game.
What global score does: without it, Python makes a brand-new score inside the function every click and throws it away. That line says "use the real one out there."
Turn it in

Finished Levels 1 to 4?

  1. Take a screenshot of your game window with some points on the board.
  2. Go to the Pre-Flight tab, paste your whole program, and run the check.
  3. Submit the screenshot and your turtle_arcade.py file.

Time left over? The Stretch tab adds an arena wall and a shot limit.

Stretch • optional

Only if Levels 1–4 already run

These are extras. Do not start one until your game works and you have saved a copy you are happy with.

Stretch 1

Build an arena wall

Ask the player how many walls, then draw a polygon around the target using the third number in circle() — the one from the Arc Lab.

sides = int(input("How many arena walls (3-8)? ")) arena = turtle.Turtle() arena.hideturtle() arena.speed(0) arena.pensize(4) arena.color("deepskyblue") arena.penup() arena.goto(0, -200) arena.pendown() arena.circle(200, 360, sides)
Put this before the target code, or the wall draws on top of your rings.
Stretch 2

Make the shots run out

You already asked for shots in Level 2. Now use it. Add a counter next to score = 0:

shots_left = shots

Then change your function: add shots_left to the global line, put a guard at the very top, and count down before you write the score.

def shoot(x, y): global score, shots_left if shots_left <= 0: return # ... the rest of your function stays the same ... shots_left = shots_left - 1
return means "stop running this function right now." Without that guard the player could keep firing forever. Every game has a version of it.

Then make the score line show a different message when the shots are gone:

hud.clear() if shots_left > 0: hud.write("Score: " + str(score) + " Shots left: " + str(shots_left), align="center", font=("Arial", 16, "bold")) else: hud.write(player + " finished with " + str(score) + " points!", align="center", font=("Arial", 16, "bold"))
Stretch 3

Your own ideas

  • Let the player pick the bullseye colour with another input().
  • Move the target somewhere new after every hit. Look up import random and random.randint.
  • Two players taking turns, each with their own score.
  • Make a miss flash a message instead of silently scoring 0.
Video Game Design team: the guard clause, the distance check, and the score update are three of the four pieces of every game loop you will build this year. The fourth is drawing a frame, and you have been doing that since Activity 1.1.1.
Stuck?

Find your error message here

Read the last line of the red text in the terminal. That line names the problem. Match it below.

What it saysWhat it meansFix
ModuleNotFoundError: No module named 'turtle' VS Code has no Python selected. Ctrl+Shift+P → "Python: Select Interpreter" → pick Python 3.
AttributeError: module 'turtle' has no attribute 'Turtle' Your file is named turtle.py. Rename it turtle_arcade.py and delete any __pycache__ folder.
SyntaxError: invalid character Curly quotes, from copying out of Docs or a website. Delete the quotes and retype them in VS Code.
IndentationError A line is pushed in when it should not be, or you mixed tabs and spaces. Use 4 spaces for every line inside def shoot, and nothing else.
TypeError: can only concatenate str You joined a number onto text. Wrap the number: str(score), str(shots).
NameError: name '...' is not defined Typo, or you used something before you made it. Check the spelling, and check it appears above the line that uses it.
SyntaxError: unexpected EOF / invalid syntax Usually a missing ) or a missing :. Look at the line above the one Python names. Count your brackets.
The window opens and vanishes The program ended. turtle.done() must be the last line.
Nothing happens, no error It is waiting for your input. Click the terminal at the bottom, type your answer, press Enter.
Clicking does nothing onscreenclick is missing, or has brackets after shoot. It must read screen.onscreenclick(shoot) — no () after shoot — and sit above turtle.done().
Still stuck after two tries? Raise your hand. Say what you typed, what you expected, and what the last red line says. Those three sentences are how programmers ask for help.

✅ Quick self-check

Tick these off as you go. If a level will not run, the answer is almost always on this list.

Before you turn it in

Pre-Flight Check

Paste your whole program below. The check reads your code the way Python does, so comments and text inside quotes do not count.

It checks the pieces are there. It cannot tell you whether the game is fun — run it and play it before you submit.