Short explanation: Trying to move game pieces with pygame
I circled back to a project I build a couple years ago and wanted to add a GUI, but I am having the most difficult time.
Move == True executes but pieces are not displaying in new positions
Here is my code Github
if event.type == pygame.MOUSEBUTTONDOWN:
selection = (mouse_pos_to_square(event.pos))
allowed_sq = game.index_to_move(selection)
if len(clicks) == 0 and game.get_square_occupant(allowed_sq) == game.get_active_player():
clicks.append(selection)
elif len(clicks) == 1 and game.get_square_occupant(allowed_sq) == "NONE":
clicks.append(selection)
source = game.index_to_move(clicks[0])
destination = game.index_to_move(clicks[1])
print(f"Move attempt: {source} → {destination}")
move = game.make_move(source, destination)
print(move)
if move == True:
print(f"Moving {source} → {destination}")
pygame.draw.circle(display_surface, (0, 0, 0), rect.center, SQUARE_SIZE // 2 - 10)
clicks = []
I spent some time going over it, I added a print statement for the move variable on line 107 and it seems that it is returning False. But also there is some movements, such at i2 > f2 that returns True and executes the rest of the code but it still does not draw the pieces at the new space as expected.
It was brought to my attention that I was loading display.surface.fill after drawing my pieces, I have since moved that above the code I am currently working with.