-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMap.py
211 lines (169 loc) · 5.28 KB
/
Map.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import math
import turtle
#===============================================================================
# LANDMARKS
#===============================================================================
def drawSpring(xpos,ypos):
turtle.fillcolor(0.5,1,1)
turtle.setpos(xpos,ypos)
turtle.fill(True)
turtle.circle(10)
turtle.fill(False)
turtle.setpos(xpos,ypos)
return
def drawTown(xpos,ypos):
turtle.fillcolor(1,0,0)
turtle.fill(True)
turtle.setpos(xpos,ypos)
turtle.setpos(xpos-7,ypos)
turtle.setpos(xpos-7,ypos+10)
turtle.setpos(xpos-10,ypos+10)
turtle.setpos(xpos,ypos+20)
turtle.setpos(xpos+10,ypos+10)
turtle.setpos(xpos+7,ypos+10)
turtle.setpos(xpos+7,ypos)
turtle.setpos(xpos,ypos)
return
def drawCave(xpos,ypos):
turtle.fillcolor(0.75,0.75,0.75)
turtle.fill(True)
turtle.setpos(xpos-10,ypos)
turtle.setpos(xpos-10,ypos+15)
turtle.setpos(xpos-5,ypos+20)
turtle.setpos(xpos,ypos+20)
turtle.setpos(xpos+5,ypos+20)
turtle.setpos(xpos+10,ypos+15)
turtle.setpos(xpos+10,ypos)
turtle.setpos(xpos-10,ypos)
turtle.fill(False)
turtle.fillcolor(0,0,0)
turtle.fill(True)
turtle.setpos(xpos-5,ypos)
turtle.setpos(xpos-5,ypos+10)
turtle.setpos(xpos,ypos+15)
turtle.setpos(xpos+5,ypos+10)
turtle.setpos(xpos+5,ypos)
turtle.setpos(xpos-5,ypos)
turtle.fill(False)
return
def drawRuin(xpos,ypos):
turtle.fillcolor(0.95,0.95,0.95)
turtle.fill(True)
turtle.setpos(xpos-5,ypos)
turtle.setpos(xpos-5,ypos+10)
turtle.setpos(xpos,ypos+15)
turtle.setpos(xpos+5,ypos+20)
turtle.setpos(xpos+5,ypos)
turtle.setpos(xpos-5,ypos)
turtle.fill(False)
turtle.setpos(xpos-10,ypos)
turtle.setpos(xpos+10,ypos)
return
def putSymbol(tuple):
k=tuple[0]
xpos=k[0]
ypos=k[1]
label=tuple[1]
turtle.penup()
turtle.fill(False)
turtle.setpos(xpos,ypos)
turtle.pendown();
if (label=='ruin'):
drawRuin(xpos,ypos)
elif(label=='cave'):
drawCave(xpos,ypos)
elif(label=='town'):
drawTown(xpos,ypos)
elif(label=='spring'):
drawSpring(xpos,ypos)
return
def putSymbols(symbolSet):
symbolType=symbolSet[0]
for coords in symbolSet[1:]:
putSymbol([coords,symbolType])
return
#===============================================================================
# BLOCKS OF COLOR
#===============================================================================
def fetchColor(label):
color=(1,1,1)
if (label=='ocean'):
color=(0,0,1)
elif (label=='shallow'):
color=(0.5,0.5,1)
elif (label=='sand'):
color=(1,1,0.5)
elif (label=='plain'):
color=(0.5,1.0,0.5)
elif (label=='forest'):
color=(0,0.5,0)
elif (label=='mountain'):
color=(0.75,0.75,0.75)
else:
color=(1,0,0)
return color
def putBlock(block):
label=block[0]
p=[]
for coord in block[1:]:
p=p+coord
color=fetchColor(label)
turtle.fill(True)
turtle.fillcolor(color)
turtle.penup()
k=p[0]
turtle.setpos(k[0],k[1])
turtle.pendown()
for i in range(0,len(p)):
k=p[i]
turtle.setpos(k[0],k[1])
k=p[0]
turtle.setpos(k[0],k[1])
turtle.fill(False)
turtle.penup()
return
#===============================================================================
# MAPGRIDS
#===============================================================================
def drawCenter():
for i in range(0,360,90):
turtle.penup()
turtle.setpos(0,0)
turtle.setheading(i)
turtle.pendown()
turtle.forward(500)
turtle.penup()
turtle.setpos(0,0)
turtle.setheading(0)
return
def drawGrid():
for i in range(360,-360,-20):
turtle.penup()
turtle.setpos(-500,i)
turtle.pendown()
turtle.setpos(500,i)
for i in range(-500,500,20):
turtle.penup()
turtle.setpos(i,-360)
turtle.pendown()
turtle.setpos(i,360)
return
#===============================================================================
#MAIN
#===============================================================================
turtle.speed(0)
turtle.setup (width=1000, height=720)
turtle.hideturtle()
drawCenter()
#PUT BLOCKS OF COLOR HERE. ORDER IS IMPORTANT
block=['ocean', [(-500, -360),(-500, 360),( 500, 360),( 500,-360)]]
putBlock(block)
block=['shallows', [(-460, -140), (-460, -140), (-460, 165), (-250, 315), (50, 265), (200, 215), (400, 215), (425, 150), (450, -45), (250, -145), (200, -245), (-100, -245), (-150, -170), (-200, -95), (-250, -95), (-300, -140)]]
putBlock(block)
drawGrid()
#PUT LANDMARKS
#Springs
symbolset=['spring',(-110, 100), (-360,0), (320,0)]
putSymbols(symbolset)
#PUT PATH TO TREASURE
turtle.exitonclick()