A BUG IN PYGAME in memory puzzle game

I am going through a python book tutorial. It can be found here

I want to notify the author that there is a bug in the program, but I also want to give him a working solution.

The bug is if the user clicks on a card that card should go from covered to uncovered.
This does work on the first card. On the second card however, the card remains covered on the second click.

The way it should work is: The user clicks a card the shape is revealed then the user clicks a different card the shape is revealed. Then the game checks if the 1st card matched the second card.

I have gone through this book but not found the card game.
Which one you are asking for?

Maybe my first post was not clear. Here is my attempt at a better explanation.
The full code can be found here. It is from a tutorial

In this conditional statement

                    if icon1shape != icon2shape or icon1color != icon2color:
                        # Icons don't match. Re-cover up both selections.
                        # coverBoxesAnimation(mainBoard, [(firstSelection[0], firstSelection[1]), (boxx, boxy)])
                        revealedBoxes[firstSelection[0]][firstSelection[1]] = False
                        revealedBoxes[boxx][boxy] = False

This is supposed to cover up both of the cards if the first selection and the selection do not equal to each other.

The bug that i am facing is that pygame.display.update() runs right after i make the second selection making the 2nd card chosen to reveal itself and cover itself right away. This happens in a fraction of a second. I tried pygame.time.wait(1000) right below the conditional statement and it did not work.

Welcome to the community.

1 Like

Thanks @zootechdrum
People like you will always help to build better.