-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (27 loc) · 868 Bytes
/
main.py
File metadata and controls
36 lines (27 loc) · 868 Bytes
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
import pygame
from src.game import Game
def main():
#Initialize the game
pygame.display.set_caption('Checkers')
window = pygame.display.set_mode((800, 800))
game = Game(window)
isRunning = True
fps = 60
clock = pygame.time.Clock()
#Game loop
while isRunning:
clock.tick(fps)
if game.winner():
print(game.winner())
isRunning = False
for event in pygame.event.get():
if event.type == pygame.QUIT:
isRunning = False
if event.type == pygame.MOUSEBUTTONDOWN:
pos = pygame.mouse.get_pos()
row, col = int(pos[1] / game.getSquareSize()), int(pos[0] / game.getSquareSize())
game.select(row, col)
game.update()
pygame.quit()
if __name__ == "__main__":
main()