-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsandie.py
51 lines (34 loc) · 1.42 KB
/
sandie.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
import sys, pygame, numpy
from board import Board
import draw
if __name__ == "__main__":
pygame.init()
width, height = 640, 360
zoom_factor = 2
timer_id = 25
screen = pygame.display.set_mode((width * zoom_factor, height * zoom_factor + 200))
ui = draw.UserInterface(width, height, zoom_factor, screen)
board = Board(width, height, zoom_factor, ui.game_surface)
#board.render_entire_board()
ui.draw_ui(board)
pygame.time.set_timer(25, board.tick_delay)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
if event.type == timer_id:
board.update()
ui.frame(board)
pygame.event.clear(eventtype = timer_id)
elif event.type == pygame.MOUSEBUTTONUP and event.button == 1:
ui.mouse_up(board, event.pos[0], event.pos[1])
elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
ui.mouse_down(board, event.pos[0], event.pos[1])
elif event.type == pygame.MOUSEMOTION and pygame.mouse.get_pressed()[0]:
ui.mouse_drag(board, event.pos[0], event.pos[1])
elif event.type == pygame.KEYDOWN and event.key == pygame.K_q:
pygame.quit()
sys.exit()
else:
continue
pygame.display.flip()
# draw.draw_ui(board, screen)