diff --git a/lib/tasks/project_components/make_a_face_starter/main.py b/lib/tasks/project_components/make_a_face_starter/main.py index 140cbaadf..3641009ad 100644 --- a/lib/tasks/project_components/make_a_face_starter/main.py +++ b/lib/tasks/project_components/make_a_face_starter/main.py @@ -4,13 +4,16 @@ from grid import * def setup(): - # Put code to run once here - size(400, 400) # width and height + # Put code to run once here + size(400, 400) # width and height def draw(): - # Put code to run every frame here - background(255, 255, 255) # move under draw() to reset the drawing every frame - grid() # add a # to the beginning of this line to hide the grid + # Put code to run every frame here + background(255, 255, 255) + # Add code to draw your face here + + grid() # add a # to the beginning of this line to hide the grid + # Keep this to run your code run() diff --git a/lib/tasks/project_components/powerful_patterns_kek_lepis_sarawak/main.py b/lib/tasks/project_components/powerful_patterns_kek_lepis_sarawak/main.py index e9816f307..3c1f5c80a 100644 --- a/lib/tasks/project_components/powerful_patterns_kek_lepis_sarawak/main.py +++ b/lib/tasks/project_components/powerful_patterns_kek_lepis_sarawak/main.py @@ -30,7 +30,7 @@ def quadrant(): def outer(): - # Thehe cake is wrapped in an outer layer + # The cake is wrapped in an outer layer yellowgreen = Color(154, 205, 50) no_fill() # Don't cover up the cake quadrants! diff --git a/lib/tasks/project_components/powerful_patterns_starter/main.py b/lib/tasks/project_components/powerful_patterns_starter/main.py index 84f2849da..28ebb719c 100644 --- a/lib/tasks/project_components/powerful_patterns_starter/main.py +++ b/lib/tasks/project_components/powerful_patterns_starter/main.py @@ -16,4 +16,4 @@ def draw(): # Keep this to run your code -run() +run(frame_rate = 5) diff --git a/lib/tasks/project_components/rocket_launch_example/main.py b/lib/tasks/project_components/rocket_launch_example/main.py index e8637ceff..71cc9488a 100644 --- a/lib/tasks/project_components/rocket_launch_example/main.py +++ b/lib/tasks/project_components/rocket_launch_example/main.py @@ -6,67 +6,65 @@ # Setup global variables screen_size = 400 -rocket_y = screen_size # start at the bottom -burn = 100 # how much fuel is burned in each frame +rocket_y = 400 +burn = 100 orbit_radius = 250 orbit_y = screen_size - orbit_radius + # The draw_rocket function goes here def draw_rocket(): + global rocket_y, fuel, burn - global rocket_y, fuel, burn - - if fuel >= burn and rocket_y > orbit_y: # still flying - rocket_y -= 1 # move the rocket - fuel -= burn # burn fuel - print('Fuel left: ', fuel) - - no_stroke() # Turn off the stroke - - for i in range(25): # draw 25 burning exhaust ellipses - fill(255, 255 - i*10, 0) # yellow - ellipse(width/2, rocket_y + i, 8, 3) # i increases each time the loop repeats + if fuel >= burn and rocket_y > orbit_y: + rocket_y -= 1 + fuel -= burn + print('Fuel left: ', fuel) + + no_stroke() + + for i in range(25): + fill(255, 255 - i * 10, 0) + ellipse(width/2, rocket_y + i, 8, 3) - fill(200, 200, 200, 100) # transparent grey - for i in range(20): # draw 20 random smoke ellipses - ellipse(width/2 + randint(-5, 5), rocket_y + randint(20, 50), randint(5, 10), randint(5, 10)) - - if fuel < burn and rocket_y > orbit_y: # No more fuel and not in orbit - tint(255, 0, 0) # Failure - elif fuel < 1000 and rocket_y <= orbit_y: - tint(0, 255, 0) # Success - elif fuel >= 1000 and rocket_y <= orbit_y: - tint(255, 200, 0) # Too much fuel - - image(rocket, width/2, rocket_y, 64, 64) - no_tint() - + fill(200, 200, 200, 100) #Transparent grey + for i in range(20): #Draw 20 random smoke ellipses + ellipse(width/2 + randint(-5, 5), rocket_y + randint(20, 50), randint(5, 10), randint(5, 10)) + + if fuel < burn and rocket_y > orbit_y: + tint(255, 0, 0) + elif fuel < 1000 and rocket_y <= orbit_y: + tint(0, 255, 0) + elif fuel >= 1000 and rocket_y <= orbit_y: + tint(255, 200, 0) + + image(rocket, width/2, rocket_y, 64, 64) + no_tint() + # The draw_background function goes here def draw_background(): - background(0) # short for background(0, 0, 0) - black - image(planet, width/2, height, 300, 300) # draw the image - - no_fill() # Turn off any fill - stroke(255) # Set a white stroke - stroke_weight(2) - ellipse(width/2, height, orbit_radius*2, orbit_radius*2) - + background(0) + image(planet, width/2, height, 300, 300) + + no_fill() + stroke(255) + stroke_weight(2) + ellipse(width/2, height, orbit_radius * 2, orbit_radius * 2) def setup(): - # Setup your animation here - size(screen_size, screen_size) - image_mode(CENTER) - global planet, rocket - planet = load_image('planet.png') # your chosen planet - rocket = load_image('rocket.png') + # Setup your animation here + size(screen_size, screen_size) + image_mode(CENTER) + global planet, rocket + planet = load_image('planet.png') + rocket = load_image('rocket.png') def draw(): - # Things to do in every frame - draw_background() - draw_rocket() - + # Things to do in every frame + draw_background() + draw_rocket() fuel = int(input('How many kilograms of fuel do you want to use?')) run()