if boxx !none and boxy !none the mouse is currently over box if not revealedboxes[boxx][boxy] drawhighlightbox(boxxboxy if not revealedboxes[boxx][boxyand mouseclicked revealboxesanimation(mainboard[(boxxboxy)] revealedboxes[boxx][boxytrue set the box as "revealed if firstselection =nonethe current box was the first box clicked firstselection (boxxboxy elsethe current box was the second box clicked check if there is match between the two icons icon shapeicon color getshapeandcolor(mainboardfirstselection[ ]firstselection[ ] icon shapeicon color getshapeandcolor(mainboardboxxboxy if icon shape !icon shape or icon color !icon color icons don' match re-cover up both selections pygame time wait( milliseconds sec coverboxesanimation(mainboard[(firstselection[ ]firstselection[ ])(boxxboxy)] revealedboxes[firstselection[ ]][firstselection [ ]false revealedboxes[boxx][boxyfalse elif haswon(revealedboxes)check if all pairs found gamewonanimation(mainboard pygame time wait( reset the board mainboard getrandomizedboard( revealedboxes generaterevealedboxesdata(false show the fully unrevealed board for second drawboard(mainboardrevealedboxes pygame display update( pygame time wait( replay the start game animation startgameanimation(mainboard firstselection none reset firstselection variable redraw the screen and wait clock tick pygame display update(