My third commit will consist of my third round of changes. What has changed during my third commit were my functions. In this attempt I was given feedback to consider how can I add more parameters or loops to my existing code. I did both by adding customizable parameters to allow a house and sun of any color. I also added a for loop that gives me three houses of different color instead of one.

What got me stuck in the beginning was how can I add more parameters or loops to my existing code.
What I figured out was that by adding more parameters and loops to my existing code I would be able to create a drawing that would give me three house and a sun
with customizable color of my choosing. A strategy I used to get unstuck was to continue using ideas from previous lessons about parameters and trial and error to
 see where things went right and wrong. What I wonder is how can I use super turtle to create an animated sun. What I want to learn more about is how to properly
 use super turtle. Since I have more houses and sun with customizable color my future project idea could be to create three houses and a sun with customizable
 coloring but this time using super turtle to creaete an animated rising sun.
This commit is contained in:
angelotr
2025-10-05 17:35:20 -04:00
parent eaf4735298
commit 6966760b2b
4 changed files with 85 additions and 54 deletions

View File

@@ -1,41 +1,50 @@
import turtle
def draw_square(t, size, color="black", fill=""):
t.color(color, fill)
def draw_square(pen, size, color="black", fill=None):
"""Draw a square with optional fill color."""
pen.color(color)
if fill:
t.begin_fill()
pen.fillcolor(fill)
pen.begin_fill()
for _ in range(4):
t.forward(size)
t.right(90)
pen.forward(size)
pen.right(90)
if fill:
t.end_fill()
pen.end_fill()
def draw_rectangle(t, width, height, color="black", fill=""):
t.color(color, fill)
def draw_rectangle(pen, width, height, color="black", fill=None):
"""Draw a rectangle with optional fill color."""
pen.color(color)
if fill:
t.begin_fill()
pen.fillcolor(fill)
pen.begin_fill()
for _ in range(2):
t.forward(width)
t.right(90)
t.forward(height)
t.right(90)
pen.forward(width)
pen.right(90)
pen.forward(height)
pen.right(90)
if fill:
t.end_fill()
pen.end_fill()
def draw_triangle(t, size, color="black", fill=""):
t.color(color, fill)
def draw_triangle(pen, size, color="black", fill=None):
"""Draw an equilateral triangle with optional fill color."""
pen.color(color)
if fill:
t.begin_fill()
pen.fillcolor(fill)
pen.begin_fill()
for _ in range(3):
t.forward(size)
t.left(120)
pen.forward(size)
pen.left(120)
if fill:
t.end_fill()
pen.end_fill()
def draw_circle(t, radius, color="black", fill=""):
t.color(color, fill)
def draw_circle(pen, radius, color="black", fill=None):
"""Draw a circle with optional fill color."""
pen.color(color)
if fill:
t.begin_fill()
t.circle(radius)
pen.fillcolor(fill)
pen.begin_fill()
pen.circle(radius)
if fill:
t.end_fill()
pen.end_fill()