-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
54 lines (39 loc) · 1.16 KB
/
main.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
#!/usr/bin/env python
import sys
import pygame
import globals
from core.hex_map import HexMap
from game import Game
from editor import Editor
black = pygame.Color(0, 0, 0)
pygame.init()
size = [globals.WINDOW_WIDTH, globals.WINDOW_HEIGHT]
screen = pygame.display.set_mode(size)
done = False
clock = pygame.time.Clock()
background = pygame.Surface(screen.get_size())
background = background.convert()
if len(sys.argv) == 2 and sys.argv[1] == 'editor':
pygame.display.set_caption("Editor")
hex_map = HexMap(globals.WORLD_WIDTH, globals.WORLD_HEIGHT)
game = Editor(background, hex_map)
else:
pygame.display.set_caption("HEX")
hex_map = HexMap(globals.WORLD_WIDTH, globals.WORLD_HEIGHT, 'world.json')
game = Game(background, hex_map)
game.init()
game.start()
while not done:
clock.tick(60)
background.fill(black)
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
if event.type == pygame.MOUSEBUTTONDOWN:
pos = pygame.mouse.get_pos()
game.on_click(pos)
game.update()
game.draw()
screen.blit(background, (0, 0))
pygame.display.flip()
pygame.quit()