Skip to content

Instantly share code, notes, and snippets.

@laserbat
Created July 3, 2011 06:55
Show Gist options
  • Save laserbat/1062017 to your computer and use it in GitHub Desktop.
Save laserbat/1062017 to your computer and use it in GitHub Desktop.
def drawmap(self):
"""Drawmap function.
Will draw map. Working with fov.
"""
global gamemap,screen
global io
mapx,mapy=0,0
for mapx in xrange(MAP_W - 1):
for mapy in xrange(MAP_H - 1):
#If cell is in map range
if gamemap[mapx][mapy] != None and(mapx <= 22 and mapx >= 1\
and mapy <= 61 and mapy >= 1):
if gamemap[mapx][mapy].lit and not gamemap[mapx][mapy].\
mob:
if self.inLos(mapx, mapy, x, y):
gamemap[mapx][mapy].visible = True
if gamemap[mapx][mapy].visible: #Visible always explored
gamemap[mapx][mapy].explored = True
if gamemap[mapx][mapy].mob:
gamemap[mapx][mapy].undercell.explored = True
gamemap[mapx][mapy].explored = False
screen.attron(screen.A_BOLD) #Visible is bold
if gamemap[mapx][mapy].type[0] and gamemap[mapx]\
[mapy].plain_cell:
color = 1 #Dots are white not yellow
else:
color = gamemap[mapx][mapy].color #Normal color
# of cell
io.printex(mapx, mapy, gamemap[mapx][mapy].char(),\
color,False) #Print cell.
screen.attroff(screen.A_BOLD)
elif gamemap[mapx][mapy].explored:
screen.attron(screen.A_DIM) #Explored is dim
if gamemap[mapx][mapy].mob and not\
gamemap[mapx][mapy].visible:
if gamemap[mapx][mapy].undercell.door:
io.printex(mapx, mapy,"-",5,False)
else:
io.printex(mapx, mapy,".",5,False)
else:
io.printex(mapx, mapy, gamemap[mapx][mapy].\
char(),5,False)
elif gamemap[mapx][mapy].mob: #For monsters.
if gamemap[mapx][mapy].undercell.explored == True:
io.printex(mapx, mapy, gamemap[mapx][mapy].\
undercell.char(),5,False)
if gamemap[mapx][mapy].lit:
if self.inLos(mapx, mapy, x, y):
screen.attron(screen.A_BOLD)
io.printex(mapx, mapy, gamemap[mapx][mapy]\
.char(),gamemap[mapx][mapy].color,False)
screen.attroff(screen.A_BOLD)
else:
if chars:
self.drawChar(mapx, mapy, level)
screen.attroff(screen.A_DIM)
screen.refresh()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment