forked from TheLastBanana/tactics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (33 loc) · 1.04 KB
/
main.py
File metadata and controls
37 lines (33 loc) · 1.04 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
import sys, pygame, tiles
from gui import GUI
RESOLUTION = pygame.Rect(0, 0, 800, 600)
BG_COLOR = (32, 32, 32)
# Initialize everything
pygame.mixer.pre_init(22050, -16, 2, 512) # Small buffer for less sound lag
pygame.init()
pygame.display.set_caption("Tactics")
main_gui = GUI(RESOLUTION, BG_COLOR)
clock = pygame.time.Clock()
argv = sys.argv[1:]
# If a filename was given, load that level. Otherwise, load a default.
level = "island"
if len(argv) > 0:
level = argv[0]
main_gui.load_level("maps/" + level + ".lvl")
# The main game loop
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.display.quit()
sys.exit()
# End if q is pressed
elif (event.type == pygame.KEYDOWN and
(event.key == pygame.K_q or event.key == pygame.K_ESCAPE)):
pygame.display.quit()
sys.exit()
# Respond to clicks
elif event.type == pygame.MOUSEBUTTONUP:
main_gui.on_click(event)
main_gui.update()
main_gui.draw()
clock.tick(60)