-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (31 loc) · 1.04 KB
/
main.py
File metadata and controls
43 lines (31 loc) · 1.04 KB
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
import pygame
from checkers.constants import WIDTH, HEIGHT, SQUARE_SIZE, GREY
from checkers.game import Game
FPS = 60
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption('Checkers') #sets name displayed on the top of the app
def get_pos_from_mouse(pos): #pos: tuple with x and y position
x,y = pos
row = y//SQUARE_SIZE
col = x//SQUARE_SIZE
return row,col
def main():
run = True
clock = pygame.time.Clock()
game = Game(WIN)
while run:
clock.tick(FPS)
if game.winner() != None:
print(game.winner())
run = False
for event in pygame.event.get(): #events, setting button action etc...
match event.type:
case pygame.QUIT:
run = False
case pygame.MOUSEBUTTONDOWN:
pos = pygame.mouse.get_pos()
row, col = get_pos_from_mouse(pos)
game.select(row, col)
game.update()
pygame.QUIT
main()