def draw(self): for onScreenY in range(self.height): for onScreenX in range(self.width): mapX = onScreenX + self._offsetX mapY = onScreenY + self._offsetY c = self.map.getCell(mapX, mapY) # newly seen if not c.seen: if libtcod.map_is_in_fov(self.fovMap, mapX, mapY): c.discover() # GOTCHA: not else, since we want to catch newly seen cells if c.seen: cv = self.cellToView(c, mapX, mapY) libtcod.console_put_char_ex(self.console, onScreenX, onScreenY, cv.char, cv.fg, cv.bg) if self.map.shroom.active and self.map.shroom.inNetwork( mapX, mapY): # print "%d, %d : %d, %d" % (onScreenX, onScreenY, mapX, mapY) libtcod.console_set_char_background( self.console, onScreenX, onScreenY, Colors.crimson, flag=libtcod.BKGND_ADDALPHA(0.4)) self.setDirty(False)
def draw(self): _max = float(self._max - self._min) val = self._val - self._min chars = len(self.chars) steps = self.width * chars if steps != len(self._colors): self.calculateColors() fullSteps = int(val / _max * steps) fullChars = int(fullSteps / chars) lastChar = self.chars[fullSteps % chars] colorIndex = max(0, min(len(self._colors) - 1, val - 1)) fg = self._colors[colorIndex][0] bg = self._colors[colorIndex][1] for y in range(self.height): for i in range(fullChars): libtcod.console_put_char_ex(self.console, i, y, self.chars[-1], fg, bg) libtcod.console_put_char_ex(self.console, fullChars, y, lastChar, fg, bg)
def drawExplosion(self, a): print "Drawing Explosion at", a.x, a.y for _x, _y in a.explosion.coords: x, y = self.parent.onScreen(_x, _y) if not 0 <= x < self.width or not 0 <= y < self.height: continue libtcod.console_put_char_ex( self.console, x, y, a.explosion.ch, Colors.white, Colors.black) self.parent.map.removeAttack(a)
def draw(self): for sy in range(self.height): for sx in range(self.width): x = sx + self._offsetX y = sy + self._offsetY if (x >= 0 and x < self.map.width and y >= 0 and y < self.map.height): c = self.map.getCell(x, y) cv = self.cellToView(c) libtcod.console_put_char_ex(self.console, sx, sy, cv.char, cv.fg, cv.bg) self.setDirty(False)
def draw(self): for y in range(self.height): for x in range(self.width): c = self._map.getCell(x + self._offsetX, y + self._offsetY) libtcod.console_put_char_ex(self.console, x, y, c.terrain.char, c.terrain.fg, c.terrain.bg) for i in range(len(c.entities)): e = c.entities[i] libtcod.console_put_char(self.console, x, y, e.char) libtcod.console_set_char_foreground( self.console, x, y, e.color)
def draw(self): # we never set ourselves to dirty, so the overlay is always cleared map = self.parent.map for a in map.attacks: x, y = self.parent.onScreen(a.x, a.y) if not 0 <= x < self.width or not 0 <= y < self.height: continue if not a.explosion: libtcod.console_put_char_ex(self.console, x, y, a.ch, Colors.crimson, Colors.black) self.parent.setDirty() else: self.drawExplosion(a) self.parent.setDirty()
def draw(self): for onScreenY in range(self.height): for onScreenX in range(self.width): mapX = onScreenX + self._offsetX mapY = onScreenY + self._offsetY c = self.map.getCell(mapX, mapY) # newly seen if not c.seen: if libtcod.map_is_in_fov(self.fovMap, mapX, mapY): c.discover() # GOTCHA: not else, since we want to catch newly seen cells if c.seen: cv = self.cellToView(c, mapX, mapY) libtcod.console_put_char_ex(self.console, onScreenX, onScreenY, cv.char, cv.fg, cv.bg) if self.map.shroom.active and self.map.shroom.inNetwork(mapX, mapY): # print "%d, %d : %d, %d" % (onScreenX, onScreenY, mapX, mapY) libtcod.console_set_char_background( self.console, onScreenX, onScreenY, Colors.crimson, flag=libtcod.BKGND_ADDALPHA(0.4)) self.setDirty(False)
def putCh(self, x, y, ch, fg, bg): libtcod.console_put_char_ex(self.console, x, y, ch, fg, bg) self.setDirty()