-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (53 loc) · 1.49 KB
/
main.py
File metadata and controls
66 lines (53 loc) · 1.49 KB
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
import pygame
import constants as c
import HUD
import Map
import stats
import wave
import enemies
import Towers
import projectile
pygame.init()
pygame.display.set_caption('Castle Defender')
clock = pygame.time.Clock()
def mainmenu():
mainmenu = True
while mainmenu:
for event in pygame.event.get():
# print(event)
if event.type == pygame.QUIT:
pygame.quit()
quit()
c.gameDisplay.fill(c.WHITE)
pygame.display.update()
clock.tick(15)
def gameloop():
Map.createmap()
for i in range(len(Map.map.map)):
print (c.space.join(Map.map.map[i]))
while game:
eventlistener()
Map.readmap()
HUD.hud()
wave.wavelistener()
Towers.placedtowers.update()
projectile.projectiles.update()
projectile.projectiles.draw(c.gameDisplay)
Towers.placedtowers.draw(c.gameDisplay)
stats.stats.miliseconds = pygame.time.get_ticks()
pygame.display.update()
clock.tick(60)
def eventlistener():
for event in pygame.event.get():
if event.type == pygame.QUIT:
global game
game = False
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
if HUD.inhudrange(pygame.mouse.get_pos()):
HUD.hudclick(pygame.mouse.get_pos())
else:
Map.mapclick(pygame.mouse.get_pos())
if __name__ == '__main__':
game = True
gameloop()
pygame.quit()