def drawlifemeter(currentlife) lifeboxsize int((windowheight maxlife draw background color of life meter pygame draw rect(displaysurfbgcolor( (maxlife lifeboxsize)) for in range(maxlife) if currentlife >(maxlife )draw solid red box pygame draw rect(displaysurfred( ( lifeboxsize) lifeboxsize) pygame draw rect(displaysurfwhite( ( lifeboxsize) lifeboxsize) draw white outline def getcolorofpaletteat(xy) returns the index of the color in palettecolors that the and parameters are over returns none if and are not over any palette numcolors len(palettecolors xmargin int((windowwidth ((palettesize numcolors(palettegapsize (numcolors ))) top windowheight palettesize for in range(numcolors) find out if the mouse click is inside any of the palettes left xmargin ( palettesize( palettegapsize pygame rect(lefttoppalettesizepalettesize if collidepoint(xy) return return none no palette exists at these xy coordinates def floodfill(boardoldcolornewcolorxy) this is the flood fill algorithm if oldcolor =newcolor or board[ ][ !oldcolor return board[ ][ynewcolor change the color of the current box make the recursive call for any neighboring boxes if floodfill(boardoldcolornewcolorx yon box to the left if boardwidth floodfill(boardoldcolornewcolorx yon box to the right