Skip to content

Instantly share code, notes, and snippets.

@rpodcast
Created April 30, 2023 03:15
Show Gist options
  • Save rpodcast/5ba56e7ed3ac9ed1fc082d7ec8240e25 to your computer and use it in GitHub Desktop.
Save rpodcast/5ba56e7ed3ac9ed1fc082d7ec8240e25 to your computer and use it in GitHub Desktop.
Python Project (Darren)
# Darren Nantz
# Final Project Name: My House And Yard
#Class: Beginner 2
from turtle import *
from random import *
bgcolor("lightblue")
tracer(0)
color("springgreen")
begin_fill()
up()
goto(-10000,-10000)
goto(10000,-10000)
goto(10000,-400)
goto(-10000,-400)
goto(-10000,-10000)
end_fill()
goto(0,0)
color("brown")
def draw_leaves(leafsize):
color("green", "green")
begin_fill()
circle(leafsize) #leaves
end_fill()
down()
n=(randint(1,100))
if(n>94):
dot(15,"red") #fruit
def draw_branch(len):
down()
if (len > 5): #control loop
color("saddlebrown")
forward(len)
pensize(5)
right(25)
draw_branch(len - randint(1,10))#random number for branch size controls the loop and calls itself
left(50)
draw_leaves(8)
draw_branch(len - randint(1,10))
right(25)
backward(len)
up()
def tree(x,y):
goto(x,y)
left(90)
draw_branch(60)
penup()
goto(x,y-300)
up()
color("saddlebrown")
pensize(40)
pendown()
goto(x,y+100)
penup()
tree(0,-200)
up()
goto(-425,350)
dot(100,"yellow")
m=Turtle()
m.shape("circle")
m.goto(-440,350)
def house(x,y):
penup()
goto(x,y)
begin_fill()
pendown()
color("tan")
goto(x,y)
goto(x,y+300)
goto(x+300,y+300)
goto(x+300,y)
goto(x,y)
end_fill()
color("tan")
up()
goto(x,y+300)
left(90)
begin_fill()
down()
forward(45)
right(120)
fd(390)
right(120)
fd(390)
right(120)
fd(45)
end_fill()
up()
goto(x+140,y)
down()
color("tan") #house
goto(x+150,y)
goto(x+150,y+40)
goto(x+140,y+40)
goto(x+140,y)
up()
begin_fill()
down()
pensize(50)
color("darkgoldenrod") #door
goto(x+130,y)
goto(x+170,y)
goto(x+170,y+200)
goto(x+130,y+200)
goto(x+130,y)
end_fill()
up()
goto(x+165,y+100) # door knob
dot(20,"darkslategray")
goto(x+170,y-200)
up()
goto(x+50,y+60)
begin_fill()
color("white") #windows
goto(x+2,y+60)
goto(x+2,y+200)
goto(x+92,y+200)
goto(x+92,y+60)
goto(x+2,y+60)
penup()
end_fill()
up()
color("white")
begin_fill()
goto(x+218,y+60)
down()
pensize(5)
goto(x+218,y+200)
goto(x+308,y+200)
goto(x+308,y+60)
goto(x+218,y+60)
end_fill()
penup()
goto(x+150,y+400)
dot(100,"white") #circle window on roof
house(-700,-500)
def drawsun (o,p,c,s):
color("green")
penup()
goto(o,p)
pendown()
pensize(5)
setheading(-90)
forward(100)
backward(100)
pensize(1)
penup()
goto(o,p)
pendown()
for i in range(0,720,10):
setheading(i)
color(c)
forward(s)
backward(s)
drawsun(-200, -300,"red",50)
drawsun(200,-300,"blue",40)
drawsun(300,-300,"orange",60)
drawsun(-800,-300,"yellow",50)
def drawflower(x,y,c):
color("green")
up()
goto(x,y)
pensize(10)
setheading(-90)
down()
forward(200)
backward(200)
pensize(3)
color(c)
for i in range(20):
circle(30)
left(360/20)
up()
color("grey") #mountains
begin_fill()
goto(700,200)
goto(800,400)
goto(900,200)
goto(700,200)
end_fill()
begin_fill()
goto(575,250)
goto(675,550)
goto(775,250)
goto(575,250)
end_fill()
begin_fill()
goto(800,180)
goto(900,380)
goto(1000,180)
goto(800,180)
end_fill()
begin_fill()
goto(600,220)
goto(500,340)
goto(400,220)
goto(600,220)
end_fill()
drawflower(500,-200,"pink")
drawflower(800,-200,"purple")
up()
def cloud(x,y):
goto(x,y)
dot(120,"white")
backward(100)
goto(x+20,y+30)
dot(50,"white")
goto(x+70,y+60)
dot(60,"white")
goto(x-30,y)
dot(100,"white")
goto(x-100,y+20)
dot(130,"white")
goto(x-150,y-30)
dot(90,"white")
goto(x+30,y+30)
dot(100,"white")
cloud(300,400)
def cloud2(x,y):
goto(x,y)
goto(x,y)
dot(160,"white")
backward(100)
goto(x-20,y+30)
dot(50,"white")
goto(x-90,y+60)
dot(80,"white")
goto(x+30,y)
dot(100,"white")
goto(x-140,y+20)
dot(130,"white")
goto(x-100,y-30)
dot(90,"white")
goto(x+10,y+30)
dot(100,"white")
cloud2(-400,350)
def stone(x,y,s):
up()
color("grey")
goto(x,y)
left(180)
begin_fill()
circle(s,180)
end_fill()
stone(140,-400,50)
stone(230,-420,30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment