-
Notifications
You must be signed in to change notification settings - Fork 0
/
12bonesdoomv1n.py
439 lines (373 loc) · 18.1 KB
/
12bonesdoomv1n.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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
## 12 Bones of Doom V001m
## Import and Initialize ###
import pygame
import time
import random
pygame.init()
#######################
## Display and Audio File Load ##
display_width = 800
display_height = 600
splash = pygame.image.load('skull2.png')
sword_fight = pygame.mixer.Sound("sword_fight.wav")
sword_clash = pygame.mixer.Sound("sword_clash.wav")
magic_blast = pygame.mixer.Sound("magic_blast.wav")
pygame.mixer.music.load('fugedmin.mid')
#######################
## Color Pallet #######
black = (0,0,0)
white = (255,255,255)
red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)
purple = (100,0,100)
orange = (255,100,0)
yellow = (200,200,0)
light_gray = (210,210,210)
dark_gray = (20,20,29)
########################
## Display Manifest ##################################################
gameDisplay = pygame.display.set_mode((display_width,display_height),pygame.FULLSCREEN)
pygame.display.set_caption("Twelve Bones of Doom")
clock = pygame.time.Clock()
######################################################################
def text_objects_white (text, font):
textSurface = font.render(text, True,white) # text color
return textSurface, textSurface.get_rect()
def text_objects_black (text, font):
textSurface = font.render(text, True,black) # text color
return textSurface, textSurface.get_rect()
def print_smtxt_white(text, x_pos, y_pos):
smallText = pygame.font.Font('week.TTF',18)
TextSurf, TextRect = text_objects_white(text, smallText)
TextRect.center = ((x_pos),(y_pos))
gameDisplay.blit(TextSurf, TextRect)
def print_smtxt_black(text, x_pos, y_pos):
smallText = pygame.font.Font('week.TTF',18)
TextSurf, TextRect = text_objects_black(text, smallText)
TextRect.center = ((x_pos),(y_pos))
gameDisplay.blit(TextSurf, TextRect)
def text_objects(text, font):
textSurface = font.render(text, True,red) # text color
return textSurface, textSurface.get_rect()
def print_lgtxt (text,y_pos): #Centered Text
largeText = pygame.font.Font('week.TTF',90)
TextSurf, TextRect = text_objects(text, largeText)
TextRect.center = ((display_width/2),(y_pos))
gameDisplay.blit(TextSurf, TextRect)
def print_smtxt(text, y_pos):
smallText = pygame.font.Font('week.TTF',18)
TextSurf, TextRect = text_objects(text, smallText)
TextRect.center = ((display_width/2),(y_pos))
gameDisplay.blit(TextSurf, TextRect)
def print_mdtxt(text, y_pos):
medText = pygame.font.Font('week.TTF',40)
TextSurf, TextRect = text_objects(text, medText)
TextRect.center = ((display_width/2),(y_pos))
gameDisplay.blit(TextSurf, TextRect)
def game_intro():
gameIntro = True
pygame.mixer.music.play(-1)
while gameIntro:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
game_quit ()
if event.key == pygame.K_p:
main_menu ()
gameDisplay.blit(splash,(10,10))
print_smtxt ("The Most Terrifyting RPG You Can Play !",580)
print_smtxt ("Press (p) To PLay",540)
pygame.display.update()
clock.tick(30)
def main_menu ():
mainMenu = True
while mainMenu:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
game_quit ()
if event.key == pygame.K_p:
game_play ()
gameDisplay.fill (dark_gray)
print_lgtxt ("Main Menu",50)
print_mdtxt ("(P) Play Game (Q) Quit Game",200)
pygame.display.update()
clock.tick(30)
def game_quit ():
pygame.quit()
quit ()
def game_play ():
pygame.mixer.music.stop()
## Create Enemy
enemy_l1 = ['Giant Spider','Giant Centipede','Giant Scorpian', 'Giant Rat', 'Jr. Troll']
enemy_species = (random.choice(enemy_l1))
## magic_attack=0
if enemy_species == 'Giant Rat':
enemy_health = random.randrange(15, 30)
enemy_strength = random.randrange(4,10)
enemy_armor = random.randrange(1,5)
enemy_magic = 0
enemy_wisdom = random.randrange(1,3)
enemy_charisma = random.randrange(1,2)
enemy_const = random.randrange(2,7)
enemy_pic = pygame.image.load('giantrat.png')
if enemy_species == 'Giant Spider':
enemy_health = random.randrange(5, 10)
enemy_strength = random.randrange(4,12)
enemy_armor = 1
enemy_magic = 1
enemy_wisdom = 3
enemy_charisma = 1
enemy_const = 1
enemy_pic = pygame.image.load('giantspider.png')
if enemy_species == 'Jr. Troll':
enemy_health = random.randrange(20, 40)
enemy_strength = random.randrange(4,10)
enemy_armor = 10
enemy_magic = 1
enemy_wisdom = 3
enemy_charisma = 1
enemy_const = 1
enemy_pic = pygame.image.load('jrtroll.png')
if enemy_species == 'Giant Centipede':
enemy_health = random.randrange(25, 50)
enemy_strength = random.randrange(6,13)
enemy_armor = 15
enemy_magic = 1
enemy_wisdom = 3
enemy_charisma = 1
enemy_const = 1
enemy_pic = pygame.image.load('centepede.png')
if enemy_species == 'Giant Scorpian':
enemy_health = random.randrange(30, 60)
enemy_strength = random.randrange(8,15)
enemy_armor = random.randrange(4, 10)
enemy_magic = 0
enemy_wisdom = random.randrange(1,3)
enemy_charisma = 0
enemy_const = random.randrange(4,10)
enemy_pic = pygame.image.load('giantscorpian.jpeg')
## End Enemy Creator
## Hero Creator
hero_class = ['Fighter', 'Mage', 'Ranger','Thief','Paladin','Shaman']
hero_type = (random.choice(hero_class))
hero_health = random.randrange(60,100)
hero_strength = random.randrange(3,10)
hero_armor = random.randrange(3,6)
hero_magic = random.randrange(0,10)
hero_wisdom = random.randrange(6,13)
hero_charisma = random.randrange(8,20)
hero_const = random.randrange(4,9)
hero_potions = 3
hero_pic = pygame.image.load('herom.png')
## End Hero Creator
gamePlaying = True
while gamePlaying:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
main_menu ()
if event.key==pygame.K_a:
## Attack
pygame.mixer.Sound.play(sword_clash)
attack_damage = hero_strength
new_ehealth = enemy_health - attack_damage
enemy_health=new_ehealth
## Counter Attack
enemy_damage=enemy_strength
new_hero_health = hero_health - enemy_damage + hero_armor
hero_health = new_hero_health
if enemy_health < 1:
gameDisplay.fill (yellow)
print_lgtxt ("Enemy Defeated !",285)
pygame.display.update()
pygame.time.delay(2000)
gameDisplay.fill (yellow)
print_lgtxt ("Creating Enemy!",285)
pygame.display.update()
pygame.time.delay(2000)
## Enemy CREATOR
enemy_l1 = ['Giant Spider','Giant Centipede','Giant Scorpian', 'Giant Rat', 'Jr. Troll']
enemy_species = (random.choice(enemy_l1))
## magic_attack=0
if enemy_species == 'Giant Rat':
enemy_health = random.randrange(15, 30)
enemy_strength = random.randrange(4,10)
enemy_armor = random.randrange(1,5)
enemy_magic = 0
enemy_wisdom = random.randrange(1,3)
enemy_charisma = random.randrange(1,2)
enemy_const = random.randrange(2,7)
enemy_pic = pygame.image.load('giantrat.png')
if enemy_species == 'Giant Spider':
enemy_health = random.randrange(5, 10)
enemy_strength = random.randrange(4,12)
enemy_armor = 1
enemy_magic = 1
enemy_wisdom = 3
enemy_charisma = 1
enemy_const = 1
enemy_pic = pygame.image.load('giantspider.png')
if enemy_species == 'Jr. Troll':
enemy_health = random.randrange(20, 40)
enemy_strength = random.randrange(4,10)
enemy_armor = 10
enemy_magic = 1
enemy_wisdom = 3
enemy_charisma = 1
enemy_const = 1
enemy_pic = pygame.image.load('jrtroll.png')
if enemy_species == 'Giant Centipede':
enemy_health = random.randrange(25, 50)
enemy_strength = random.randrange(6,13)
enemy_armor = 15
enemy_magic = 1
enemy_wisdom = 3
enemy_charisma = 1
enemy_const = 1
enemy_pic = pygame.image.load('centepede.png')
if enemy_species == 'Giant Scorpian':
enemy_health = random.randrange(30, 60)
enemy_strength = random.randrange(8,15)
enemy_armor = random.randrange(4, 10)
enemy_magic = 0
enemy_wisdom = random.randrange(1,3)
enemy_charisma = 0
enemy_const = random.randrange(4,10)
enemy_pic = pygame.image.load('giantscorpian.jpeg')
## End Enemy Creator
if hero_health < 1:
gameDisplay.fill(yellow)
print_lgtxt("You Died!", 285)
pygame.display.update()
pygame.time.delay(4000)
main_menu()
if event.key==pygame.K_s: # Cast Spell
if hero_magic < 5:
gameDisplay.fill(dark_gray)
print_mdtxt("You Can Not", 285)
print_mdtxt("Use Magic" , 365)
pygame.display.update()
pygame.time.delay(2000)
## Cast Magic Spell
if hero_magic > 4:
pygame.mixer.Sound.play(magic_blast)
magic_attack = hero_magic
new_ehealth = enemy_health - magic_attack
enemy_health=new_ehealth
gameDisplay.fill(dark_gray)
print_mdtxt("You Cast Lightning", 285)
print_mdtxt("It does " + str(magic_attack) + " Damage", 365)
pygame.display.update()
pygame.time.delay(2000)
if enemy_health < 1:
gameDisplay.fill (yellow)
print_lgtxt ("Enemy Defeated !",285)
pygame.display.update()
pygame.time.delay(2000)
## Enemy CREATOR
gameDisplay.fill (yellow)
print_lgtxt ("Creating Enemy!",285)
pygame.display.update()
pygame.time.delay(2000)
enemy_l1 = ['Giant Spider','Giant Centipede','Giant Scorpian', 'Giant Rat', 'Jr. Troll']
enemy_species = (random.choice(enemy_l1))
if enemy_species == 'Giant Rat':
enemy_health = random.randrange(15, 30)
enemy_strength = random.randrange(4,10)
enemy_armor = random.randrange(1,5)
enemy_magic = 0
enemy_wisdom = random.randrange(1,3)
enemy_charisma = random.randrange(1,2)
enemy_const = random.randrange(2,7)
enemy_pic = pygame.image.load('giantrat.png')
if enemy_species == 'Jr. Troll':
enemy_health = random.randrange(20, 40)
enemy_strength = random.randrange(4,10)
enemy_armor = 10
enemy_magic = 1
enemy_wisdom = 3
enemy_charisma = 1
enemy_const = 1
enemy_pic = pygame.image.load('jrtroll.png')
if enemy_species == 'Giant Centipede':
enemy_health = random.randrange(25, 50)
enemy_strength = random.randrange(6,13)
enemy_armor = 15
enemy_magic = 1
enemy_wisdom = 3
enemy_charisma = 1
enemy_const = 1
enemy_pic = pygame.image.load('centepede.png')
if enemy_species == 'Giant Scorpian':
enemy_health = random.randrange(30, 60)
enemy_strength = random.randrange(8,15)
enemy_armor = random.randrange(4, 10)
enemy_magic = 0
enemy_wisdom = random.randrange(1,3)
enemy_charisma = 0
enemy_const = random.randrange(4,10)
enemy_pic = pygame.image.load('giantscorpian.jpeg')
## End Enemy Creator
if hero_health < 1:
gameDisplay.fill(yellow)
print_lgtxt("You Died!", 285)
pygame.display.update()
pygame.time.delay(2000)
main_menu()
## Render Menu
gameDisplay.fill (dark_gray)
print_mdtxt("12 Bones of Doom",60)
## Hero Pic
pygame.draw.rect(gameDisplay, light_gray, [25, 150, 120, 200])
## Hero Data Box
pygame.draw.rect(gameDisplay, yellow, [155, 150, 240,200])
## Enemy Picture box
pygame.draw.rect(gameDisplay, light_gray, [415, 150, 120,200])
## Enemy Data Box
pygame.draw.rect(gameDisplay, yellow, [545, 150, 240,200])
## Command Screen
pygame.draw.rect(gameDisplay, black, [25,375,765,200])
print_smtxt_white("Command Screen:", 100,400)
print_smtxt_white("a = Attack", 75,425)
print_smtxt_white("s = Cast Spell", 90,450)
print_smtxt_white("h = Heal Potion", 95,475)
print_smtxt_white("q = Quit Game", 95,500)
## Enemy Data and Display
print_smtxt_black(enemy_species,630, 160)
print_smtxt_black("Health: " + str(enemy_health), 593,180)
print_smtxt_black("Strength: " + str(enemy_strength),602,200)
print_smtxt_black("Armor: " + str(enemy_armor),586,220)
print_smtxt_black("Magic: " + str(enemy_magic),586,240)
print_smtxt_black("Wisdom: " + str(enemy_wisdom),589,260)
print_smtxt_black("Charisma: " + str(enemy_charisma),602,280)
print_smtxt_black("Const: " + str(enemy_const),586,300)
gameDisplay.blit(enemy_pic,(415,150))
## Hero data and display
print_smtxt_black(hero_type,200,160)
print_smtxt_black("Health: " + str(hero_health), 200,180)
print_smtxt_black("Strength: " + str(hero_strength),200,200)
print_smtxt_black("Armor: " + str(hero_armor),200,220)
print_smtxt_black("Magic: " + str(hero_magic),200,240)
print_smtxt_black("Wisdom: " + str(hero_wisdom),200,260)
print_smtxt_black("Charisma: " + str(hero_charisma),200,280)
print_smtxt_black("Const: " + str(hero_const),200,300)
gameDisplay.blit(hero_pic, (25,150))
## Refresh Screen
pygame.display.update()
clock.tick(30)
## Run Game
game_intro()
## End Game
pygame.quit()
quit()