File tree 1 file changed +43
-0
lines changed
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Assets: https://techwithtim.net/wp-content/uploads/2020/09/assets.zip
2
+ import pygame
3
+ from checkers .constants import WIDTH , HEIGHT , SQUARE_SIZE , RED
4
+ from checkers .game import Game
5
+ from minimax .algorithm import minimax
6
+
7
+ FPS = 60
8
+
9
+ WIN = pygame .display .set_mode ((WIDTH , HEIGHT ))
10
+ pygame .display .set_caption ('Checkers' )
11
+
12
+ def get_row_col_from_mouse (pos ):
13
+ x , y = pos
14
+ row = y // SQUARE_SIZE
15
+ col = x // SQUARE_SIZE
16
+ return row , col
17
+
18
+ def main ():
19
+ run = True
20
+ clock = pygame .time .Clock ()
21
+ game = Game (WIN )
22
+
23
+ while run :
24
+ clock .tick (FPS )
25
+
26
+ if game .winner () != None :
27
+ print (game .winner ())
28
+ run = False
29
+
30
+ for event in pygame .event .get ():
31
+ if event .type == pygame .QUIT :
32
+ run = False
33
+
34
+ if event .type == pygame .MOUSEBUTTONDOWN :
35
+ pos = pygame .mouse .get_pos ()
36
+ row , col = get_row_col_from_mouse (pos )
37
+ game .select (row , col )
38
+
39
+ game .update ()
40
+
41
+ pygame .quit ()
42
+
43
+ main ()
You can’t perform that action at this time.
0 commit comments