I'm using Python 3.7.4. I'm using Pycharm 2020 Community as my IDE. I'm using Pygame 1.9.6 as my game interpreter.
I was wondering on how I could keep track of the players click on the chess board. I was thinking it should should in my main() running operation, but where in it? So on a chessboard it's an 8x8 board, so 64 squares. Like say they click on the square once to select the square with a piece on it, then click on another square to move said piece to other square if the square is empty. An empty square on my chess board is: "01". Like do I need someway to get to the dimensions of the board say, like a row or a column? I have the dimensions of the board.
WIDTH = HEIGHT = 512 # 400 is another option
DIMENSION = 8 # dimensions of a chess board are 8x8
SQ_SIZE = HEIGHT // DIMENSION
MAX_FPS = 15 # for animations later on
IMAGES = {}
def main():
p.init()
screen = p.display.set_mode((WIDTH, HEIGHT))
clock = p.time.Clock()
screen.fill(p.Color("white"))
gs = ChessEngine.GameState()
loadImages() # only do this once, before the while loop
running = True
while running:
for e in p.event.get():
if e.type == p.QUIT:
running = False
drawGameState(screen, gs)
clock.tick(MAX_FPS)
p.display.flip()
I've never done mouse clicks before so I was wondering on how I could do that?