diff --git a/main.py b/main.py index bc4d301..ddddad0 100644 --- a/main.py +++ b/main.py @@ -1,33 +1,44 @@ # Import library code from p5 import * -from random import randint # Set up global variables screen_size = 400 +rocket_y = screen_size - 100 +rocket_img = None +planet_img = None -# The draw_rocket function goes here +def draw_rocket(): + '''Draw the rocket at its current position''' + global rocket_y, rocket_img + + if rocket_img: + # Draw rocket at current position + image(rocket_img, width / 2, rocket_y, 50, 50) # Width=50, Height=50 + + rocket_y = rocket_y - 5 + + if rocket_y < -50: + rocket_y = screen_size + 50 +def draw_background(): + '''Draw the space background with planet''' + background(0, 0, 0) + + if planet_img: + # Draw planet at bottom center (size 150x150) + image(planet_img, width / 2, height - 50, 150, 150) - -# The draw_background function goes here - - - def setup(): - # Set up your animation here + global rocket_img, planet_img size(screen_size, screen_size) image_mode(CENTER) - global planet - planet = load_image('planet.png') - + + # Load images + rocket_img = load_image('rocket.png') + planet_img = load_image('planet.png') def draw(): - # Things to do in every frame - - - + draw_background() + draw_rocket() run() - - - \ No newline at end of file