2026-05-29 19:06:52 +00:00
2026-05-29 19:06:52 +00:00
2026-05-29 08:27:52 +00:00
2026-05-29 08:27:52 +00:00
2026-05-29 08:27:52 +00:00
2026-05-29 08:27:52 +00:00
2026-05-29 08:27:52 +00:00
2026-05-29 08:27:52 +00:00

🚀 Rocket Launch Animation

What You'll Create

An animated rocket that launches into space with a planet in the background!

How to Run

  1. Open Python IDLE

    • Mac: Press ⌘ + Space, type "IDLE", press Enter
    • Windows: Press ⊞ + R, type "idle", press Enter
  2. In IDLE, click File → Open...

  3. Navigate to this folder and select main.py

  4. Click Run → Run Module or press F5

  5. Watch your rocket launch! 🚀

Option 2: Using Terminal/Command Prompt

cd "Rocket Launch/rocket_launch"
python3 main.py

What the Code Does

Global Variables

  • screen_size = 400 - Sets the window size to 400x400 pixels
  • rocket_y - Controls the rocket's vertical position (starts near bottom)

Functions

draw_rocket()

                                                                                                                                                                        • -_background()`
  • Sets the backgrou- Sets the backgrou-- Draws the planet at the bottom center of the screen

setup()

  • Creates a 400x400 pixel window
  • Sets image mode to CENTER (images are positioned from their center)
  • Load- Load- Load- Load- Load- Load- Load- Load- Load- Load- Loom- Load- Load- Load- Load- Load- Load- Load- Load- Load- Lohe background
  • Then draws the rocket on top

Customization Ideas

Try modifying the code tTry modifying the code tTry modifying the codeed Try modifying the code tTry mod line:

rocket_y = rocket_y - 5  # Try rocketr faster, -2 for slower

Use a Different Planet

In setup(), change the planet image:

planet = load_image('purple_planet.png')  # or 'orange_planet.png' or 'moon.png'

Add Stars

Add this to draw_background():

for i in range(50):
    x = randint(0, width)
    y = randint(0, height)
    fill(255)
    circle(x, y, 2)

Change Background Color

In draw_background(), change:

background(0, 0, 0)  # Black space
# Try: background(25, 25, 112) for midnight blue
# Or: background(75, 0, 130) for indigo

Troubleshooting

"No module named 'p5'"

Install p5 by running in terminal:

pip3 install p5

########################### sure all image files are in the same folder as main.py:

  • planet.png
  • rocket.png
  • moon.png (opti- moon.png (opti- net.png (o- moon.png (optle_planet.png (optional)

Window Doesn't Open

Check for error messages in red text. Common issues:

  • Missing images
  • Typo in code
  • p5 not installed

Learn More

This project uses the *This project uses the *Th which makes it easy to create animationsThis proeractive graphics!

Happy coding! 🎉

Description
No description provided
Readme 230 KiB
Languages
Python 100%