-
Notifications
You must be signed in to change notification settings - Fork 2
/
game (mod version).py
571 lines (455 loc) · 17.2 KB
/
game (mod version).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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
from player import Player
from enemy import *
from proj import Missile,Missile2
from info import Info,Pen
from images import Images
from maps import*
from intro import Intro
from item import*
import turtle
import math
import random
import time
import winsound
for image in Images:
turtle.register_shape(image)
#intro screen
#------------------------------
Intro()
#main screen
#------------------------------
wn = turtle.Screen()
wn.bgcolor("black")
wn.title("7 Dungeons Deep (7DD)")
wn.setup(1900,930)
wn.bgpic(".\\art\\background.gif")
wn.tracer(0)
particles = []
for i in range(15):
particles.append(Particle("circle", "red", 0, 0))
mission=0
lives=0
quests2=[]
quests=[]
quest_items=[]
armourupgrade=0
weaponupgrade=0
crowns=[]
enemies2 =[]
enemies =[]
coins =[]
doors =[]
healings=[]
fake_walls=[]
npcs=[]
firescrolls=[]
swords=[]
armours=[]
walls=[]
Enemy.walls = walls
levels = [""]
levels.append(level_1)
levels.append(level_2)
levels.append(level_3)
levels.append(level_4)
levels.append(level_5)
levels.append(level_6)
levels.append(level_7)
levels.append(level_8)
#row are y ( up/down) column are x (left and right )
#
def setup_maze(level):
for y in range (len(level)): #tell how many rows there is
for x in range(len(level[y])): # acquire every x of the y row
#Get the character at each x,y coordinate
#NOTE the order of Y AND X in the next line
character = level [y][x]
#Calculate the screen x,y coordinates. Furtherest left upper corner is (0,0)
screen_x = -350 + (x*24)
screen_y = 288 - (y*24)
#check if it is an x represent a wall
if character == "X":
pen.goto(screen_x, screen_y)
pen.shape(".\\art\\wall.gif")
pen.stamp()
walls.append((screen_x,screen_y))
if character == "T":
pen.goto(screen_x, screen_y)
pen.shape(".\\art\\torch.gif")
pen.stamp()
walls.append((screen_x,screen_y))
if character == "Y":
pen.goto(screen_x, screen_y)
pen.shape(".\\art\\skeleton.gif")
pen.stamp()
walls.append((screen_x,screen_y))
if character == "G":
pen.goto(screen_x, screen_y)
pen.shape(".\\art\\tree.gif")
pen.stamp()
walls.append((screen_x,screen_y))
if character == "R":
pen.goto(screen_x, screen_y)
pen.shape(".\\art\\rock.gif")
pen.stamp()
walls.append((screen_x,screen_y))
if character == "V":
pen.goto(screen_x, screen_y)
pen.shape(".\\art\\cage.gif")
pen.stamp()
walls.append((screen_x,screen_y))
if character == "P": # p= player
player.goto(screen_x, screen_y)
if character == "C":
coins.append(Coin(screen_x, screen_y))
if character =="E":
enemies.append(Orc(screen_x, screen_y))
if character =="D":
doors.append(Door(screen_x, screen_y))
if character =="M":
crowns.append(Crown(screen_x, screen_y))
if character =="H":
healings.append(Healing(screen_x, screen_y))
if character =="F":
firescrolls.append(Firescroll(screen_x, screen_y))
if character =="A":
armours.append(Armour(screen_x, screen_y))
if character =="S":
swords.append(Sword(screen_x, screen_y))
if character =="Z":
enemies.append(Zombie(screen_x, screen_y))
if character =="N":
npcs.append(Npc(screen_x, screen_y))
if character =="Q":
quests.append(Quest(screen_x, screen_y))
if character =="B":
quest_items.append(Quest_item(screen_x, screen_y))
if character =="I":
fake_walls.append(Fake_wall(screen_x, screen_y))
if character =="J":
enemies.append(Boss(screen_x, screen_y))
if character =="L":
enemies.append(Ghost(screen_x, screen_y))
if character =="K":
quests2.append(Quest2(screen_x, screen_y))
pen=Pen()
player= Player()
Enemy.hero = player
missile = Missile(0,0,player)
missile2 = Missile2(0,0,player)
setup_maze(levels[1])
maze=("level1")
# Reason why there is both info and game, at some point when i had one it just
#stopped working
info=Info()
game=Info()
game.draw_border()
game.draw_border2()
game.draw_border3()
game.draw_border4()
game.show_rules()
game.show_gold()
game.show_armour()
game.show_weapon()
info.show_health()
info.show_strength()
info.show_level()
info.show_healthpotion()
info.show_fire_scroll()
info.show_exp()
info.show_defense()
#keyboard binding, onkey only takes 1 augment so to get around this we use lambda which will create a function within the function so it express as only 1 augement.
turtle.listen()
turtle.onkey((lambda:player.go_left(walls)), "Left")
turtle.onkey((lambda:player.go_right(walls)), "Right")
turtle.onkey((lambda:player.go_up(walls)), "Up")
turtle.onkey((lambda:player.go_down(walls)), "Down")
turtle.onkey((lambda:player.headright(missile,lives)), "d")
turtle.onkey((lambda:player.headleft(missile,lives)), "a")
turtle.onkey((lambda:player.headdown(missile,lives)),"s")
turtle.onkey((lambda:player.headup(missile,lives)),"w")
turtle.onkey((lambda:player.headright(missile,lives)),"D")
turtle.onkey((lambda:player.headleft(missile,lives)), "A")
turtle.onkey((lambda:player.headdown(missile,lives)),"S")
turtle.onkey((lambda:player.headup(missile,lives)),"W")
turtle.onkey((lambda:player.drink(info)),"space")
turtle.onkey((lambda:player.fireball(missile2,info,lives)),"z")
turtle.onkey((lambda:player.fireball(missile2,info,lives)),"Z")
for enemy in enemies:
turtle.ontimer(enemy.move,t=250)
while True:
missile.move(player,walls)
missile2.move(player,walls)
for particle in particles:
particle.move()
for armour in armours:
if player.is_collision(armour):
armour.destroy()
if armourupgrade==1:
info.armourstats+=4
game.armour=("Mythril Plate")
game.show_armour()
info.show_defense()
armourupgrade+=1
winsound.PlaySound(".\\sound\\armour.wav", winsound.SND_ASYNC)
if armourupgrade==0:
info.armourstats+=6
game.armour=("Steel Plate")
game.show_armour()
info.show_defense()
armourupgrade+=1
winsound.PlaySound(".\\sound\\armour.wav", winsound.SND_ASYNC)
for npc in npcs:
if player.is_collision(npc):
game.intro()
Npc.destroy(npc)
for quest in quests:
if player.is_collision2(quest):
if mission ==0:
game.start()
if mission ==1:
game.end()
info.exp+=quest.exp
info.show_exp()
Quest.destroy(quest)
for quest2 in quests2:
if player.is_collision2(quest2):
if info.boss ==0:
game.start2()
if info.boss ==1:
game.end2()
info.exp+=200
info.show_exp()
Quest.destroy(quest2)
for quest_item in quest_items:
if player.is_collision(quest_item):
mission=1
Quest_item.destroy(quest_item)
winsound.PlaySound(".\\sound\\key.wav", winsound.SND_ASYNC)
for sword in swords:
if player.is_collision(sword):
sword.destroy()
if weaponupgrade==1:
info.weaponstats+=4
game.weapon=("Mythril Sword")
game.show_weapon()
info.show_strength()
weaponupgrade+=1
winsound.PlaySound(".\\sound\\sword.wav", winsound.SND_ASYNC)
if weaponupgrade==0:
info.weaponstats+=6
game.weapon=("Steel Sword")
game.show_weapon()
info.show_strength()
weaponupgrade+=1
winsound.PlaySound(".\\sound\\sword.wav", winsound.SND_ASYNC)
for firescroll in firescrolls:
if player.is_collision(firescroll):
firescroll.destroy()
info.fire_scroll+=1
info.show_fire_scroll()
winsound.PlaySound(".\\sound\\scroll.wav", winsound.SND_ASYNC)
for healing in healings:
if player.is_collision(healing):
healing.destroy()
info.potion+=1
info.show_healthpotion()
winsound.PlaySound(".\\sound\\potion.wav", winsound.SND_ASYNC)
for crown in crowns:
if player.is_collision(crown):
#winsound.PlaySound(".\\sound\\victory.wav",0)
player.destroy()
crown.destroy()
crowns.remove(crown)
lives=3
game.win(player)
for enemy in enemies:
if missile.is_collision(enemy):
enemy.hp -= (info.strength+info.weaponstats)
missile.status = "ready"
winsound.PlaySound(".\\sound\\orkdeath.wav", winsound.SND_ASYNC)
if missile2.is_collision(enemy):
enemy.hp -= missile2.damage
missile2.status = "ready"
winsound.PlaySound(".\\sound\\orkdeath.wav", winsound.SND_ASYNC)
if enemy.hp<=0 and enemy.alive==True:
enemy.alive=False
Enemy.destroy(enemy)
missile.status = "ready"
info.exp += enemy.exp
info.boss+=enemy.boss
player.kill+=1
info.show_exp()
winsound.PlaySound(".\\sound\\orkdeath.wav", winsound.SND_ASYNC)
if info.exp>70 and info.level2_claimed:
info.hp=1100
info.fullhp=1100
info.strength=20
info.defense=4
info.level=2
info.level2_claimed = False
info.show_defense()
info.show_health()
info.show_strength()
info.show_level()
winsound.PlaySound(".\\sound\\levelup.wav", winsound.SND_ASYNC)
time.sleep(1)
if info.exp>150 and info.level3_claimed:
info.hp=1200
info.fullhp=1200
info.strength=25
info.defense=8
info.level=3
info.level3_claimed = False
info.show_defense()
info.show_health()
info.show_strength()
info.show_level()
winsound.PlaySound(".\\sound\\levelup.wav", winsound.SND_ASYNC)
time.sleep(1)
if info.exp>300 and info.level4_claimed:
info.hp=1300
info.fullhp=1300
info.strength=30
info.defense=12
info.level=4
info.level4_claimed = False
info.show_defense()
info.show_health()
info.show_strength()
info.show_level()
winsound.PlaySound(".\\sound\\levelup.wav", winsound.SND_ASYNC)
time.sleep(1)
if info.exp>450 and info.level5_claimed:
info.hp=1500
info.fullhp=1500
info.strength=40
info.defense=20
info.level=5
info.level5_claimed = False
info.show_defense()
info.show_health()
info.show_strength()
info.show_level()
winsound.PlaySound(".\\sound\\levelup.wav", winsound.SND_ASYNC)
time.sleep(1)
if info.exp>700 and info.level6_claimed:
info.hp=1700
info.fullhp=1700
info.strength=60
info.defense=25
info.level=6
info.level6_claimed = False
info.show_defense()
info.show_health()
info.show_strength()
info.show_level()
winsound.PlaySound(".\\sound\\levelup.wav", winsound.SND_ASYNC)
time.sleep(1)
if info.exp>950 and info.level7_claimed:
info.hp=2000
info.fullhp=2000
info.strength=80
info.defense=30
info.level=7
info.level7_claimed = False
info.show_defense()
info.show_health()
info.show_strength()
info.show_level()
winsound.PlaySound(".\\sound\\levelup.wav", winsound.SND_ASYNC)
time.sleep(1)
if info.exp>1400 and info.level8_claimed:
info.hp=2200
info.fullhp=2200
info.strength=100
info.defense=50
info.level=8
info.level8_claimed = False
info.show_defense()
info.show_health()
info.show_strength()
info.show_level()
winsound.PlaySound(".\\sound\\levelup.wav", winsound.SND_ASYNC)
time.sleep(1)
for coin in coins:
if player.is_collision(coin):
game.gold += coin.gold
game.show_gold()
#print("Player Gold: {}".format (game.gold))
coin.destroy()
coins.remove(coin)
winsound.PlaySound(".\\sound\\coin.wav", winsound.SND_ASYNC)
for enemy in enemies:
if player.is_collision(enemy):
attack=enemy.damage
reduce_damage=attack-(info.defense+game.armourstats)
if reduce_damage <0 :
reduce_damage=0
info.hp-=reduce_damage
info.show_health()
for particle in particles:
particle.explode(player.xcor(), player.ycor())
for door in doors:
if player.is_collision(door):
walls.clear()
pen.clear()
wn.bgpic(".\\art\\black.gif")
for enemy in enemies:
Enemy.destroy(enemy)
for coin in coins:
Coin.destroy(coin)
for door in doors:
Door.destroy(door)
for armour in armours:
Armour.destroy(armour)
for sword in swords:
Sword.destroy(sword)
for healing in healings:
Healing.destroy(healing)
for firescroll in firescrolls:
Firescroll.destroy(firescroll)
for npc in npcs:
Npc.destroy(npc)
for quest in quests:
Quest.destroy(quest)
for quest_item in quest_items:
Quest_item.destroy(quest_item)
for fake_wall in fake_walls:
Fake_wall.destroy(fake_wall)
for quest2 in quests2:
Quest2.destroy(quest2)
winsound.PlaySound(".\\sound\\unlock.wav", winsound.SND_ASYNC)
if maze==("level1"):
setup_maze(levels[2])
maze=("level2")
elif maze ==("level2"):
setup_maze(levels[3])
maze=("level3")
elif maze==("level3"):
setup_maze(levels[4])
maze=("level4")
elif maze==("level4"):
setup_maze(levels[5])
maze=("level5")
elif maze==("level5"):
setup_maze(levels[6])
maze=("level6")
elif maze==("level6"):
setup_maze(levels[7])
maze=("level7")
elif maze==("level7"):
setup_maze(levels[8])
maze=("level8")
else:
pass
for enemy in enemies:
turtle.ontimer(enemy.move,t=250)
if info.hp<=0:
game.dead()
player.destroy()
winsound.PlaySound(".\\sound\\death.wav", winsound.SND_ASYNC)
time.sleep(2)
info.show_health()
break
wn.update()