-
Notifications
You must be signed in to change notification settings - Fork 2
/
Const.py
287 lines (252 loc) · 6.7 KB
/
Const.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
import pygame as pg
import os.path
# model
FPS = 60 # frame per second
GAME_LENGTH = 120 * FPS
PLAYER_INIT_POSITION = [pg.Vector2(100, 160), pg.Vector2(555, 0), pg.Vector2(555, 360), pg.Vector2(1000, 160)]
PLAYER_NUMBER = 4
PLAYER_WIDTH = 90
PLAYER_HEIGHT = 120
PLAYER_SHIFT_SPEED = 350
PLAYER_JUMP_SPEED = 300
PLAYER_SPEED_ADJUST = 0.8
PLAYER_GRAVITY = 300
PLAYER_FULL_BLOOD = 1000
PLAYER_COMMON_ATTACK_SIZE = 20 #additional size around player
PLAYER_COMMON_ATTACK_DAMAGE = 40
PLAYER_COMMON_ATTACK_DAMAGE_ADJUST = 2.5
PLAYER_SPECIAL_ATTACK_TIMER = 2.5 * FPS
PLAYER_COMMON_ATTACK_TIMER = 1 * FPS
PLAYER_SPECIAL_ATTACK_DELAY = 0.1 * FPS
SCORE_KILL_OTHER = 500
SCORE_NEVER_DIE = 1000
SCORE_HELLO_WORLD = 300
#item effect
ENERGY_MULTIPLE = 2 # multiple of accumulate energy speed affected by video card
CHARGE_BLOOD = 300
DIRECTION_TO_VEC2 = {
'up': pg.Vector2(0, -1),
'left': pg.Vector2(-1, 0),
'down': pg.Vector2(0, 1),
'right': pg.Vector2(1, 0),
}
#(left, top, width, height)
GROUND_POSITION = [
( 360, 160, 480, 40),
( 0, 360, 400, 40),
( 800, 360, 400, 40),
( 240, 560, 720, 40),
( 0, 760, 1200, 40)
]
GROUND_SIZE = 40
ITEM_WIDTH = 40
ITEM_HEIGHT = 40
ITEM_KEEP_LIST = [
'FAN',
'LIGHTNING',
'THROW_COFFEE',
'THROW_BUG',
'DOS',
'DDOS'
]
ITEM_TYPE_LIST = ['FAN',
'LIGHTNING',
'THROW_COFFEE',
'THROW_BUG',
'DOS',
'DDOS',
'EXE',
'USB',
'FIREWALL',
'GRAPHIC_CARD',
'FORMAT',
'FOLDER_UNUSED',
'CHARGE'
]
ITEM_GENERATE_VAL = {'FAN':5,
'LIGHTNING':5,
'THROW_COFFEE':5,
'THROW_BUG':4,
'DOS':5,
'DDOS':3,
'EXE':2,
'USB':5,
'FIREWALL':5,
'GRAPHIC_CARD':5,
'FORMAT':5,
'FOLDER_UNUSED':2,
'CHARGE':5
}
MAX_ITEM_NUMBER = 10
ITEM_GENERATOR_COOLDOWN = int(0.5 * FPS)
# special attack
SPECIAL_ATTACK_LIST = ['Arrow',
'Bug',
'Coffee',
'Fireball',
'Tornado',
'Lightning',
'Dos',
'Ddos',
'Throw_Bug',
'Throw_Coffee',
'Cast_Fireball',
'Cast_Tornado',
'Cast_Lightning',
]
ARROW_SPEED = 200
ARROW_SIZE = 25
DOS_ACTIVE_LIMIT = 10
DOS_DAMAGE = 15
DOS_TIMER = 20
DDOS_ACTIVE_LIMIT = 5
DDOS_DAMAGE = 15
DDOS_TIMER = 20
DDOS_RADIUS = 200
COFFEE_WIDTH = 40
COFFEE_HEIGHT = 40
COFFEE_DAMAGE = 150
COFFEE_GRAVITY = 500
COFFEE_THROW_SPEED = 600
BUG_WIDTH = 30
BUG_HEIGHT = 30
BUG_DAMAGE = 150
BUG_THROW_SPEED = 5
BUG_STRAIGHT_TIMER = 1 * FPS
BUG_RANDOM_TIMER = 4 * FPS
BUG_RANDOM_PERIOD = 10
FIREBALL_RADIUS = 30
FIREBALL_SPEED = 300
FIREBALL_DAMAGE = 150
TORNADO_WIDTH = 80
TORNADO_HEIGHT = 250
TORNADO_SPEED = 280
TORNADO_DAMAGE = 150
LIGHTNING_DAMAGE = 150
LIGHTNING_WIDTH = 70
LIGHTNING_HEIGHT = 100
LIGHTNING_TIMER = FPS // 2
# state time
INFECTED_TIME = 5 * FPS
INFECTED_COMMON_ATTACK_TIME = 2 * FPS
INVISIBLE_TIME = int(0.5 * FPS)
IN_FOLDER_TIME = 2 * FPS
SLOW_DOWN_TIME = 3 * FPS
BROKEN_TIME_COFFEE = 2 * FPS
BROKEN_TIME_BUG = 2 * FPS
FIREWALL_TIME = 8 * FPS
GRAPHIC_CARD_TIME = 4 * FPS
# State machine constants
STATE_POP = 0 # for convenience, not really a state which we can be in
STATE_MENU = 1
STATE_PLAY = 2
STATE_STOP = 3 # not implemented yet
STATE_ENDGAME = 4
STATE_TUTORIAL = 5
STATE_COLOR_SELECT = 6
# Path
IMAGE_PATH = os.path.join('View', 'assets')
SOUND_PATH = os.path.join('View', 'sound_effects')
BACKGROUND_MUSIC_PATH = os.path.join('View', 'background_music')
# Images
SPECIAL_ATTACK_KEEP_PICS = [
'prop_bug.png', 'prop_coffee.png',
'prop_ddos.png', 'prop_dos.png',
'prop_fan.png', 'prop_lightning.png',
]
SPECIAL_ATTACK_KEEP_TO_NUM = {
'THROW_BUG': 0, 'THROW_COFFEE': 1, 'DDOS': 2, 'DOS': 3, 'FAN': 4, 'LIGHTNING': 5
}
PROP_PICS = {
'FAN':'prop_fan.png',
'LIGHTNING':'prop_lightning.png',
'THROW_COFFEE':'prop_coffee.png',
'THROW_BUG':'prop_bug.png',
'DOS':'prop_dos.png',
'DDOS':'prop_ddos.png',
'EXE':'prop_hello_world.png',
'USB':'prop_usb.png',
'FIREWALL':'prop_firewall.png',
'GRAPHIC_CARD':'prop_graphic_card.png',
'FORMAT':'prop_format.png',
'FOLDER_UNUSED':'prop_directory.png',
'CHARGE':'prop_charge_line.png',
'PROP':'prop.png'
}
# view
WINDOW_CAPTION = 'Challenge 2021'
WINDOW_SIZE = (1200, 800)
ARENA_SIZE = (1200, 800)
BACKGROUND_COLOR = pg.Color('black')
PLAYER_COLOR = [(255,200,200), (200,255,200), (200,200,255), (230,220,220)]
PLAYER_COLOR_DRAWER = True
ATTACK_RANGE_COLOR = [pg.Color('lightgreen'), pg.Color('orchid1'), pg.Color('lightcyan'), pg.Color('whitesmoke')]
INVISIBLE_COLOR = pg.Color('gray')
BLOCK_COLOR = pg.Color('white')
ITEM_COLOR = pg.Color("purple")
ARROW_COLOR = pg.Color("red")
COFFEE_COLOR = pg.Color("brown")
BUG_COLOR = pg.Color("DarkOliveGreen")
HP_BAR_COLOR = [pg.Color('white'), pg.Color('green')]
ENERGY_BAR_COLOR = [pg.Color('white'), pg.Color('orange'), pg.Color('gray')]
ITEM_BOX_COLOR = pg.Color('brown')
ITEM_BOX_SIZE = 25
# controller
PLAYER_MOVE_KEYS = {
pg.K_a: (0, 'left'),
pg.K_d: (0, 'right'),
pg.K_f: (1, 'left'),
pg.K_h: (1, 'right'),
pg.K_j: (2, 'left'),
pg.K_l: (2, 'right'),
pg.K_LEFT: (3, 'left'),
pg.K_RIGHT: (3, 'right')
}
PLAYER_JUMP_KEYS = {
pg.K_w: (0, 'jump'),
pg.K_t: (1, 'jump'),
pg.K_i: (2, 'jump'),
pg.K_UP: (3, 'jump'),
}
PLAYER_ATTACK_KEYS = {
pg.K_s: (0, 'attack'),
pg.K_g: (1, 'attack'),
pg.K_k: (2, 'attack'),
pg.K_DOWN: (3, 'attack')
}
PLAYER_SPECIAL_ATTACK_KEYS = {
pg.K_q: (0, 'special_attack'),
pg.K_r: (1, 'special_attack'),
pg.K_u: (2, 'special_attack'),
pg.K_RSHIFT: (3, 'special_attack'),
}
GAME_STOP_KEY = pg.K_SPACE
GAME_CONTINUE_KEY = pg.K_RETURN
GAME_RESTART_KEY = pg.K_F5
GAME_FULLSCREEN_KEY = pg.K_F11
#Color Selection
COLOR_TABLE_SIZE = 11
COLOR_TABLE = (
(255, 128, 128),
(255, 71, 50),
(255, 133, 51),
(255, 219, 77),
(255, 255, 153),
(204, 255, 102),
#== second line ==
(255, 102, 255),
(187, 153, 255),
(128, 170, 255),
(102, 217, 255),
(153, 255, 204)
)
PLAYER_PICKER_COLOR = (
pg.Color('orange'),
pg.Color('red'),
pg.Color('green'),
pg.Color('blue'),
)
SCORE_PLAYING_SIZE = (200,48)
SCORE_PLAYING_STATE_SIZE = (40,40)
## API
API_TIMEOUT = 1/6/FPS