-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
49 lines (37 loc) · 1.31 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
import pygame
from GameBoard import GameBoard
class Gomoku:
def __init__(self):
pygame.init()
self.screen = pygame.display.set_mode((800, 600))
self.clock = pygame.time.Clock()
self.font = pygame.font.Font(r"C:\Windows\Fonts\consola.ttf", 24)
self.going = True
self.gameboard = GameBoard()
def loop(self):
while self.going:
self.update()
self.draw()
self.clock.tick(60)
pygame.quit()
def update(self):
for event in pygame.event.get():
if self.gameboard.current_piece == 'w':
while not self.gameboard.agent_pick():
continue
continue
if event.type == pygame.QUIT:
self.going = False
elif event.type == pygame.MOUSEBUTTONDOWN:
self.gameboard.mouse_handler(event)
def draw(self):
self.screen.fill((255, 255, 255))
self.gameboard.draw(self.screen)
if self.gameboard.game_over:
self.screen.blit(
self.font.render("{0} Win".format("Black" if self.gameboard.winner == 'b' else "White"), True,
(0, 0, 0)), (500, 10))
pygame.display.update()
if __name__ == '__main__':
game = Gomoku()
game.loop()