if the event object was either quit event or keyup event for the esc keythen the program should terminate otherwisein the event of mousemotion event (that isthe mouse cursor has movedor mousebuttonup event (that isa mouse button was pressed earlier and now the button was let up)the position of the mouse cursor should be stored in the mousex and mousey variables if this was mousebuttonup eventmouseclicked should also be set to true once we have handled all of the eventsthe values stored in mousexmouseyand mouseclicked will tell us any input that player has given us now we should update the game state and draw the results to the screen checking which box the mouse cursor is over boxxboxy getboxatpixel(mousexmouseyif boxx !none and boxy !nonethe mouse is currently over box if not revealedboxes[boxx][boxy]drawhighlightbox(boxxboxythe getboxatpixel(function will return tuple of two integers the integers represent the xy board coordinates of the box that the mouse coordinates are over how getboxatpixel(does this is explained later all we have to know for now is that if the mousex and mousey coordinates were over boxa tuple of the xy board coordinates are returned by the function and stored in boxx and boxy if the mouse cursor was not over any box (for exampleif it was off to the side of the board or in gap in between boxesthen the tuple (nonenoneis returned by the function and boxx and boxy will both have none stored in them we are only interested in the case where boxx and boxy do not have none in themso the next several lines of code are in the block following the if statement on line that checks for this case if execution has come inside this blockwe know the user has the mouse cursor over box (and maybe has also clicked the mousedepending on the value stored in mouseclickedthe if statement on line checks if the box is covered up or not by reading the value stored in revealedboxes[boxx][boxyif it is falsethen we know the box is covered whenever the mouse is over covered up boxwe want to draw blue highlight around the box to inform the player that they can click on it this highlighting is not done for boxes that are already uncovered the highlight drawing is handled by our drawhighlightbox(functionwhich is explained later if not revealedboxes[boxx][boxyand mouseclickedrevealboxesanimation(mainboard[(boxxboxy)]email questions to the authoral@inventwithpython com