forked from x4nth055/pythoncode-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (30 loc) · 904 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
30
31
32
33
34
35
36
37
import pygame
from data.classes.Board import Board
pygame.init()
WINDOW_SIZE = (600, 600)
screen = pygame.display.set_mode(WINDOW_SIZE)
board = Board(WINDOW_SIZE[0], WINDOW_SIZE[1])
def draw(display):
display.fill('white')
board.draw(display)
pygame.display.update()
if __name__ == '__main__':
running = True
while running:
mx, my = pygame.mouse.get_pos()
for event in pygame.event.get():
# Quit the game if the user presses the close button
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.MOUSEBUTTONDOWN:
# If the mouse is clicked
if event.button == 1:
board.handle_click(mx, my)
if board.is_in_checkmate('black'): # If black is in checkmate
print('White wins!')
running = False
elif board.is_in_checkmate('white'): # If white is in checkmate
print('Black wins!')
running = False
# Draw the board
draw(screen)