the maketext(function handles creating the surface and rect objects for positioning text on the screen instead of doing all these calls each time we want to make text on the screenwe can just call maketext(instead this saves us on the amount of typing we have to do for our program (though drawtile(makes the calls to render(and get_rect(itself because it positions the text surface object by the center point rather than the topleft point and uses transparent background color drawing the board def drawboard(boardmessage) displaysurf fill(bgcolor if message textsurftextrect maketext(messagemessagecolorbgcolor displaysurf blit(textsurftextrect for tilex in range(len(board)) for tiley in range(len(board[ ])) if board[tilex][tiley] drawtile(tilextileyboard[tilex][tiley]this function handles drawing the entire board and all of its tiles to the displaysurf display surface object the fill(method on line completely paints over anything that used to be drawn on the display surface object before so that we start from scratch line to handles drawing the message at the top of the window we use this for the --generating new puzzle |and other text we want to display at the top of the window remember that if statement conditions consider the blank string to be false valueso if message is set to 'then the condition is false and lines and are skipped nextnested for loops are used to draw each tile to the display surface object by calling the drawtile(function drawing the border of the board lefttop getlefttopoftile( width boardwidth tilesize height boardheight tilesize pygame draw rect(displaysurfbordercolor(left top width height ) lines to draw border around the tiles the top left corner of the boarder will be pixels to the left and pixels above the top left corner of the tile at board coordinates ( the width and height of the border are calculated from the number of tiles wide and high the board is (stored