textrect textsurf get_rect( textrect center left int(tilesize adjxtop int(tilesize adjy displaysurf blit(textsurftextrect def maketext(textcolorbgcolortopleft) create the surface and rect objects for some text textsurf basicfont render(texttruecolorbgcolor textrect textsurf get_rect( textrect topleft (topleft return (textsurftextrect 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] lefttop getlefttopoftile( width boardwidth tilesize height boardheight tilesize pygame draw rect(displaysurfbordercolor(left top width height ) displaysurf blit(reset_surfreset_rect displaysurf blit(new_surfnew_rect displaysurf blit(solve_surfsolve_rect def slideanimation(boarddirectionmessageanimationspeed) notethis function does not check if the move is valid blankxblanky getblankposition(board if direction =up movex blankx movey blanky elif direction =down movex blankx