slideto right elif spotx =blankx and spoty =blanky slideto up elif spotx =blankx and spoty =blanky slideto down elif event type =keyup check if the user pressed key to slide tile if event key in (k_leftk_aand isvalidmove(mainboardleft) slideto left elif event key in (k_rightk_dand isvalidmove(mainboardright) slideto right elif event key in (k_upk_wand isvalidmove(mainboardup) slideto up elif event key in (k_downk_sand isvalidmove(mainboarddown) slideto down if slideto slideanimation(mainboardslideto'click tile or press arrow keys to slide ' show slide on screen makemove(mainboardslideto allmoves append(slidetorecord the slide pygame display update( fpsclock tick(fps def terminate() pygame quit( sys exit( def checkforquit() for event in pygame event get(quit)get all the quit events terminate(terminate if any quit events are present for event in pygame event get(keyup)get all the keyup events if event key =k_escape terminate(terminate if the keyup event was for the esc key pygame event post(eventput the other keyup event objects back def getstartingboard() return board data structure with tiles in the solved state email questions to the authoral@inventwithpython com