the game loop while truemain game loop if fallingpiece =noneno falling piece in playso start new piece at the top fallingpiece nextpiece nextpiece getnewpiece(lastfalltime time time(reset lastfalltime if not isvalidposition(boardfallingpiece)return can' fit new piece on the boardso game over checkforquit(the main game loop that starts on line handles all of the code for the main part of the game when pieces are falling to the bottom the fallingpiece variable is set to none after the falling piece has landed this means that the piece in nextpiece should be copied to the fallingpiece variableand random new piece should be put into the nextpiece variable new piece can be generated from the getnewpiece(function the lastfalltime variable is also reset to the current time so that the piece will fall in however many seconds is in fallfreq the pieces that getnewpiece(are positioned little bit above the boardusually with part of the piece already on the board but if this is an invalid position because the board is already filled up there (in which case the isvalidposition(call on line will return false)then we know that the board is full and the player should lose the game when this happensthe rungame(function returns the event handling loop for event in pygame event get()event handling loop if event type =keyupthe event handling loop takes care of when the player rotates the falling piecemoves the falling pieceor pauses the game pausing the game if (event key =k_p)pausing the game displaysurf fill(bgcolorpygame mixer music stop(showtextscreen('paused'pause until key press pygame mixer music play(- email questions to the authoral@inventwithpython com