-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
29 lines (24 loc) · 907 Bytes
/
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
import pygame
from tictactoe.game.ticTacToe import TicTacToe
from tictactoe.ui.ticTacToeUi import TicTacToeUI
if __name__ == "__main__":
pygame.init()
window = pygame.display.set_mode((300, 350))
def loop():
tictactoe = TicTacToe("X")
ui = TicTacToeUI(pygame, tictactoe, window)
while True:
for event in pygame.event.get():
if event.type is pygame.QUIT:
return False
if event.type is pygame.MOUSEBUTTONDOWN:
if event.button is 1:
column = event.pos[0] // 100
row = event.pos[1] // 100
tictactoe.set_obj(row, column)
if event.type is pygame.KEYDOWN:
if event.key is pygame.K_r:
tictactoe.restart()
ui.update()
loop()
pygame.quit()