def rungame() plays through single game when the game is overthis function returns initialize the board gameboard getblankboard( score fillboardandanimate(gameboard[]scoredrop the initial gems initialize variables for the start of new game firstselectedgem none lastmousedownx none lastmousedowny none gameisover false lastscorededuction time time( clickcontinuetextsurf none while truemain game loop clickedspace none for event in pygame event get()event handling loop if event type =quit or (event type =keyup and event key =k_escape) pygame quit( sys exit( elif event type =keyup and event key =k_backspace return start new game elif event type =mousebuttonup if gameisover return after games endsclick to start new game if event pos =(lastmousedownxlastmousedowny) this event is mouse clicknot the end of mouse drag clickedspace checkforgemclick(event pos else this is the end of mouse drag firstselectedgem checkforgemclick((lastmousedownxlastmousedowny) clickedspace checkforgemclick(event pos if not firstselectedgem or not clickedspace if not part of valid dragdeselect both firstselectedgem none clickedspace none email questions to the authoral@inventwithpython com