Skip to content

Commit

Permalink
Update chess_main.py
Browse files Browse the repository at this point in the history
Added menu functionality to choose game settings.
  • Loading branch information
zachartrand authored May 27, 2021
1 parent c6a61c6 commit 999e8ea
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions chess_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

import os
import sys
import shelve

import pygame as p

import chess_engine
import chess_ai as ai
from chess_themes import themes
from chess_menu import mainMenu

CAPTION = 'Chess'
WIDTH = HEIGHT = 720 # Width and height of board in pixels.
Expand All @@ -38,14 +38,15 @@ def main():
This will handle user input and updating the graphics.
"""
global screen, clock, theme, gs, highlight_last_move, UPSIDEDOWN
humanWhite, humanBlack, theme_name = mainMenu()
if theme_name not in themes.keys():
theme_name = "blue"
p.init()
screen = p.display.set_mode((WIDTH, HEIGHT))
p.display.set_caption(CAPTION)
clock = p.time.Clock()
screen.fill(p.Color(28, 28, 28))
with shelve.open(os.path.join('settings', 'settings')) as settings:
# TODO: In GUI, make this variable customizable.
theme = themes[settings['theme']]
theme = themes[theme_name]
gs = chess_engine.GameState()
board = gs.board
squares = board.squares
Expand All @@ -59,8 +60,8 @@ def main():
playerClicks = [] # Keep track of player clicks
# (two tuples: [(4, 6), (4, 4)] would be (e2 pawn to) e4)
highlight_last_move = True
humanWhite = True # True if human player is white.
humanBlack = True # True if human player is black.
# humanWhite = True # True if human player is white.
# humanBlack = True # True if human player is black.
if humanBlack and not humanWhite:
UPSIDEDOWN = True

Expand Down

0 comments on commit 999e8ea

Please sign in to comment.