Rocket Launch Project Guide Grade 8 Python • CodeSkulptor3
Rocket Launch Lab
py3.codeskulptor.org
Name: _______________________________
Date: _______________
Mission Briefing
In this project, you will code an animated space launch in CodeSkulptor3 using Python. You will layer simple shapes, pick colors, and use a timer to make your rocket blast off across the canvas!
How the 400 × 400 Canvas Works
(0, 0) (400, 0) (0, 400) (400, 400)
(200, 200)
Top-Left is (0, 0): Unlike math class, y gets bigger as you go down !
x-axis (Left to Right): Goes from 0 to 400.
y-axis (Top to Bottom): Goes from 0 to 400.
Moving Up: To make a rocket fly up , we subtract from its y value!
Step 1
Create the Frame & Night Sky
Open py3.codeskulptor.org , delete the starter code, and type this code to create a 400×400 window with a dark space background:
import simplegui
def draw(canvas):
# Background sky (dark navy)
canvas.draw_polygon([(0, 0), (400, 0), (400, 400), (0, 400)], 1, "MidnightBlue", "MidnightBlue")
frame = simplegui.create_frame("Rocket Launch", 400, 400)
frame.set_draw_handler(draw)
frame.start()
Checkpoint 1: Click the Run (▶) button. You should see a 400×400 dark blue square!
Step 2
Add Stars, a Planet, and the Ground
Inside draw(canvas), shapes are layered in order—first drawn goes in the back! Add these lines inside your draw function:
# Distant planet and stars
canvas.draw\_circle((320, 80), 35, 2, "Cyan", "Teal")
canvas.draw\_circle((70, 60), 3, 1, "White", "White")
canvas.draw\_circle((160, 110), 2, 1, "Yellow", "Yellow")
canvas.draw\_circle((240, 45), 3, 1, "White", "White")
# Launchpad ground
canvas.draw\_polygon(\[(0, 350), (400, 350), (400, 400), (0, 400)\], 1, "SlateGray", "DimGray")
Step 3
Build Your Rocket Using a Position Variable
Instead of typing fixed numbers for the rocket's height, we will use a variable called rocket_y. At the very top of your code (below import simplegui), add:
rocket_y = 260
Now add the rocket shapes at the bottom of your draw(canvas) function so every part moves together when rocket_y changes:
# Rocket body, nose cone, and window
canvas.draw\_polygon(\[(180, rocket\_y), (220, rocket\_y), (220, rocket\_y + 80), (180, rocket\_y + 80)\], 2, "Silver", "White")
canvas.draw\_polygon(\[(180, rocket\_y), (200, rocket\_y - 40), (220, rocket\_y)\], 2, "OrangeRed", "Orange")
canvas.draw\_circle((200, rocket\_y + 30), 10, 2, "SlateGray", "DeepSkyBlue")
Plan Your Scene (Sketch & Coordinates)
Sketch where your planet, stars, and rocket sit on the 400×400 canvas. Label at least 3 coordinates!
Pro Tip: draw_circle(center, radius, line_width, line_color, fill_color) takes 5 arguments!
Step 4
Animate Liftoff with a Timer!
Animation happens when a timer updates our rocket_y variable many times per second. Add a timer handler function above frame = ...:
def tick():
global rocket_y
rocket_y = rocket_y - 3 # Move rocket UP by 3 pixels
if rocket_y < -100: # If rocket flies off top of screen...
rocket_y = 320 # ...reset it back to the launchpad!
Next, add an exhaust flame inside draw(canvas) right below the rocket body:
# Exhaust flame
canvas.draw\_polygon(\[(185, rocket\_y + 80), (215, rocket\_y + 80), (200, rocket\_y + 110)\], 1, "Red", "Yellow")
Finally, create and start the timer at the very bottom of your program (50 milliseconds = 20 frames per second):
timer = simplegui.create_timer(50, tick)
timer.start()
Common Bug Check
1. UnboundLocalError? Make sure global rocket_y is the first line inside tick()!
2. Rocket not moving? Check that you wrote timer.start() at the bottom.
3. Flame covering the rocket? Put the flame code before the rocket body if you want it behind the rocket.
Checkpoint 2: Run your code! Your rocket should smoothly lift off, fly past the planet, and loop back to the pad.
Step 5
Customize & Level Up Your Scene
Choose at least two upgrades to make your animation unique:
Tier 1: Starter
• Add rocket fins using draw_polygon.
• Change the sky or planet colors.
• Change the timer speed (50 → 30).
Tier 2: Explorer
• Add a second moving object (like a UFO or shooting star with ufo_x).
• Add a ring around your planet with draw_line.
Tier 3: Commander
• Make the flame flicker by alternating its size each tick!
• Add a countdown text using canvas.draw_text.
Mission Debrief (Exit Reflection)
1. Why did we subtract from rocket_y instead of adding to make the rocket go up?
2. What happens if you change create_timer(50, tick) to create_timer(200, tick)? Why?
3. Describe one custom feature you added (or want to add) and which shape/variable you used:
CodeSkulptor3 • Drawing & Animation
Canvas Animation Slides Grade 8 Python • CodeSkulptor3
Rocket Launch Lab
Use simple shapes, colors, and timers to bring a space scene to life.
py3.codeskulptor.org import simplegui
The 400 × 400 Canvas
(0, 0) (400, 0) (0, 400) (400, 400)
(200, 200)
Origin (0, 0) is at the top-left corner.
x increases from left to right (0 → 400).
y increases going down (0 → 400).
To move a rocket UP, we subtract from y!
Drawing Shapes & Layering
1. Circles (Planets, Stars, Windows)
canvas.draw_circle((320, 80), 35, 2, "Cyan", "Teal")
(center_x, center_y), radius, line_width, line_color, fill_color
2. Polygons (Sky, Ground, Rocket Body, Nose)
canvas.draw_polygon([(180, 260), (200, 220), (220, 260)], 2, "Red", "Orange")
List of corner points [(x1, y1), (x2, y2), ...], line_width, line_color, fill_color
Painter's Rule: Shapes drawn first go in the back!
How Animation Works
1. Variable
Track Position
Store the rocket's height in a variable so it can change.
rocket_y = 260
2. Timer
Update State
Every 50 ms, run tick() to move the rocket up.
rocket_y -= 3
3. Draw Loop
Redraw Frame
CodeSkulptor redraws the canvas 60 times a second!
draw(canvas)
Code Spotlight: Liftoff Timer
def tick():
global rocket_y
rocket_y = rocket_y - 3
if rocket_y < -100:
rocket_y = 320
global rocket_y lets tick() modify the variable created at the top.
Don't forget timer.start() at the bottom of your file!
Your Mission Today
1. Build & Test
Follow Steps 1–4 in your Project Guide to launch your rocket.
2. Customize
Add fins, a UFO, planet rings, or a flickering flame!
3. Debrief
Complete the 3 reflection questions at the end of your guide.
Open py3.codeskulptor.org and begin Step 1!
Rocket Launch Teacher Guide Teacher Facilitation Guide • Grade 8
Rocket Launch Lab
Platform: CodeSkulptor3
py3.codeskulptor.org
Learning Objectives
• Plot shapes accurately on a 400×400 2D canvas where (0, 0) is at the top-left.
• Construct a composite scene using draw_polygon and draw_circle with layering order.
• Animate scene elements by updating a global position variable inside a simplegui timer handler.
50-Minute Pacing Plan
Time
Activity
Teacher Moves
0–10 min
Launch & Coordinates (Slides 1–3)
Demo the inverted y-axis. Ask students which way a rocket moves if y decreases.
10–25 min
Static Scene (Steps 1–3)
Students build sky, planet, ground, and rocket. Circulate to check rocket_y placement and sketch pad.
25–35 min
Timer Animation (Slide 4–5, Step 4)
Pause class briefly to explain global rocket_y and timer.start() before students add the timer.
35–45 min
Customize & Level Up (Step 5)
Encourage Tier 1–3 upgrades (fins, UFO, flickering flame). Pair-debug any syntax errors.
45–50 min
Mission Debrief
Students complete the 3 reflection questions on Page 4 of their Project Guide.
Differentiation & Support
Scaffolds for Beginners
• Provide Step 1–2 as a starter link (CodeSkulptor Save URL) for students who type slowly.
• Have students trace rocket_y values on paper (260 → 257 → 254) to visualize movement.
Extensions for Early Finishers
• Add a second global variable ufo_x moving horizontally across the sky.
• Add canvas.draw_text for a live altitude readout or launch countdown.
Rocket Launch Lab • Teacher Guide (1/2)
Complete Working Solution (Steps 1–4)
import simplegui
rocket_y = 260
def draw(canvas):
# Sky, planet, stars, and ground
canvas.draw_polygon([(0, 0), (400, 0), (400, 400), (0, 400)], 1, "MidnightBlue", "MidnightBlue")
canvas.draw_circle((320, 80), 35, 2, "Cyan", "Teal")
canvas.draw_circle((70, 60), 3, 1, "White", "White")
canvas.draw_circle((160, 110), 2, 1, "Yellow", "Yellow")
canvas.draw_circle((240, 45), 3, 1, "White", "White")
canvas.draw_polygon([(0, 350), (400, 350), (400, 400), (0, 400)], 1, "SlateGray", "DimGray")
# Exhaust flame & rocket
canvas.draw\_polygon(\[(185, rocket\_y + 80), (215, rocket\_y + 80), (200, rocket\_y + 110)\], 1, "Red", "Yellow")
canvas.draw\_polygon(\[(180, rocket\_y), (220, rocket\_y), (220, rocket\_y + 80), (180, rocket\_y + 80)\], 2, "Silver", "White")
canvas.draw\_polygon(\[(180, rocket\_y), (200, rocket\_y - 40), (220, rocket\_y)\], 2, "OrangeRed", "Orange")
canvas.draw\_circle((200, rocket\_y + 30), 10, 2, "SlateGray", "DeepSkyBlue")
def tick():
global rocket_y
rocket_y = rocket_y - 3
if rocket_y < -100:
rocket_y = 320
frame = simplegui.create_frame("Rocket Launch", 400, 400)
frame.set_draw_handler(draw)
timer = simplegui.create_timer(50, tick)
frame.start()
timer.start()
Quick Troubleshooting Guide
Nothing appears: Check that frame.start() is present and spelled correctly.
SyntaxError on colors: Color names like "MidnightBlue" must be in quotes and have no spaces.
UnboundLocalError in tick(): Student forgot global rocket_y inside tick().
Mission Debrief Answer Key
1. Subtracting from rocket_y: Because (0, 0) is at the top-left of the canvas, smaller y values are higher up on the screen.
2. Changing timer to 200 ms: The timer runs 4× slower (5 times per second instead of 20), so the rocket moves up much more slowly and looks choppier.
3. Custom feature: Answers vary; look for a clear connection between a shape (draw_circle, draw_polygon, etc.) or variable and what it draws/animates.
Rocket Launch Lab • Teacher Guide (2/2)