-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclasses.py
302 lines (284 loc) · 9.04 KB
/
classes.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
291
292
293
294
295
296
297
298
299
300
301
302
import pygame
from pygame.locals import *
'''
Purpose:
- To create keys that would be placed around the map
- Disappear upon contact
Parameter:
key_x: The horizontal location of the key
key:y: The vertical location of the key
Return:
- Keys that would be placed around the map and would disappear upon contact with the character
'''
class key(pygame.sprite.Sprite):
def __init__(self,key_x,key_y):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.image.load("key.gif").convert_alpha()
self.rect = self.image.get_rect()
self.rect.top = key_y
self.rect.left = key_x
def update(self,x,y):
self.rect.top += y
self.rect.left += x
'''
Purpose:
- To create drillss that would be placed around the map
- Disappear upon contact
Parameter:
key_x: The horizontal location of the drill
key:y: The vertical location of the drill
Return:
- Drill that would be placed around the map and would disappear upon contact with the character
'''
class drill(pygame.sprite.Sprite):
def __init__(self,drill_x,drill_y):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.image.load("drill.gif").convert_alpha()
self.rect = self.image.get_rect()
self.rect.top = drill_y
self.rect.left = drill_x
def update(self,x,y):
self.rect.top += y
self.rect.left += x
'''
Purpose:
- To create small icons around the map
- Disappear upon contact
Parameter:
photo: The image of the icon
x: The horizontal location of the icon
y: The vertical location of the icon
Return:
- Icons that would be placed around the map that could be clicked
'''
class icon(pygame.sprite.Sprite):
def __init__(self,photo,top,left):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.image.load(photo).convert()
self.rect = self.image.get_rect()
self.rect.top = top
self.rect.left = left
def update(self,x,y):
self.rect.top += y
self.rect.left += x
def get_sides(self):
left = self.rect.left
right = self.rect.right
top = self.rect.top
bottom = self.rect.bottom
return(left,right,top,bottom)
'''
Purpose:
- To display big charts of the small icons from the map so the player can read the papers
Parameter:
photo: The image of the big chart
Return:
- The big chart will draw onto the screen when the corresponding small icon is clicked so the player can read it
'''
class chart(pygame.sprite.Sprite):
def __init__(self,photo):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.image.load(photo).convert()
self.rect = self.image.get_rect()
self.rect.top = 0
self.rect.left = 0
def get_sides(self):
left = self.rect.left
right = self.rect.right
top = self.rect.top
bottom = self.rect.bottom
return(left,right,top,bottom)
'''
Purpose:
- To have a guard that would patrol the hall of the bank
Parameter:
N/A
Return:
- A guard will move along halls of the bank and will raise alarm if it touches the player
'''
class guard(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.Surface((285,285)).convert()
self.image.set_alpha(50)
self.image.fill((255,255,0))
self.rect = self.image.get_rect()
self.rect.top = 615
self.rect.left = -1600
def update(self,x,y,guard_x,guard_y):
self.rect.top += y + guard_y
self.rect.left += x + guard_x
'''
Purpose:
- To create ghosts that would stalk the player
Parameter:
x: The original horizontal location of the ghost
y: The original vertical location of the ghost
Return:
- A ghost that follows the player around whereever he/she goes
'''
class ghost(pygame.sprite.Sprite):
def __init__(self,x,y):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.image.load("ghost.gif").convert_alpha()
self.image.set_alpha(50)
self.rect = self.image.get_rect()
self.rect.top = y
self.rect.left = x
def update(self,x,y):
self.rect.top += y
self.rect.left += x
def center(self):
return self.rect.center
'''
Purpose:
- To create an area
- When the player enters it, a sound would play
Parameter:
N/A
Return:
- An area on the map that emits a specific sound when the player collides with it
'''
class sound_Zone(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.Surface((940,380)).convert()
self.image.set_alpha(0)
self.image.fill((0,0,0))
self.rect = self.image.get_rect()
self.rect.top = 225
self.rect.left = -2125
def update(self,x,y):
self.rect.top += y
self.rect.left += x
'''
Purpose:
- To create an area
- Gold will draw in this area when the player opens the safe
Parameter:
N/A
Return:
rect.left: The left side of the area
rect.right: the right side of the area
rect.top: The top side of the area
rect.bottom: The bottom side of the area
- An area that will display gold in its dimensions when the safe is opened
'''
class win_Zone(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.Surface((230,230)).convert()
self.image.set_alpha(0)
self.image.fill((0,0,0))
self.rect = self.image.get_rect()
self.rect.top = 470
self.rect.right = -2230
def update(self,x,y):
self.rect.top += y
self.rect.left += x
def sides(self):
return(self.rect.left,self.rect.right,self.rect.top,self.rect.bottom)
'''
Purpose:
- To create an area
- Special events would occur
Parameter:
width: The width of the area
height: The height of the area
x: The horizontal location of the area
y: The vertical location of the area
Return:
- An area where special events like enter a code or drilling a safe occur is made
'''
class safe_Zone(pygame.sprite.Sprite):
def __init__(self,width,height,x,y):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.Surface((width,height)).convert()
self.image.set_alpha(0)
self.image.fill((0,0,0))
self.rect = self.image.get_rect()
self.rect.bottom = x
self.rect.right = y
def update(self,x,y):
self.rect.bottom += y
self.rect.right += x
def left(self):
return self.rect.left
def center(self):
return self.rect.center
'''
Purpose:
- To create an area
- Special events would occur
Parameter:
width: The width of the area
height: The height of the area
x: The horizontal location of the area
y: The vertical location of the area
Return:
- An area where special events like enter a code or drilling a safe occur is made
'''
class leave(pygame.sprite.Sprite):
def __init__(self,name,x,y):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.image.load(name).convert()
self.rect = self.image.get_rect()
self.rect.center = (x,y)
def get_sides(self):
return(self.rect.left,self.rect.right,self.rect.top,self.rect.bottom)
'''
Purpose:
- To create an area
- To create the class for the quit button
- Return the sides of the button
Parameter:
width: The width of the area
height: The height of the area
x: The horizontal location of the area
y: The vertical location of the area
Return:
- An area where special events like enter a code or drilling a safe occur is made or click region
'''
class quit(pygame.sprite.Sprite):
def __init__(self,name,x,y):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.image.load(name).convert()
self.rect = self.image.get_rect()
self.rect.left = (x)
self.rect.top = (y)
def get_sides(self):
return(self.rect.left,self.rect.right,self.rect.top,self.rect.bottom)
'''
Purpose:
- To display the background photo of the game
Parameter:
N/A
Return:
- The window is pasted with the background photo
'''
class board(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.image.load("maison.jpg").convert()
self.rect = self.image.get_rect()
self.rect.center = (-1500,1000)
def update(self,x,y):
self.rect.top +=y
self.rect.left +=x
'''
Purpose:
- To display a flashed background photo when there is lightning
Parameter:
N/A
Return:
- The flashed background photo is pasted onto the window when lightning is triggered
'''
class board_flash(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite. __init__(self)
self.image = pygame.image.load("maison_flash.jpg").convert()
self.rect = self.image.get_rect()
self.rect.center = (-1500,1000)
def update(self,x,y):
self.rect.top +=y
self.rect.left +=x