def turn(self):
global board,whos_turn,n_of_turn
for event in pygame.event.get():
if (event.type == pygame.MOUSEBUTTONDOWN):
mouse_pos = pygame.mouse.get_pos()
for i in range(3):
for j in range(3):
if (sqr_pos[i][j][0] < mouse_pos[0] and sqr_pos[i][j][0] + sqr_size[0] > mouse_pos[0] and
sqr_pos[i][j][1] < mouse_pos[1] and sqr_pos[i][j][1] + sqr_size[1] > mouse_pos[
1] and board[i*3+j] == NO_ONE):
board[i*3+j] = whos_turn
n_of_turn += 1
who_won(tuple(board) ,whos_turn, n_of_turn)
reward_consider(winner,tuple(board),p1,p2)
whos_turn = self.ID ^ 1
elif (event.type == pygame.K_ESCAPE):
esc_pause()
if (event.type == pygame.QUIT):
sys.exit()
# -------------------------------------------
评论列表
文章目录