I'm stuck! I tried to draw the bubbles to ease up on a loop

but when I run it, the bubbles speed up and go crazy.  I
don't know what I'm missing.  Also, when the bubbles are on a loop
it doesn't continue on to draw the turtle.  Can I run the two simultaniously?
This commit is contained in:
Hope 2025-06-23 14:08:01 -04:00
parent c82a594a05
commit 6bc9ef9f0b
2 changed files with 43 additions and 5 deletions

View File

@ -11,10 +11,6 @@ which allows basic formatting.
(I would like to create an animated swimming sea turtle with some bubbles.
If you want to link to an
image, move the image to this directory, and then use the following syntax:
![Description](filename.png)
)
## Planning

View File

@ -9,7 +9,9 @@
from turtle import *
from superturtle.movement import fly
from superturtle.animation import animate
from superturtle.easing import easeInQuad
import math
import random
def draw_turtle(size):
@ -52,10 +54,50 @@ def draw_turtle(size):
forward(size*1.5)
pendown()
def draw_flipper(size):
left(90)
def draw_bubble(b_size):
pencolor("blue")
circle(b_size)
def place_bubbles(number):
#draws bubbles of random sizes and locations in each of the 4 quadrants
for i in range(number):
x = random.random()*400
y = random.random()*200
fly(x,y)
b_size = random.random()*15
draw_bubble(b_size)
for i in range(number):
x = random.random()*400
y = random.random()*200
fly(-x,y)
b_size = random.random()*15
draw_bubble(b_size)
for i in range(number):
x = random.random()*400
y = random.random()*200
fly(x,-y)
b_size = random.random()*15
draw_bubble(b_size)
for i in range(number):
x = random.random()*400
y = random.random()*200
fly(-x,-y)
b_size = random.random()*15
draw_bubble(b_size)
fly(0,0)
#pass the number of bubbles you want in each quadrant (so it will be 4 X what you pass)
for frame in animate(50, loop=True):
x = frame.interpolate(-10, 10)
y = frame.interpolate(20, -10, easing=easeInQuad)
fly(x, y)
place_bubbles(1)
draw_turtle(20)
done()