-
Notifications
You must be signed in to change notification settings - Fork 1
/
fullGame.py
1857 lines (1659 loc) · 93.4 KB
/
fullGame.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
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#mainGame
from pygame import *
from math import *
from random import *
#basic colours
RED=(255,0,0)
GREEN=(0,255,0)
BLUE=(0,0,255)
BLACK=(0,0,0)
WHITE=(255,255,255)
YELLOW=(255,255,0)
init()
#load pictures
mainMenu=image.load("FSE-Assets/mainscreen.jpg")
credMenu=image.load("FSE-Assets/credits.jpg")
instructMenu=image.load("FSE-Assets/instructions.jpg")
levelSelectMenu=image.load("FSE-Assets/levelSelect.jpg")
cross=image.load("FSE-Assets/cross.png")
hudimg=image.load("FSE-Assets/hud.jpg")
hudRect=image.load("FSE-Assets/hudRect.png")
readyPic=image.load("FSE-Assets/readyRect.jpg")
quitP=image.load("FSE-Assets/quitRect.png")
dialogueP=image.load("FSE-Assets/dialogueRect.png")
cancelPic=image.load("FSE-Assets/cancelRect.png")
deletePic=image.load("FSE-Assets/deleteRect.png")
mutePic=image.load("FSE-Assets/musicPicMUTE.png")
eigthNote=image.load("FSE-Assets/musicPic.png")
blackHeart=image.load("FSE-Assets/blackHeart.png")
loseRect=image.load("FSE-Assets/loseRect.png")
pressToStart=image.load("FSE-Assets/previews/pushtostart.png")
muzzleFlash=image.load("FSE-Assets/muzzleFlash.png")
wreck=image.load("FSE-Assets/wreckage.png")
dead=image.load("FSE-Assets/enemies/dead.png")
victoryRect=image.load("FSE-Assets/victoryRect.png")
sureRect=image.load("FSE-Assets/sureRect.png")
finalLevel=image.load("FSE-Assets/finalLevel.png")
txtFont=font.SysFont("FSE-Assets/fonts/kremlin.ttf",25)
txtFont2=font.SysFont("Stencil",17)
txtFont3=font.SysFont("Stencil",20)
txtFont4=font.SysFont("Stencil",35)
#loading map previews
pr1=image.load("FSE-Assets/previews/lvl1prev.jpg")
pr2=image.load("FSE-Assets/previews/lvl2prev.jpg")
pr3=image.load("FSE-Assets/previews/lvl3prev.jpg")
pr4=image.load("FSE-Assets/previews/lvl4prev.jpg")
pr5=image.load("FSE-Assets/previews/lvl5prev.jpg")
#loading maps
map1=image.load("FSE-Assets/Maps/map1.jpg")
map2=image.load("FSE-Assets/Maps/map2.jpg")
map3=image.load("FSE-Assets/Maps/map3.jpg")
map4=image.load("FSE-Assets/Maps/map4.jpg")
map5=image.load("FSE-Assets/Maps/map5.jpg")
#transform pictures
hud=transform.scale(hudimg,(500,75))
hudRects=transform.scale(hudRect,(200,95))
quitPic=transform.scale(quitP,(150,40))
crossPic=transform.scale(cross,(30,30))
dialoguePic=transform.scale(dialogueP,(400,110))
blackHeart=transform.scale(blackHeart,(25,25))
mutePic=transform.scale(mutePic,(37,35))
eigthNote=transform.scale(eigthNote,(37,35))
#sounds
mixer.init()
place_sound = mixer.Sound("FSE-Assets/sound/placeSound.wav")
gun_sound = mixer.Sound("FSE-Assets/sound/gunShot.wav")
cannon_sound = mixer.Sound("FSE-Assets/sound/gunShotCannon.wav")
remove_sound = mixer.Sound(("FSE-Assets/sound/removeSound.wav"))
explosion_sound = mixer.Sound(("FSE-Assets/sound/explosion.wav"))
money=0 #the starting amount of money you have
score=0 #your starting score
pause=False #if the music is paused or not, starts off paused.
#this is the first class which defines all the characteristics of each enemy troop
class enemyType:
def __init__(self,name,speed,health,damage,prize):
self.name=name #name of the enemy troop
self.speed=speed #the speed at which the enemy troop travel downs the path
self.health=health #the health of the enemy
self.damage=damage #the amount of damage the troop does to the base when it reaches the end of the path
self.prize=prize #the amount of money you get when you kill a enemy troop
self.filename="FSE-Assets/Enemies/"+name+".png" #the name to load the picture into the game
infantry=enemyType('infantry',2.7,200,5,40) #so these are all the properties of the troops
transport=enemyType('transport',3.3,400,10,50) #for example, 'transport' has a speed of 1.7, 400 health, does 10 damage to the base, and you get 175 dollars if you kill it
motorcycle=enemyType('motorcycle',4,250,10,75)
lightTank=enemyType('lightTank',3,600,15,100)
heavyTank=enemyType('heavyTank',2.5,900,20,200)
tankDestroyer=enemyType('tankDestroyer',2.3,900,25,300)
class towerType: #this is the class that defines all the properties for the towers
def __init__(self,name,damage,price,uCost,refund,delay):
self.name=name #this is the name of the tower
self.damage=damage #this is the amount of damage the tower would do to the enemy troop
self.price=price #how much it costs to get this tower
self.uCost=uCost #how much money it takes to upgrade the towers
self.refund=refund #how much money you get if you refund the tower
self.delay=delay #the rate of fire of the tower (ie. the heaveMG would attack faster than the antitank)
self.filename="FSE-Assets/Defenses/"+name+".png" #the file path to load the picture into the game
antiTank=towerType('antiTank',80,800,350,400,40) #so these are all the properties for the towers
bunker=towerType('bunker',20,1000,450,500,10) #for example the 'bunker' would deal 30 damage to troops, cost 1000 dollars, cost 450 to upgrade, you get 500 if you refund it, and it fires every 10 ticks
fortress=towerType('fortress',100,1250,600,625,50)
heavyGun=towerType('heavyGun',150,1500,700,750,50)
heavyMG=towerType('heavyMG',6.3,500,200,250,5)
soldier=towerType('soldier',25,250,100,125,20)
def genEnemies(enemy): #this function loads all the images for the enemy troops for each level
global pics #list that contains the pictures of the troops for each level
global deadPics #list that contains the pictures of the troops when they die for each level
pics=[]
deadPics=[]
for i in enemy: #for every enemy in each level
img=[]
img.append(image.load(i[3].filename)) #the original picture (i[3] is the name of the troop )
img.append(transform.rotate(image.load(i[3].filename),-90)) #the picture but rotated 90 degress for when its going down the path
img.append(transform.rotate(image.load(i[3].filename),-270)) #the picture but rotated 270 for when its going up the path
img.append(transform.rotate(image.load(i[3].filename),-180))#the picture but rotated 180 for when its going left of the path
pics.append(img) #append the list into the pics list to make a 2D list
#this makes it so that the first index of img is the image facing the right, second is down, third is up, and fourth is left
for i in enemy:
img=[]
if i[3]==infantry:
img.append(dead)
img.append(transform.rotate(dead,-90))
img.append(transform.rotate(dead,-270))
img.append(transform.rotate(dead,-180))
deadPics.append(img)
else:
img.append(wreck)
img.append(transform.rotate(wreck,-90))
img.append(transform.rotate(wreck,-270))
img.append(transform.rotate(wreck,-180))
deadPics.append(img)
return pics #outputs the pics list
def healthBars(enemy):
for i in enemy: #for all enemy troops in the level
if i[5]==False and i[0]>=0: #if the troop is not dead
draw.rect(screen,BLACK,(i[0]+14,i[1]-11,i[3].health/10+2,9),0) #the outline of the healthbar, the length of the black bar is determined by starting health of the troop
draw.rect(screen,GREEN,(i[0]+15,i[1]-10,i[4]/10,7),0) #the actual health of the troop, starts full, and the length decreases as the health goes down by taking the current
#health of the troop and dividing it by 10
def moneyScore(screen): #function to blit the amoount of money you have and the score you currently have
global money #global variable of money
global activeDefenses
global score
txtMoney=txtFont.render("$"+str(money),True,RED) #renders the amount of money you have
txtScore=txtFont.render(str(score),True,RED) #renders the score
screen.blit(txtMoney,(100,30))
screen.blit(txtScore,(110,84))
def baseHealth(enemy,enemy2):
global gameOver #if health goes to zero
global ready,ready2
screen.blit(blackHeart,(940,350))
bars=100 #starting health of the base
count=0
draw.rect(screen,BLACK,(944,374,102,12),0) #draws the outline of the health bar
for i in enemy: #for every enemy in the level
if i[0]>=900: #if the enemy reaches the base
if i[5]==False: #If they are not dead
bars-=i[3].damage #subtract the health of the base by the damage that they deal (defined in the enemyType class)
if i[5]==True and i[0]>=1100: #makes sure if the enemy is off the screen and becomes "dead" in-game, the damage done to the base is still applied
bars-=i[3].damage
if bars<=0: #if it goes negative, set it back to zero
mixer.Sound.play(explosion_sound)
bars=0
if i[0]>=1100: #if the enemy passes through the base, its job is done, so it becomes "dead", though it was never killed by a tower
i[5]=True
for i in enemy2: #same thing but with the second wave of enemies
if i[0]>=900:
if i[5]==False:
bars-=i[3].damage
if i[5]==True and i[0]>=1100:
bars-=i[3].damage
if bars<=0:
mixer.Sound.play(explosion_sound)
bars=0
if i[0]>=1100:
i[5]=True
baseHealth=txtFont3.render(str(bars),True,BLACK) #renders the health beside the black heart
screen.blit(baseHealth,(965,353))
draw.rect(screen,RED,(1044,375,bars-100,10),0) #blits a red rectangle, and the length will be start at 0, because bars starts a 100, and as bars goes up, negative number is the length
draw.rect(screen,GREEN,(945,375,bars,10),0) #the green rect, starts with a length of 100 and decreases as the health goes down (length is dependant to health)
if bars==0: #when bars is zero (no health), starts the gameOver function
gameOver=True
def music(state): #this function is used to toggle the music (mute and unmute)
global pause #the variable to control the toggle
global current #to determine what screen is on right now
if current=="main": #if its the main menu, the position of the mute rect is different
muteRect=Rect(870,650,50,50)
screen.blit(eigthNote, (875,655))
else: #if its not the main menu, its at another spot
muteRect = Rect(420, 25, 40, 40)
screen.blit(eigthNote, (420, 27))
mx, my = mouse.get_pos()
mb = mouse.get_pressed()
if state is not None: #this only starts if mouse is being pressed down
if state: #if state is true
if muteRect.collidepoint(mx, my) and pause == False: #if i press it and music is playing, it would pause it
pause = True
mixer.music.pause()
elif muteRect.collidepoint(mx, my) and pause == True: #if i press it and the music is paused, it woudl play it again
pause = False
mixer.music.unpause()
if pause: #if the music is paused, it needs to blit the paused music image
if current=="main": #main menu location is different from the position in the levels
screen.blit(mutePic,(875,655))
else:
screen.blit(mutePic, (421, 27))
if muteRect.collidepoint(mx,my): #if the mouse is over the rect, highlight it yellow
draw.rect(screen, YELLOW, muteRect, 3)
else:
draw.rect(screen, RED, muteRect, 3)
def moveEnemy(screen,enemy): #for each level, when a enemy troop reaches the end of a path, it needs to know to turn, and this is what the function is used for
count=-1 #counter for number of enemies in the list
for i in enemy:
i[7]-=1
if i[5]==False and i[7]<=0:
if i[0]<220: #for the first section of the path, if it doesn't hit the end of the path, the enemy troop will move at a constant speed defined in the enemyType class
i[0]+=i[3].speed
i[2]=0 # i[2] is the 'frame' part of the 2D list, and it defines the frame that is needed for this section of the path. I this case, the frame needed is the troop facing right
if i[0]>=220 and i[1]<420: #this is the second section of the path, the path that goes down, and it will move at a constant speed
i[1]+=i[3].speed
i[2]=1 #the frame needed here is the one that faces down, so i[2] changes to 1
if i[1]>=410: #third section of the path, and it will travel at a constant speed
i[0]+=i[3].speed
i[2]=0 #the frame changes back to the troop facing to the right
count+=1 #counter for each enemy in the enemy list, and adds one for each enemy
if i[5]==False and i[7]<=0: #if troops are not dead and their delay is less than zero
screen.blit(pics[count][i[2]],i[:2]) #blits all the pictures needed, pics[count][i[2]] is the image and what rotation is needed, and i[:2] is the point at where you shoudl blit it
if i[5]==True and i[0]<=1100:
screen.blit(deadPics[count][i[2]],(i[0],i[1]+15))
def moveEnemy2(screen,enemy): #this is for the second level, because the path is different for each level, enemies must move different
count=-1 #counter for number of eneimes in the list
check1=Rect(300,220,65,350) #each section of the path has a rect, so when the enemy troop collides with the rect, it will turn the enemy troop
check2=Rect(300,155,365,65)
check3=Rect(665,210,65,230)
check4=Rect(665,440,900,65)
for i in enemy:
i[7]-=1 #starting section of the path
if i[5]==False and i[7]<=0: #if they are not dead
if i[0]<300: #the first section of the path
i[0]+=i[3].speed
i[2]=0
if check1.collidepoint(i[0],i[1]): #once it hits the first rect it will turn up (i[1]-=i[3].speed subtracts the y value by the speed defined in the enemyType class)
i[1]-=i[3].speed
i[2]=2 #sets the enemy sprite to the one facing up
if check2.collidepoint(i[0],i[1]): #same idea as check1, but in a different direction (in this case right)
i[0]+=i[3].speed
i[2]=0
if check3.collidepoint(i[0],i[1]):
i[1]+=i[3].speed
i[2]=1
if check4.collidepoint(i[0],i[1]):
i[0]+=i[3].speed
i[2]=0
## see moveEnemy() ##
count+=1
if i[5]==False and i[7]<=0:
screen.blit(pics[count][i[2]],i[:2])
if i[5]==True and i[0]<=1100:
screen.blit(deadPics[count][i[2]],(i[0],i[1]+15))
####################
def moveEnemy3(screen,enemy): #for comments about this function, see moveEnemy() (same idea and code, numbers changed for different path, different level)
count=-1
for i in enemy:
i[7]-=1
if i[5]==False and i[7]<=0:
if i[0]<370:
i[0]+=i[3].speed
i[2]=0
if i[0]>=370 and i[1]>=220:
i[1]-=i[3].speed
i[2]=2
if i[1]<=220:
i[0]+=i[3].speed
i[2]=0
count+=1
if i[5]==False and i[7]<=0:
screen.blit(pics[count][i[2]],i[:2])
if i[5]==True and i[0]<=1100:
screen.blit(deadPics[count][i[2]],(i[0],i[1]+15))
def moveEnemy4(screen,enemy): #for comments about this function, see moveEnemy2() (same idea and code, numbers changed for different path, different level)
count=-1
check1=Rect(230,280,60,280)
check2=Rect(230,560,360,60)
check3=Rect(590,330,60,300)
check4=Rect(590,270,900,60)
for i in enemy:
i[7]-=1
if i[5]==False and i[7]<=0:
if i[0]<230:
i[0]+=i[3].speed
i[2]=0
if check1.collidepoint(i[0],i[1]):
i[1]+=i[3].speed
i[2]=1
if check2.collidepoint(i[0],i[1]):
i[0]+=i[3].speed
i[2]=0
if check3.collidepoint(i[0],i[1]):
i[1]-=i[3].speed
i[2]=2
if check4.collidepoint(i[0],i[1]):
i[0]+=i[3].speed
i[2]=0
count+=1
if i[5]==False and i[7]<=0:
screen.blit(pics[count][i[2]],i[:2])
if i[5]==True and i[0]<=1100:
screen.blit(deadPics[count][i[2]],(i[0],i[1]+15))
def moveEnemy5(screen,enemy): #for comments about this function, see moveEnemy2() (same idea and code, numbers changed for different path, different level)
count=-1
check1=Rect(100,260,327,50)
check2=Rect(427,260,50,235)
check3=Rect(427,495,900,50)
for i in enemy:
i[7]-=1
if i[5]==False and i[7]<=0:
if i[1]<260:
i[1]+=i[3].speed
i[2]=1
if check1.collidepoint(i[0],i[1]):
i[0]+=i[3].speed
i[2]=0
if check2.collidepoint(i[0],i[1]):
i[1]+=i[3].speed
i[2]=1
if check3.collidepoint(i[0],i[1]):
i[0]+=i[3].speed
i[2]=0
count+=1
if i[5]==False and i[7]<=0:
screen.blit(pics[count][i[2]],i[:2])
if i[5]==True and i[0]<=1100:
screen.blit(deadPics[count][i[2]],(i[0],i[1]+15))
#these drawScene functions are to just blit the map into eact level (drawScene1 would be for level 1, etc...)
def drawScene1(screen):
screen.blit(map1,(0,0))
def drawScene2(screen):
screen.blit(map2,(0,0))
def drawScene3(screen):
screen.blit(map3,(0,0))
def drawScene4(screen):
screen.blit(map4,(0,0))
def drawScene5(screen):
screen.blit(map5,(0,0))
#this function is for the displaying all the things such as score, money, descriptions about the towers, etc.
def hudElements(screen):
screen.blit(hud,(550,20))
screen.blit(hudRects,(20,20))
screen.blit(dialoguePic,(600,600))
defC=None #variable to select what tower you want
ready=False #variable to see if the wave is ready to start or not
ready2=False #variable to see if the second wave is ready to start or not
gameOver=False #f you lose, gameOver=True and procedures happen
activeDefenses=[] #defenses that are currently on the map
def prep(screen,towerPos): #this function is for the start of the level
global defC,money,ready,ready2,click,wave
#rects needed to start the wave, upgrade towers, buy towers and cancel buyign towers
readyRect=Rect(830,120,179,69)
upgradeRect=Rect(750,662,70,30)
buyRects=[Rect(607,28,59,63),Rect(682,28,61,63),Rect(758,28,61,63),Rect(834,28,61,63),Rect(908,28,61,63),Rect(982,28,61,63)]
cancelRect=Rect(20,125,125,30)
## descriptions for all the towers
txtD1=txtFont2.render("Basic Soldier - Cost: $250, Damage: 25",True,BLACK)
txtD2=txtFont2.render("Machine Gun - Cost: $500, Damage: 35",True,BLACK)
txtD3=txtFont2.render("Anti-Tank Gun - Cost: $800, Damage: 80",True,BLACK)
txtD4=txtFont2.render("Bunker - Cost: $1000, Damage: 100",True,BLACK)
txtD5=txtFont2.render("Fortress - Cost: $1250, Damage: 150",True,BLACK)
txtD6=txtFont2.render("Heavy AT Gun - Cost: $1500, Damage: 200",True,BLACK)
txtS1=txtFont2.render("Basic Soldier - Damage:",True,BLACK)
txtS2=txtFont2.render("Machine Gun - Damage:",True,BLACK)
txtS3=txtFont2.render("Anti-Tank Gun - Damage:",True,BLACK)
txtS4=txtFont2.render("Bunker - Damage:",True,BLACK)
txtS5=txtFont2.render("Fortress - Damage:",True,BLACK)
txtS6=txtFont2.render("Heavy AT Gun - Damage:",True,BLACK)
towerDescription=[txtD1,txtD2,txtD3,txtD4,txtD5,txtD6]
towerStats=[txtS1,txtS2,txtS3,txtS4,txtS5,txtS6]
####
##generating defense images/sounds
defenses=[soldier,heavyMG,antiTank,bunker,fortress,heavyGun]
defensePics=[]
for i in defenses:
defensePics.append(image.load(i.filename))
sounds=[gun_sound,gun_sound,cannon_sound,gun_sound,gun_sound,cannon_sound]
draw.rect(screen,RED,readyRect,2)
screen.blit(readyPic,(830,120))
mx,my=mouse.get_pos()
mb=mouse.get_pressed()
if readyRect.collidepoint(mx,my):
draw.rect(screen,(255,255,0),readyRect,2)
if click and wave=="first": #checks what wave is coming up next
ready=True #changes the first wave's "ready" variable
if readyRect.collidepoint(mx,my):
draw.rect(screen,(255,255,0),readyRect,2)
if click and wave=="second": #checks if the second wave is coming
ready2=True #changes the 2nd wave's "ready" variable
for i in range(len(buyRects)): #if mouse hovers over any of the towers when you try to buy one, it will outline yellow
if buyRects[i].collidepoint(mx,my):
draw.rect(screen,YELLOW,buyRects[i],2)
if click:
defC=int(i) #if you click on the rect, defC turns into a number and the number represents what tower is selected (ie 0 is solider)
if defC!=None: #if there is a tower selected
draw.rect(screen,GREEN,buyRects[defC],2) #outline the tower green
screen.blit(towerDescription[defC],(620,630)) #blit the description
cancelRect=Rect(20,125,125,30) #give player option to cancel
screen.blit(cancelPic,(20,125))
#money and stuff
for i in range(len(towerPos)): #towerPos is all the possible spots that you can place the towers
if towerPos[i][1]==False: #if there isnt a tower there
draw.rect(screen,RED,towerPos[i][0],3) #its red
if towerPos[i][0].collidepoint(mx,my):
draw.rect(screen,YELLOW,towerPos[i][0],3)
if click and money-defenses[defC].price>=0: #if you have enough moeny and you click on an avaliable space, it will take away the money and append the tower into the active defenses list
mixer.Sound.play(place_sound)
#tower picture, blit position, tower class variable, tower position index, damage, upgrade cost, delay counter, delay, sound type
activeDefenses.append([defensePics[defC],towerPos[i][2],defenses[defC],towerPos[i][4],int(defenses[defC].damage),defenses[defC].uCost,0,defenses[defC].delay,sounds[defC]])
money-=defenses[defC].price
towerPos[i][1]=True #that spot is taken, so that index is true
towerPos[i][5]=defC #it also identifies what tower is there
if money-defenses[defC].price<0: #if there is not enough money, message is displayed
noMoney = txtFont2.render("Not enough money for this tower.", True, RED)
screen.blit(noMoney,(620,660))
if cancelRect.collidepoint(mx,my): #you can cancel to pick another thing
draw.rect(screen,RED,cancelRect,2)
if click:
defC=None
#This is the tower edit program - selecting, upgrade, delete
select=None #select checks if a tower is already selected. If a tower is selected already, select prohibits the player from choosing another tower
if defC==None: #no tower is being bought
for i in towerPos:
if i[0].collidepoint(mx,my) and i[1]==True and select==None: #if the player hovers over a tower space,there is a tower, and the player has not
draw.rect(screen,YELLOW,i[0],3) #selected a tower yet, the space will be highlighted
if click:
i[3]=True #the tower can be edited if the player clicks on it.
select=i[4]
if i[3]==True:
#select=True #while a tower is selected, the player cannot select another until they choose cancel
draw.rect(screen,GREEN,buyRects[i[5]],2) #highlights the tower
screen.blit(towerStats[i[5]],(620,630)) #this will blit the individual tower's damage
txtUpgrade=txtFont2.render("UPGRADE?",True,BLACK)
draw.rect(screen,BLACK,upgradeRect,2)
for a in activeDefenses: #checks all active towers
if a[1]==i[2]: #checks which active tower is on the selected tower space
damageDes=txtFont2.render("%i"%(a[4]),True,BLACK) #the individual tower's attack is a[4]
screen.blit(damageDes,(850,630))
if type(a[5])==int: #if upgraded, a[5] will be None - not an int value
txtuCost=txtFont2.render("$%i"%(a[5]),True,BLACK) #price of upgrade
else:
txtuCost=txtFont2.render(a[5],True,BLACK) #will blit nothing, signalling the tower cannot be upgraded further
if upgradeRect.collidepoint(mx,my):
if type(a[5])==int:
draw.rect(screen,GREEN,upgradeRect,2) #will highlight upgradeRect when hovered over and if the tower has not been upgraded
if click and money-defenses[i[5]].uCost>=0: #will only upgrade if the player has enough money
mixer.Sound.play(place_sound)
a[4]+=10*(i[5]+1) #increasing the attack
a[5]=None #once upgraded, the upgrade cost will be nothing
money-=defenses[i[5]].uCost
cancelRect=Rect(20,125,125,30)
screen.blit(txtUpgrade,(650,670))
screen.blit(txtuCost,(763,670))
screen.blit(cancelPic,(20,125))
cancelRect=Rect(20,125,125,30) #rect for cancelling a tower selection
deleteRect=Rect(20,160,125,30) #rect for deleting an active tower
draw.rect(screen,GREEN,i[0],3)
screen.blit(cancelPic,(20,125))
screen.blit(deletePic,(20,160))
if deleteRect.collidepoint(mx,my):
draw.rect(screen,RED,deleteRect,2)
if click:
mixer.Sound.play(remove_sound)
i[3]=False #when deleted, tower edit status reverts
i[1]=False #when deleted, the tower space goes empty
for a in activeDefenses:
if a[3]==i[4]: #checks which active tower was on the selected tower space
activeDefenses.remove(a) #deletes the tower from the active list
money+=a[2].refund #give back money
select=None
if cancelRect.collidepoint(mx,my):
draw.rect(screen,RED,cancelRect,2)
if click:
i[3]=False #tower edit status reverts
select=None #player can select a tower again
def damageEnemies(enemy,activeDefenses,towerPos): #this function is the damage dealt to the enemies by the towers
global money,score
for a in activeDefenses: #for all the towers on the screen right now
flashList=list(towerPos[a[3]][2]) #take the muzzle flash sprites out
for e in enemy: #for every enemy in the level
if towerPos[a[3]][6].collidepoint(e[0],e[1]) and e[5]==False: #if the enemy is in the towers range (which is a rect) ad it isn't dead
if a[6]==0: #if the delay is zero
mixer.Sound.play(a[8]) #muzzle flash sound is played
screen.blit(muzzleFlash,(flashList[0]-25,flashList[1]+13))#muzzle flash animation is played
e[4]-=a[4] #e4 s the enemy health, a[4] is the tower damage, subtract damamge from health
a[6]=a[7] #set delay back to original, make sure it doesn.t fire rapidly
if a[6]>0: #set delay back down
a[6]-=1
if e[4]<=0: #if the health drops to zero or under
e[5]=True #sets the troop as dead
if e[5]==True: #if its dead, you gain money and your score goes up by a number predetermined in the enemyType class
money+=e[6]
score+=e[6]
e[6]=0
#this is the victory screen. displays after all 5 levels are won
def victory(score): #this function is used when a player wins the match. It bust displays your final score and if you want to go back
running=True
mixer.music.load("FSE-Assets/sound/sovietTheme.mp3")
mixer.music.play(-1)
mainMenuRect=Rect(573,620,400,50)
click=False
finalScore = txtFont4.render(str(score), True, BLACK)
while running:
mx,my=mouse.get_pos()
mb=mouse.get_pressed()
screen.blit(finalLevel,(13,17))
screen.blit(finalScore,(830,302))
for evt in event.get():
if evt.type==QUIT:
running=False
return "exit"
if evt.type==MOUSEBUTTONDOWN:
click=True
if evt.type==MOUSEBUTTONUP:
click=False
if mainMenuRect.collidepoint(mx,my):
draw.rect(screen,BLACK,mainMenuRect,3)
if mb[0]==1 and click==False:
running=False
display.flip()
return "levelSelect"
#these are the preview screens.
def prev1(): #this is the preview scene that you see before you actually get into the level. Just cool pictures and a button that you press to start. Different screens for different level
running=True
mixer.music.load("FSE-Assets/sound/startMusic2.mp3")
mixer.music.play(-1)
pressRect=Rect(380,320,300,100)
while running:
screen.blit(pr1,(0,0))
screen.blit(pressToStart,(380,320))
for evt in event.get():
if evt.type==QUIT:
running=False
return "exit"
mx,my=mouse.get_pos()
mb=mouse.get_pressed()
if pressRect.collidepoint(mx,my):
draw.rect(screen,RED,pressRect,3)
if mb[0]==1:
return "lev1" #calls the first level
display.flip()
def prev2(): # refer to prev1()
running=True
mixer.music.load("FSE-Assets/sound/startMusic1.mp3")
mixer.music.play(-1)
pressRect=Rect(380,320,300,100)
while running:
screen.blit(pr2,(0,0))
screen.blit(pressToStart,(380,320))
for evt in event.get():
if evt.type==QUIT:
running=False
return "exit"
mx,my=mouse.get_pos()
mb=mouse.get_pressed()
if pressRect.collidepoint(mx,my):
draw.rect(screen,RED,pressRect,3)
if mb[0]==1:
return "lev2" #calls the second level
display.flip()
def prev3(): # refer to prev1()
running=True
mixer.music.load("FSE-Assets/sound/startMusic2.mp3")
mixer.music.play(-1)
pressRect=Rect(380,320,300,100)
while running:
screen.blit(pr3,(0,0))
screen.blit(pressToStart,(380,320))
for evt in event.get():
if evt.type==QUIT:
running=False
return "exit"
mx,my=mouse.get_pos()
mb=mouse.get_pressed()
if pressRect.collidepoint(mx,my):
draw.rect(screen,RED,pressRect,3)
if mb[0]==1:
return "lev3" #calls the third level
display.flip()
def prev4(): # refer to prev1()
running=True
mixer.music.load("FSE-Assets/sound/startMusic1.mp3")
mixer.music.play(-1)
pressRect=Rect(380,320,300,100)
while running:
screen.blit(pr4,(0,0))
screen.blit(pressToStart,(380,320))
for evt in event.get():
if evt.type==QUIT:
running=False
return "exit"
mx,my=mouse.get_pos()
mb=mouse.get_pressed()
if pressRect.collidepoint(mx,my):
draw.rect(screen,RED,pressRect,3)
if mb[0]==1:
return "lev4" #calls the fourth level
display.flip()
def prev5(): # refer to prev1()
running=True
mixer.music.load("FSE-Assets/sound/startMusic2.mp3")
mixer.music.play(-1)
pressRect=Rect(380,320,300,100)
while running:
screen.blit(pr5,(0,0))
screen.blit(pressToStart,(380,320))
for evt in event.get():
if evt.type==QUIT:
running=False
return "exit"
mx,my=mouse.get_pos()
mb=mouse.get_pressed()
if pressRect.collidepoint(mx,my):
draw.rect(screen,RED,pressRect,3)
if mb[0]==1:
return "lev5" #calls the fifth level
display.flip()
def lev1(): #this is the function that you use for each level to generate all the gameplay features
global defC,ready,ready2,activeDefenses,money,score,click,gameOver,wave #all the variables needed
money=4500 #starting about of money
pause=False
running=True
myclock=time.Clock()
mixer.music.load("FSE-Assets/sound/bgMusic.mp3")
mixer.music.play(-1)
quitRect=Rect(260,25,150,40)
#rect, status, blit position, edit status, rect, active tower, tower attack range
# subtract 91 from x,y, make 212 the length and width
towerPos1=[[Rect(115,273,50,50),False,(115,273),False,0,None,Rect(5,162,160,100)],[Rect(264,114,50,50),False,(264,114),False,1,None,Rect(60,162,212,130)],
[Rect(319,242,50,50),False,(319,242),False,2,None,Rect(190,131,212,230)],[Rect(217,529,50,50),False,(217,529),False,3,None,Rect(126,400,212,212)],
[Rect(388,342,50,50),False,(388,342),False,4,None,Rect(297,251,212,212)],[Rect(570,342,50,50),False,(570,342),False,5,None,Rect(479,251,212,212)],
[Rect(750,342,50,50),False,(750,342),False,6,None,Rect(659,251,212,212)],[Rect(418,503,50,50),False,(418,503),False,7,None,Rect(327,412,212,212)],
[Rect(598,503,50,50),False,(598,503),False,8,None,Rect(507,412,212,212)],[Rect(778,503,50,50),False,(778,503),False,9,None,Rect(688,412,212,212)]]
#first wave
#x,y,frame,enemy type,health,death status, prize, delay
enemy=[[-100,190,0,motorcycle,motorcycle.health,False,motorcycle.prize,30],[-100,190,0,motorcycle,motorcycle.health,False,motorcycle.prize,90],[-100,190,0,motorcycle,motorcycle.health,False,motorcycle.prize,150],
[-100,190,0,motorcycle,motorcycle.health,False,motorcycle.prize,210],[-100,190,0,motorcycle,motorcycle.health,False,motorcycle.prize,270],[-100,190,0,motorcycle,motorcycle.health,False,motorcycle.prize,330],
[-100,190,0,motorcycle,motorcycle.health,False,motorcycle.prize,390],[-100,190,0,transport,transport.health,False,transport.prize,450],[-100,190,0,transport,transport.health,False,transport.prize,530],
[-100,190,0,transport,transport.health,False,transport.prize,610],[-100,190,0,transport,transport.health,False,transport.prize,700],[-100,190,0,transport,transport.health,False,transport.prize,780],
[-100,190,0,infantry,infantry.health,False,infantry.prize,820],[-100,190,0,infantry,infantry.health,False,infantry.prize,880],[-100,190,0,infantry,infantry.health,False,infantry.prize,940],[-100,190,0,infantry,infantry.health,False,infantry.prize,1000],
[-100,190,0,infantry,infantry.health,False,infantry.prize,1060],[-100,190,0,infantry,infantry.health,False,infantry.prize,1120],[-100,190,0,lightTank,lightTank.health,False,lightTank.prize,1200],
[-100,190,0,lightTank,lightTank.health,False,lightTank.prize,1320],[-100,190,0,lightTank,lightTank.health,False,lightTank.prize,1440],[-100,190,0,lightTank,lightTank.health,False,lightTank.prize,1560],
[-100,190,0,lightTank,lightTank.health,False,lightTank.prize,1680]] #1st wave
enemy2=[[-100,190,0,lightTank,lightTank.health,False,lightTank.prize,0],[-100,190,0,lightTank,lightTank.health,False,lightTank.prize,120],[-100,190,0,lightTank,lightTank.health,False,lightTank.prize,240],
[-100,190,0,lightTank,lightTank.health,False,lightTank.prize,360],[-100,190,0,lightTank,lightTank.health,False,lightTank.prize,480],[-100,190,0,transport,transport.health,False,transport.prize,560],
[-100,190,0,transport,transport.health,False,transport.prize,640],[-100,190,0,transport,transport.health,False,transport.prize,720],[-100,190,0,transport,transport.health,False,transport.prize,800],
[-100,190,0,motorcycle,motorcycle.health,False,motorcycle.prize,850],[-100,190,0,motorcycle,motorcycle.health,False,motorcycle.prize,910],[-100,190,0,motorcycle,motorcycle.health,False,motorcycle.prize,970],
[-100,190,0,infantry,infantry.health,False,infantry.prize,1010],[-100,190,0,infantry,infantry.health,False,infantry.prize,1070],[-100,190,0,infantry,infantry.health,False,infantry.prize,1130],[-100,190,0,infantry,infantry.health,False,infantry.prize,1190],
[-100,190,0,infantry,infantry.health,False,infantry.prize,1250],[-100,190,0,infantry,infantry.health,False,infantry.prize,1310],[-100,190,0,infantry,infantry.health,False,infantry.prize,1370],[-100,190,0,infantry,infantry.health,False,infantry.prize,1430],
[-100,190,0,heavyTank,heavyTank.health,False,heavyTank.prize,1510],[-100,190,0,heavyTank,heavyTank.health,False,heavyTank.prize,1630],[-100,190,0,heavyTank,heavyTank.health,False,heavyTank.prize,1750],
[-100,190,0,heavyTank,heavyTank.health,False,heavyTank.prize,1870],[-100,190,0,heavyTank,heavyTank.health,False,heavyTank.prize,1990]]#2nd wave
click=False
wave="first" #start off with the first wave
while running:
myclock.tick(60)
drawScene1(screen) #blits the map
hudElements(screen) #money, score, descriptons
moneyScore(screen) #counts you rscore and amount of money
baseHealth(enemy,enemy2) #the amount of health your base has
screen.blit(quitPic,(260,25))
draw.rect(screen,BLACK,quitRect,2)
mx,my=mouse.get_pos()
mb=mouse.get_pressed()
for evt in event.get():
if evt.type==QUIT:
running=False
return "exit"
if evt.type==MOUSEBUTTONDOWN:
click=True
music(True) #when mouse is down it checks if you've paused the music
if evt.type==MOUSEBUTTONUP:
click=False
fps = txtFont.render("FPS:"+str(int(myclock.get_fps())), True, BLACK) #fps counter
screen.blit(fps,(5,5))
music(None) #anytime else music stays at whatever state it is at
for a in activeDefenses:
screen.blit(a[0],a[1]) #blit all defenses at location it was placed at
if quitRect.collidepoint(mx,my): #if you press quit, game pauses
draw.rect(screen,RED,quitRect,3)
if mb[0]==1:
pause=True
if pause==True:
endScreen=Surface((width,height),SRCALPHA) #new surface that will be blitted on top to make a transparent grey screen
endScreen.fill((220,220,220,127))
screen.blit(endScreen,(0,0))
screen.blit(sureRect,(335,235))
returnRect=Rect(465,375,140,35)
leaveRect=Rect(435,425,205,35)
if returnRect.collidepoint(mx,my): #if you press return, you resume the level you are at
draw.rect(screen,RED,returnRect,3)
if mb[0]==1:
pause=False
if leaveRect.collidepoint(mx,my):# if you leave, all the variables are set on False or None so they don't save to another level, goes back to level selection screen
draw.rect(screen,RED,leaveRect,3)
if mb[0]==1:
pause=False
defC=None
editCond=False
activeDefenses=[]
running=False
ready=False
ready2=False
gameOver=False
score=0
return "levelSelect"
if ready==False and pause==False and wave=="first": #checks if either ready variable is false, so it calls the prep functions
prep(screen,towerPos1)
if ready2==False and pause==False and wave=="second":
prep(screen,towerPos1)
if ready==True and gameOver==False and pause==False: #if the first ready variable is true, it will call the functions for the first enemy list
genEnemies(enemy) #generating enemies
moveEnemy(screen,enemy) #move
healthBars(enemy) #health bars
damageEnemies(enemy,activeDefenses,towerPos1) #damage
if ready2==True and gameOver==False and pause==False: #if the 2nd ready variable becomes true, it will call the game functions for the second enemy list
genEnemies(enemy2)
moveEnemy(screen,enemy2)
healthBars(enemy2)
damageEnemies(enemy2,activeDefenses,towerPos1)
if gameOver: # if you lose, screen becomes a transparent screen and you have the option to retry or go to main menu
endScreen=Surface((width,height),SRCALPHA)
endScreen.fill((220,220,220,127))
screen.blit(endScreen,(0,0))
screen.blit(loseRect,(335,235))
retryRect=Rect(365,415,128,50)
mainRect=Rect(525,415,187,50)
draw.rect(screen,RED,(945,375,100,10),0)
if retryRect.collidepoint(mx,my):
draw.rect(screen,RED,retryRect,3)
if mb[0]==1:
defC=None
editCond=False
activeDefenses=[]
running=False
ready=False
ready2=False
gameOver=False
money=2000
score=0
return "prev1"
if mainRect.collidepoint(mx,my):
draw.rect(screen,RED,mainRect,3)
if mb[0]==1 and click==False:
defC=None
editCond=False
activeDefenses=[]
running=False
ready=False
ready2=False
gameOver=False
money=2000
score=0
count=0 #counter for the first enemy list
for i in enemy:
if i[5]==True: #for each "dead" or enemy that passed through the base, the count will go up
count+=1
if count==len(enemy): #if the counter is the same as the length of the enemy list, it means all the enemies have either died
#or passed over the base, signalling the end of the wave
wave="second" #changes the wave variable to the second wave
ready=False #makes the first ready variable false
#there are only 2 waves per level, so this is the final wave
count2=0
for i in enemy2:
if i[5]==True:
count2+=1
if count2==len(enemy2): #signals the end of the game (all 2 waves cleared)
endScreen=Surface((width,height),SRCALPHA)
endScreen.fill((220,220,220,127))
screen.blit(endScreen,(0,0))
screen.blit(victoryRect,(320,225))
redoRect=Rect(445,353,150,40)
nextRect=Rect(410,404,217,40)
if redoRect.collidepoint(mx,my):
draw.rect(screen,RED,redoRect,3)
if mb[0]==1 and click==False:
defC=None
editCond=False
activeDefenses=[]
ready=False
ready2=False
running=False
return "prev1"
if nextRect.collidepoint(mx,my):
draw.rect(screen,RED,nextRect,3)
if mb[0]==1 and click==False:
defC=None
editCond=False
activeDefenses=[]
ready=False
ready2=False
running=False
return "prev2"
display.flip()
return "levelSelect"
def lev2(): #each level has the same fucntions used, the only thing different is the places towers can be placed and the different enemies that appear in the waves
#refer to lev1() for comments
global defC,ready,ready2,activeDefenses,money,score,click,gameOver,wave
money=6000
running=True
pause=False
myclock=time.Clock()
mixer.music.load("FSE-Assets/sound/bgMusic.mp3")
mixer.music.play(-1)
quitRect=Rect(260,25,150,40)
# subtract 91 from x,y, make 212 the length and width
towerPos2=[[Rect(75,430,50,50),False,(75,430),False,0,None,Rect(-26,339,212,212)],[Rect(210,430,50,50),False,(210,430),False,1,None,Rect(119,339,212,212)],
[Rect(210,300,50,50),False,(210,300),False,2,None,Rect(119,209,212,212)],[Rect(225,125,50,50),False,(225,125),False,3,None,Rect(134,34,212,212)],
[Rect(425,125,50,50),False,(425,125),False,4,None,Rect(334,34,212,212)],[Rect(600,125,50,50),False,(600,125),False,5,None,Rect(509,34,212,212)],
[Rect(425,300,50,50),False,(425,300),False,6,None,Rect(334,209,212,212)],[Rect(560,300,50,50),False,(560,300),False,7,None,Rect(469,209,212,212)],
[Rect(750,275,50,50),False,(750,275),False,8,None,Rect(659,184,212,212)],[Rect(825,375,50,50),False,(825,375),False,9,None,Rect(734,284,212,212)]]
enemy=[[-100,510,0,infantry,infantry.health,False,infantry.prize,30],[-100,510,0,infantry,infantry.health,False,infantry.prize,80],[-100,510,0,infantry,infantry.health,False,infantry.prize,130],
[-100,510,0,infantry,infantry.health,False,infantry.prize,180],[-100,510,0,infantry,infantry.health,False,infantry.prize,230],[-100,510,0,infantry,infantry.health,False,infantry.prize,280],
[-100,510,0,infantry,infantry.health,False,infantry.prize,330],[-100,510,0,infantry,infantry.health,False,infantry.prize,380],[-100,510,0,infantry,infantry.health,False,infantry.prize,430],
[-100,510,0,infantry,infantry.health,False,infantry.prize,480],[-100,510,0,infantry,infantry.health,False,infantry.prize,530],[-100,510,0,infantry,infantry.health,False,infantry.prize,580],
[-100,510,0,transport,transport.health,False,transport.prize,650],[-100,510,0,transport,transport.health,False,transport.prize,750],[-100,510,0,transport,transport.health,False,transport.prize,850],
[-100,510,0,transport,transport.health,False,transport.prize,950],[-100,510,0,transport,transport.health,False,transport.prize,1050],[-100,510,0,transport,transport.health,False,transport.prize,1150],
[-100,510,0,lightTank,lightTank.health,False,lightTank.prize,1200],[-100,510,0,lightTank,lightTank.health,False,lightTank.prize,1320],[-100,510,0,lightTank,lightTank.health,False,lightTank.prize,1440],
[-100,510,0,lightTank,lightTank.health,False,lightTank.prize,1560],[-100,510,0,lightTank,lightTank.health,False,lightTank.prize,1680],[-100,510,0,lightTank,lightTank.health,False,lightTank.prize,1800]]#1st wave
enemy2=[[-100,510,0,motorcycle,motorcycle.health,False,motorcycle.prize,30],[-100,510,0,motorcycle,motorcycle.health,False,motorcycle.prize,80],[-100,510,0,motorcycle,motorcycle.health,False,motorcycle.prize,130],
[-100,510,0,motorcycle,motorcycle.health,False,motorcycle.prize,180],[-100,510,0,motorcycle,motorcycle.health,False,motorcycle.prize,230],[-100,510,0,heavyTank,heavyTank.health,False,heavyTank.prize,280],
[-100,510,0,heavyTank,heavyTank.health,False,heavyTank.prize,400],[-100,510,0,heavyTank,heavyTank.health,False,heavyTank.prize,520],[-100,510,0,heavyTank,heavyTank.health,False,heavyTank.prize,640],
[-100,510,0,lightTank,lightTank.health,False,lightTank.prize,760],[-100,510,0,lightTank,lightTank.health,False,lightTank.prize,880],[-100,510,0,lightTank,lightTank.health,False,lightTank.prize,1000],
[-100,510,0,lightTank,lightTank.health,False,lightTank.prize,1120],[-100,510,0,lightTank,lightTank.health,False,lightTank.prize,1240],[-100,510,0,heavyTank,heavyTank.health,False,heavyTank.prize,1360],
[-100,510,0,heavyTank,heavyTank.health,False,heavyTank.prize,1480],[-100,510,0,infantry,infantry.health,False,infantry.prize,1530],[-100,510,0,infantry,infantry.health,False,infantry.prize,1580],
[-100,510,0,infantry,infantry.health,False,infantry.prize,1630],[-100,510,0,infantry,infantry.health,False,infantry.prize,1680],[-100,510,0,infantry,infantry.health,False,infantry.prize,1730],
[-100,510,0,infantry,infantry.health,False,infantry.prize,1780],[-100,510,0,infantry,infantry.health,False,infantry.prize,30],[-100,510,0,infantry,infantry.health,False,infantry.prize,1830]]#2nd wave
wave="first"
click=False
while running:
myclock.tick(60)
drawScene2(screen)
hudElements(screen)
moneyScore(screen)
screen.blit(quitPic,(260,25))
draw.rect(screen,BLACK,quitRect,2)
baseHealth(enemy,enemy2)
mx,my=mouse.get_pos()
mb=mouse.get_pressed()
for evt in event.get():
if evt.type==QUIT:
running=False
return "exit"
if evt.type==MOUSEBUTTONDOWN:
click=True
music(True)
if evt.type==MOUSEBUTTONUP:
click=False
mx,my=mouse.get_pos()
mb=mouse.get_pressed()
music(None)
for a in activeDefenses:
screen.blit(a[0],a[1])
if quitRect.collidepoint(mx,my):
draw.rect(screen,RED,quitRect,3)
if mb[0]==1:
pause=True
if pause==True:
endScreen=Surface((width,height),SRCALPHA)
endScreen.fill((220,220,220,127))
screen.blit(endScreen,(0,0))
screen.blit(sureRect,(335,235))
returnRect=Rect(465,375,140,35)
leaveRect=Rect(435,425,205,35)
if returnRect.collidepoint(mx,my):
draw.rect(screen,RED,returnRect,3)
if mb[0]==1:
pause=False
if leaveRect.collidepoint(mx,my):
draw.rect(screen,RED,leaveRect,3)
if mb[0]==1:
pause=False
defC=None
editCond=False
activeDefenses=[]
running=False