the showtextscreen(will be used for the start screenthe game over screenand also for pause screen (the pause screen is explained later in this while checkforkeypress(=nonepygame display update(fpsclock tick(we want the text to stay on the screen until the user presses key this small loop will constantly call pygame display update(and fpsclock tick(until checkforkeypress(returns value other than none this happens when the user presses key the checkforquit(function 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 the checkforquit(function can be called to handle any events that will cause the program to terminate this happens if there are any quit events in the event queue (this is handle by lines and )or if there is keyup event of the esc key the player should be able to press the esc key at any time to quit the program because the pygame event get(call on line pulls out all of the keyup events (including events for keys other than the esc key)if the event is not for the esc keywe want to put it back into the event queue by calling the pygame event post(function the calculatelevelandfallfreq(function def calculatelevelandfallfreq(score) based on the scorereturn the level the player is on and how many seconds pass until falling piece falls one space level int(score fallfreq (level return levelfallfreq every time the player completes linetheir score will increase by one point every ten pointsthe game goes up level and the pieces start falling down faster both the level and the falling frequency can be calculated from the score that is passed to this function