I changed the building size, color, and my original project idea to something simple.

I got stuck on super turtle animuation. Everytime I try to open drawing.py it wouldn't open. Then, my instructor helped me by telling me to type poetry shell and it worked.
Additionally, I want to learn more about superturtle because i was a little confused about the codes.
This commit is contained in:
juddin2
2025-09-27 17:11:12 -04:00
parent f59b343487
commit 0517ef4c54
2 changed files with 27 additions and 15 deletions

View File

@@ -2,11 +2,12 @@
# ----------
# By Jannatun Uddin
#
# (Briefly describe what this program does.)
# (It makes 3 buildings that flicker from dark gray and gets dimmer.Also, if tou look closely at the buildings you can see it get closer too.)
from superturtle.animation import animate
from turtle import forward, left, penup, pendown, fillcolor, begin_fill, end_fill
from turtle import forward, left, right, backward, penup, pendown, begin_fill, end_fill, pencolor, fillcolor
def draw_building(width, height, color="gray"):
pencolor(color)
fillcolor(color)
begin_fill()
for i in range(2):
@@ -16,25 +17,36 @@ def draw_building(width, height, color="gray"):
left(90)
end_fill()
# Animation loop
# This is an Animation
for frame in animate(40, loop=True):
brightness = int(frame.interpolate(100, 200, mirror=True))
shade = int(frame.interpolate(100, 200, mirror=True))
color = f"#{shade:02x}{shade:02x}{shade:02x}"
# First building
penup()
backward(200)
pendown()
draw_building(60, 100, color)
# Second building
# Building 1
draw_building(60, 200, color)
# Building 2
penup()
forward(80)
pendown()
draw_building(50, 120, color)
# Third building
# Building 3
penup()
forward(70)
pendown()
draw_building(70, 90, color)
input()
draw_building(90, 300, color)