floodfill(mapobjx- yoldcharacternewcharactercall left if len(mapobj[ ] and mapobj[ ][ + =oldcharacter floodfill(mapobjxy+ oldcharacternewcharactercall down if and mapobj[ ][ - =oldcharacter floodfill(mapobjxy- oldcharacternewcharactercall up def drawmap(mapobjgamestateobjgoals) """draws the map to surface objectincluding the player and stars this function does not call pygame display update()nor does it draw the "leveland "stepstext in the corner "" mapsurf will be the single surface object that the tiles are drawn onso that it is easy to position the entire map on the displaysurf surface object firstthe width and height must be calculated mapsurfwidth len(mapobjtilewidth mapsurfheight (len(mapobj[ ] (tileheight tilefloorheighttileheight mapsurf pygame surface((mapsurfwidthmapsurfheight) mapsurf fill(bgcolorstart with blank color on the surface draw the tile sprites onto this surface for in range(len(mapobj)) for in range(len(mapobj[ ])) spacerect pygame rect(( tilewidthy (tileheight tilefloorheight)tilewidthtileheight) if mapobj[ ][yin tilemapping basetile tilemapping[mapobj[ ][ ] elif mapobj[ ][yin outsidedecomapping basetile tilemapping[' first draw the base ground/wall tile mapsurf blit(basetilespacerect if mapobj[ ][yin outsidedecomapping draw any tree/rock decorations that are on this tile mapsurf blit(outsidedecomapping[mapobj[ ][ ]]spacerect elif (xyin gamestateobj['stars'] if (xyin goals goal and star are on this spacedraw goal first mapsurf blit(imagesdict['covered goal']spacerect then draw the star sprite mapsurf blit(imagesdict['star']spacerect elif (xyin goals draw goal without star on it mapsurf blit(imagesdict['uncovered goal']spacerect