Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import turtle
- ##This Program Will Draw A Scene With a House and A Tree and A Sun/Moon
- d_n = raw_input('day or night?: ')
- if d_n == 'day':
- print 'day'
- elif d_n == 'night':
- print 'night'
- else:
- print 'You have selected neither, you get day.'
- class circle(object):
- def __init__(self, pen, size, number, fillcolor=""):
- """whats in circle"""
- pen = turtle.Turtle()
- self.b= size
- self.c = fillcolor
- self.d = number
- def __str__(self):
- """string of circle"""
- return '(' +str(self.b)+ "," + str(self.c)+ "," + str(self.d)+')'
- def draw(self, pen, size, x, y, number, fillcolor=''):
- """drawing a circle"""
- pen.up()
- pen.goto(x, y)
- pen.fill(True)
- pen.pencolor = 'black'
- pen.down()
- rotation = 360/float(number)
- for i in range(number):
- pen.fillcolor(fillcolor)
- pen.circle(size)
- pen.left(rotation)
- pen.fill(False)
- pen.up
- class square(object):
- def __init__(self, pen, size, fillcolor=''):
- """what is in square"""
- pen=turtle.Turtle()
- self.b = size
- self.c = fillcolor
- def __str__(self):
- """string of square"""
- return '(' +str(self.b)+ "," + str(self.c)+')'
- def draw(self, pen, size, x, y, fillcolor=''):
- """drawing a square"""
- pen.up()
- pen.goto(x, y)
- pen.fill(True)
- pen.pencolor = 'black'
- pen.down()
- for i in range(4):
- pen.down()
- pen.forward(size)
- pen.left(90)
- pen.fillcolor(fillcolor)
- pen.fill(False)
- pen.up()
- class tree(object):
- def __init__(self, pen, fillcolor=''):
- """what is in tree"""
- pen=turtle.Turtle()
- self.b = fillcolor
- def __str__(self):
- """string of tree"""
- return '(' +str(self.b)+ ')'
- def draw(self, pen, x, y, fillcolor=''):
- """drawing a tree"""
- pen.up()
- pen.goto(x, y)
- pen.fill(True)
- pen.pencolor='black'
- if d_n == 'night':
- a = '#330000'
- else:
- a = 'brown'
- for i in range(2):
- pen.down()
- pen.forward(20)
- pen.left(-90)
- pen.forward(200)
- pen.left(-90)
- pen.fillcolor(a)
- pen.fill(False)
- if d_n == 'night':
- b = '#006600'
- else:
- b = 'green'
- pen.up()
- pen.goto(x, y+200)
- pen.down()
- c.draw(pen, 30, x-30, y+200, 6, b)
- pen.fill(False)
- pen.up()
- pen.goto(x+30, y+200)
- pen.down()
- pen.fill(True)
- c.draw(pen, 30, x+30, y+200, 6, b)
- class house(object):
- def __init__(self, pen):
- """what is in house"""
- pen = turtle.Turtle()
- def __str__(self):
- """string of house"""
- return '(' +str(pen)+ ')'
- def draw(self, pen, x, y):
- """drawing house"""
- pen.up()
- pen.goto(x,y)
- pen.fill(True)
- pen.pencolor='black'
- if d_n == 'night':
- d = '#990000'
- else:
- d = '#FF0000'
- for i in range(2):
- pen.down()
- pen.forward(100)
- pen.left(90)
- pen.forward(175)
- pen.left(90)
- pen.fillcolor(d)
- pen.fill(False)
- pen.up()
- pen.goto(x+30, y)
- if d_n == 'night':
- e = '#FFFF00'
- else:
- e = '#CCFF00'
- for i in range(2):
- pen.fill(True)
- pen.down()
- pen.forward(40)
- pen.left(90)
- pen.forward(70)
- pen.left(90)
- pen.fillcolor(e)
- pen.fill(False)
- pen.up()
- if d_n == 'night':
- f = '#6600FF'
- else:
- f = '#66CCCC'
- pen.fill(True)
- pen.goto(x-30, y+175)
- pen.down()
- pen.fillcolor(f)
- pen.left(60)
- pen.forward(160)
- pen.right(120)
- pen.forward(160)
- pen.right(120)
- pen.forward(160)
- pen.fillcolor(f)
- pen.up()
- pen.fill(False)
- #windows#
- if d_n == 'night':
- g = 'grey'
- else:
- g = 'white'
- pen.goto(-170, -50)
- for i in range(2):
- pen.fill(True)
- pen.down()
- pen.forward(20)
- pen.left(90)
- pen.forward(30)
- pen.left(90)
- pen.forward(20)
- pen.left(90)
- pen.forward(30)
- pen.fillcolor(g)
- pen.left(90)
- pen.up()
- pen.fill(False)
- pen.goto(-110, -50)
- c.draw(pen, 2, -138, -170, 1, 'black')
- #below: drawings
- pen=turtle.Turtle()
- c = circle(pen, 7, 'blue')
- h = house(pen)
- h.draw(pen, -200, -200)
- t = tree(pen)
- t.draw(pen, 125, -200)
- #the SUN/MOON
- if d_n == 'night':
- h = 'CCFFCC'
- else:
- h = 'yellow'
- c.draw(pen, 70, -150, 300, 1, h)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement