-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtree.py
53 lines (50 loc) · 1.41 KB
/
tree.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import random
import turtle
class Tree():
def __init__(self,burning=False,wetness=1.0,xpos=0,ypos=0):
self.burning = burning
self.wetness = wetness
self.xpos = xpos
self.ypos = ypos
def changeBurning(self,burning):
self.burning = burning
class Oak(Tree):
def __init__(self,burning=False,wetness=1.0,xpos=0,ypos=0):
super().__init__(burning,wetness,xpos,ypos)
self.probCatch = 0.45/wetness
self.xpos = xpos
self.ypos = ypos
def draw(self):
'''stamps tree on screen'''
t = turtle
t.hideturtle()
t.penup()
t.setpos(self.xpos,self.ypos)
if self.burning is False:
t.color('green')
else:
t.color('red')
t.shape('circle')
t.shapesize(0.65)
t.settiltangle(90)
t.stamp()
class Pine(Tree):
def __init__(self,burning=False,wetness=1.0,xpos=0,ypos=0):
super().__init__(burning,wetness,xpos,ypos)
self.probCatch = 0.95/wetness
self.xpos = xpos
self.ypos = ypos
def draw(self):
'''stamps tree on screen'''
t = turtle
t.hideturtle()
t.penup()
t.setpos(self.xpos,self.ypos)
if self.burning is False:
t.color('green')
else:
t.color('red')
t.shape('triangle')
t.shapesize(0.65)
t.settiltangle(90)
t.stamp()