import turtle
import random
screen = turtle.Screen()
screen.setup(400, 500)
screen.bgcolor('#0a0a40')
pen = turtle.Turtle()
pen.hideturtle()
pen.speed(0)
pen.color('white')
for i in range(30):
star_x = random.randint(-200, 200)
star_y = random.randint(-250, 250)
pen.penup()
pen.goto(star_x, star_y)
pen.dot(3)
rocket_x = 0
rocket_y = -200
for step in range(50):
# Draw a puff of smoke below the rocket
pen.penup()
pen.goto(rocket_x + random.randint(-10, 10), rocket_y - 20)
pen.color('orange')
pen.dot(15)
# Draw the rocket
pen.penup()
pen.goto(rocket_x, rocket_y)
pen.color('silver')
pen.dot(30)
rocket_y = rocket_y + 8
screen.mainloop()
Project 3 — Step 4 of 4
⭐ Step 4 — Smoke trail
➡️ Add a trail of orange smoke puffs behind the rocket.
Inside the same for loop, before drawing the rocket, draw a
small orange dot just below it. Each loop turn leaves
another puff behind, building up a trail.
✏️ What to type
At the top of the for step in range(50): loop, before
the rocket drawing lines, add:
pen.penup()
pen.goto(rocket_x + random.randint(-10, 10), rocket_y - 20)
pen.color('orange')
pen.dot(15)
(Keep it pushed in by 4 spaces so it stays inside the loop.)
import turtle
import random
screen = turtle.Screen()
screen.setup(400, 500)
screen.bgcolor('#0a0a40')
pen = turtle.Turtle()
pen.hideturtle()
pen.speed(0)
pen.color('white')
for i in range(30):
star_x = random.randint(-200, 200)
star_y = random.randint(-250, 250)
pen.penup()
pen.goto(star_x, star_y)
pen.dot(3)
rocket_x = 0
rocket_y = -200
for step in range(50):
# Add an orange smoke puff here, just below the rocket
pen.penup()
pen.goto(rocket_x, rocket_y)
pen.color('silver')
pen.dot(30)
rocket_y = rocket_y + 8
screen.mainloop()
Tap ▶ Run. You should see a stack of silver rocket dots with orange smoke beneath each one. 🔥🚀
🧩 Ideas to try
- Make the smoke a different color (try
'red'or'gold'). - Slow the rocket down by changing
+ 8to+ 4. - Add a fuel variable:
fuel = 50thenfor step in range(fuel):— ask the player for fuel withinput!
Adapted from Raspberry Pi Foundation — Rocket Launch under CC BY-SA 4.0.