-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
102 lines (67 loc) · 2.02 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import pygame
from src import gameState, board
import ctypes
def readable_board(board):
for row in board:
print(row)
# CONSTANTS
ROWS = 8
COLUMNS = 8
HEIGHT = 300
WIDTH = 300
SQ_SIZE = WIDTH // ROWS
# debug constant
debug = 0
debug_time = 30
# Screen constants
WIDTH = 300
HEIGHT = 300
SIZE = (WIDTH, HEIGHT)
# Color
BLACK = (0,0,0)
WHITE = (255,255,255)
# Game State
num_of_turns = 0
FPS = 30
fpsclock = pygame.time.Clock()
colorTurn = 0
white_turn = True
#--------------------------------------------------------Game starts here--------------------------------------------------------#
pygame.init()
# Set the size of the screen to be 800,800
screen = pygame.display.set_mode(SIZE)
running = True
gs = gameState.GameState()
b = board.Board(gs.board)
b.load_images()
userClicks = []
while running:
for event in pygame.event.get():
#if debug % debug_time == 0:
#print("Under event : ", white_move)
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.MOUSEBUTTONDOWN:
location = pygame.mouse.get_pos()
x,y = location
# Get the row and column of which box is pressed
row = y // SQ_SIZE
column = x // SQ_SIZE
location = (column, row)
squareSelected = location
userClicks.append(squareSelected)
#pieceColumn, pieceRow = userClicks[0]
#print(gs.board[pieceRow][pieceColumn])
if len(userClicks) == 2:
gameStateClass = gameState.Move(userClicks[0], userClicks[1], gs.board, white_turn)
white_turn = gameStateClass.check_piece()
print(white_turn)
readable_board(gs.board)
userClicks = [] # Refresh the users click after making a move
b.draw_game_state(screen)
pygame.display.flip()
# Update the display
pygame.display.update()
fpsclock.tick(FPS)
debug += 1
pygame.quit()