-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwalls.py
290 lines (280 loc) · 9.91 KB
/
walls.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
import pygame
import random
from pygame.locals import*
'''
Purpose:
- To create the vertical boundaries for the map
Parameter:
N/A
Return:
- A vertical boundary around the map
'''
class wall_vert(pygame.sprite.Sprite):
'''
Purpose:
- To create the vertical boundaries for the map
Parameter:
back_height: The height of the object
back_width: The width of the object
thick: The thickness of the object
loc1: The location of the object, x-value
loc2: The location of the object, y-value
Return:
- A boundary with collision and boundaries
'''
def __init__(self, back_height, back_width, thick, loc1, loc2):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((thick,back_height)).convert()
self.image.set_alpha(50)
self.image.fill((250,0,0,20))
self.rect = self.image.get_rect()
self.rect.center = (loc1,loc2)
'''
Purpose:
- To move the boundary around when the player is stimulating movement
Parameter:
x: The horizontal movement of the object
y: The vertical movement of the object
Return:
- The movement and placing of the boundary
'''
def update(self,x,y):
self.rect.top +=y
self.rect.left +=x
'''
Purpose:
- To create the horizontal boundaries for the map
Parameter:
N/A
Return:
- A horizontal boundary around the map
'''
class wall_hori(pygame.sprite.Sprite):
'''
Purpose:
- To create the horizontal boundaries for the map
Parameter:
back_height: The height of the object
back_width: The width of the object
thick: The thickness of the object
loc1: The location of the object, x-value
loc2: The location of the object, y-value
Return:
- A boundary with collision and boundaries
'''
def __init__(self, back_height, back_width, thick, loc1, loc2):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((back_width, thick)).convert()
self.image.set_alpha(50)
self.image.fill((250,0,0,20))
self.rect = self.image.get_rect()
self.rect.center = (loc1,loc2)
'''
Purpose:
- To move the boundary around when the player is stimulating movement
Parameter:
x: The horizontal movement of the object
y: The vertical movement of the object
Return:
- The movement and placing of the boundary
'''
def update(self,x,y):
self.rect.top +=y
self.rect.left +=x
'''
Purpose:
- To create the vertical walls for the map
Parameter:
N/A
Return:
- A vertical wall with collision and boundaries
'''
class wall_vert_w(pygame.sprite.Sprite):
'''
Purpose:
- To create the vertical walls for the map
Parameter:
back_height: The height of the object
back_width: The width of the object
thick: The thickness of the object
loc1: The location of the object, x-value
loc2: The location of the object, y-value
tb: The top or bottom surface of the object
lr: The left or right surface of the object
Return:
- A wall with collision and boundaries
'''
def __init__(self, back_height, back_width, thick, loc1, loc2, tb, lr):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((thick,back_height)).convert()
self.image.set_alpha(0)
self.image.fill((250,0,0,20))
self.rect = self.image.get_rect()
if tb == "b":
self.rect.bottom = (loc2)
elif tb == "t":
self.rect.top = (loc2)
if lr == "r":
self.rect.right = (loc1)
elif lr == "l":
self.rect.left = (loc1)
'''
Purpose:
- To move the wall around when the player is stimulating movement
Parameter:
x: The horizontal movement of the object
y: The vertical movement of the object
Return:
- The movement and placing of the wall
'''
def update(self,x,y):
self.rect.top +=y
self.rect.left +=x
'''
Purpose:
- To create the horizontal walls for the map
Parameter:
N/A
Return:
- A horizontal wall with collision and boundaries
'''
class wall_hori_w(pygame.sprite.Sprite):
'''
Purpose:
- To create the horizontal walls for the map
Parameter:
back_height: The height of the object
back_width: The width of the object
thick: The thickness of the object
loc1: The location of the object, x-value
loc2: The location of the object, y-value
tb: The top or bottom surface of the object
lr: The left or right surface of the object
Return:
- A wall with collision and boundaries
'''
def __init__(self, back_height, back_width, thick, loc1, loc2, tb, lr):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((back_width, thick)).convert()
self.image.set_alpha(0)
self.image.fill((250,0,0,20))
self.rect = self.image.get_rect()
if tb == "b":
self.rect.bottom = (loc2)
elif tb == "t":
self.rect.top = (loc2)
if lr == "l":
self.rect.left = (loc1)
elif lr == "r":
self.rect.right = (loc1)
'''
Purpose:
- To move the wall around when the player is stimulating movement
Parameter:
x: The horizontal movement of the object
y: The vertical movement of the object
Return:
- The movement and placing of the wall
'''
def update(self,x,y):
self.rect.top +=y
self.rect.left +=x
'''
Purpose:
- To create the doors for the map
Parameter:
N/A
Return:
- A door with collision and boundaries
'''
class doors(pygame.sprite.Sprite):
'''
Purpose:
- To create the doors for the map
Parameter:
back_height: The height of the object
back_width: The width of the object
thick: The thickness of the object
loc1: The location of the object, x-value
loc2: The location of the object, y-value
tb: The top or bottom surface of the object
lr: The left or right surface of the object
Return:
- A door with collision and boundaries
'''
def __init__(self, back_height, back_width, thick, loc1, loc2, tb, lr):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((thick,back_height)).convert()
self.image.fill((102,51,0))
self.rect = self.image.get_rect()
if tb == "b":
self.rect.bottom = (loc2)
elif tb == "t":
self.rect.top = (loc2)
if lr == "r":
self.rect.right = (loc1)
elif lr == "l":
self.rect.left = (loc1)
'''
Purpose:
- To move the door around when the player is stimulating movement
Parameter:
x: The horizontal movement of the object
y: The vertical movement of the object
Return:
- The movement and placing of the door
'''
def update(self,x,y):
self.rect.top +=y
self.rect.left +=x
'''
Purpose:
- To create the boundaries, walls, and doors of the game map
Parameter:
back_height: The height of map's boundaries
back_width: The width of the map's boundaries
Return:
wall_group: The group containing all of the map's boundaries, walls, and doors
'''
def make_Walls(back_height, back_width):
##Walls
wall1 = wall_vert(back_height, back_width, 10, ((back_width/2)-1500), 1000)
wall2 = wall_vert(back_height, back_width, 10, ((-back_width/2)-1500), 1000)
wall3 = wall_hori(back_height, back_width, 10, -1500, ((back_height/2)+1000))
wall4 = wall_hori(back_height, back_width, 10, -1500, ((-back_height/2)+1000))
wall5 = wall_hori_w(0, 2482, 15, -2495, 1663, "b", "l")
wall6 = wall_vert_w(1440, 0, 15, -2480, 1663, "b", "r")
wall7 = wall_hori_w(0, 1320, 15, -2495, 233, "b", "l")
wall8 = wall_vert_w(393, 0, 15, -1175, 218, "t", "r")
wall9 = wall_hori_w(0, 1177, 15, -1190, 611, "b", "l")
wall10 = wall_vert_w(925, 0, 15, -13, 1663, "b", "r")
wall11 = wall_hori_w(0, 815, 15, -2130, 611, "b", "l")
wall12 = wall_hori_w(0, 926, 15, -2130, 923, "b", "l")
wall13 = wall_hori_w(0, 926, 15, -1080, 923, "b", "l")
wall14 = wall_vert_w(393, 0, 15, -2130, 218, "t", "l")
wall15 = wall_vert_w(695, 0, 15, -2130, 829, "t", "l")
wall16 = wall_vert_w(616, 0, 15, -1080, 1524, "b", "l")
safe1 = wall_hori_w(0, 200, 193, -2490, 233, "t", "l")
safe2 = wall_hori_w(0, 105, 105, -13, 1663, "b", "r")
box1 = wall_hori_w(0, 350, 117, -1535, 233, "t", "l")
box2 = wall_hori_w(0, 120, 110, -2130, 233, "t", "l")
desk1 = wall_hori_w(0, 100, 402, -1750, 920, "t", "l")
desk2 = wall_hori_w(0, 350, 105, -2010, 1217, "t", "l")
desk3 = wall_hori_w(0, 100, 402, -710, 920, "t", "l")
desk4 = wall_hori_w(0, 350, 105, -970, 1217, "t", "l")
chair1 = wall_hori_w(0, 74, 74, -1865, 1072, "t", "l")
chair2 = wall_hori_w(0, 74, 74, -845, 1072, "t", "l")
bush1 = wall_hori_w(0, 2613, 144, -2562, 2075, "t", "l")
bush2 = wall_vert_w(1647, 0, 148, -3162, 223, "t", "l")
car1 = wall_vert_w(437, 0, 170, -916, -30, "t", "l")
shed_wall1 = wall_hori_w(0, 645, 13, 275, 1725, "t", "l")
shed_wall2 = wall_vert_w(328, 0, 13, 908, 1725, "t", "l")
shed_wall3 = wall_hori_w(0, 645, 13, 275, 2040, "t", "l")
shed_wall4 = wall_vert_w(35, 0, 5, 275, 1725, "t", "l")
shed_wall5 = wall_vert_w(28, 0, 5, 275, 2040, "b", "l")
start_car = wall_vert_w(437, 0, 370, 550, 50, "t", "l")
walls = [wall1,wall2,wall3,wall4,wall5,wall6,wall7,wall8,wall9,wall10,wall11,wall12,wall13,wall14,wall15,wall16,safe1,safe2,box1,box2,desk1,desk2,desk3,desk4,chair1,chair2,bush1,bush2,car1,shed_wall1,shed_wall2,shed_wall3,shed_wall4,shed_wall5,start_car]
wall_group = pygame.sprite.Group()
for i in walls:
wall_group.add(i)
return wall_group