generated from mwc/project_drawing
	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:
		@@ -1,10 +1,10 @@
 | 
			
		||||
# (Drawing project)
 | 
			
		||||
 | 
			
		||||
I can draw a building with rectangles and triangles.
 | 
			
		||||
I can draw a building with rectangles.
 | 
			
		||||
 | 
			
		||||
## Description 
 | 
			
		||||
 | 
			
		||||
If I can, I want my drawing to be an animation of mutiple buildings lighting up with roads at the side.
 | 
			
		||||
If I can, I want my drawing to be an animation of mutiple buildings flickering.
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
)
 | 
			
		||||
@@ -14,6 +14,6 @@ If I can, I want my drawing to be an animation of mutiple buildings lighting up
 | 
			
		||||
## Milestone 1
 | 
			
		||||
Write a function to draw a building using the width,height, and color.
 | 
			
		||||
## Milestone 2
 | 
			
		||||
Add windows in the buildings.
 | 
			
		||||
Animate the buildings.
 | 
			
		||||
## Milestone 3
 | 
			
		||||
Create another function to try to draw a road. 
 | 
			
		||||
Fix any error. 
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										34
									
								
								drawing.py
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								drawing.py
									
									
									
									
									
								
							@@ -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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user