def draw(self): if libtcod.map_is_in_fov(gameconfig.FOV_MAP, self.x, self.y): libtcod.console_set_default_foreground(self.con, self.color) libtcod.console_set_char_background(self.con, self.x, self.y, self.color, libtcod.BKGND_SET) libtcod.console_put_char(self.con, self.x, self.y, self.char, libtcod.BKGND_NONE)
def draw(self, console, x, y): x += (camera.Camera.X / 2) y += (camera.Camera.Y / 2) libtcod.console_set_char_background(console, x, y, self.backgroundColor, libtcod.BKGND_SET) if self.symbol and self.symbolColor: libtcod.console_set_default_foreground(console, self.symbolColor) libtcod.console_put_char(console, x, y, self.symbol, libtcod.BKGND_NONE)
def RenderEverything(): player = None for ent in ActiveEntityList: if 'ControlledByPlayer' and 'CanSee' in ent.flags: player = ent break #player = TestDummy for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): terraintile = Map[x][y] if player != None: canseetile = player.Vision.CanSee(x,y) if canseetile: libtcod.console_set_char_background(MainConsole,x,y,terraintile.bgcolour,libtcod.BKGND_SET) libtcod.console_set_default_foreground(MainConsole,terraintile.fgcolour) libtcod.console_put_char(MainConsole, x, y, terraintile.char, libtcod.BKGND_NONE) else: libtcod.console_set_char_background(MainConsole,x,y,terraintile.bgcolour*UNSEEN_TERRAIN_DARKNESS,libtcod.BKGND_SET) libtcod.console_set_default_foreground(MainConsole,terraintile.fgcolour*UNSEEN_TERRAIN_DARKNESS) libtcod.console_put_char(MainConsole, x, y, terraintile.char, libtcod.BKGND_NONE) for ent in ActiveEntityList: ent.Draw() DrawAllPaths(MainConsole) RenderGui() libtcod.console_blit(MainConsole, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0) libtcod.console_blit(GUIBottomConsole, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, GUI_BOTTOM_Y)
def render_all(): for entity in entities: entity.draw() for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): wall = map[x][y].block_sight if wall: libtcod.console_set_char_background(con, x, y, color_dark_wall, libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, color_dark_ground, libtcod.BKGND_SET) libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0) libtcod.console_set_default_background(panel, libtcod.black) libtcod.console_clear(panel) global player render_bar(30, 1, BAR_WIDTH, 'HP', player.stats["health"], 100, libtcod.light_red, libtcod.darker_red) global events render_text(10, 3, "Inventory", player.inventory) render_text(5, 5, "Events", events) libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0, PANEL_Y)
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height, bar_width, panel_height, panel_y, colors): if fov_recompute: for y in range(game_map.height): for x in range(game_map.width): visible = lcod.map_is_in_fov(fov_map, x, y) wall = game_map.tiles[x][y].block_sight if visible or game_map.tiles[x][y].explored: game_map.tiles[x][y].explored = True if wall: lcod.console_set_char_background(con, x, y, colors.get("dark_wall"), lcod.BKGND_SET) else: lcod.console_set_char_background(con, x, y, colors.get("dark_ground"), lcod.BKGND_SET) entities_in_render_order = sorted(entities, key=lambda x: x.render_order.value) for entity in entities_in_render_order: draw_entity(con, entity, fov_map) lcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0) lcod.console_set_default_background(panel, lcod.black) lcod.console_clear(panel) y = 1 for message in message_log.messages: lcod.console_set_default_foreground(panel, message.color) lcod.console_print_ex(panel, message_log.x, y, lcod.BKGND_NONE, lcod.LEFT, message.text) y += 1 render_bar(panel, 1, 1, bar_width, "HP", player.fighter.hp, player.fighter.max_hp, lcod.light_red, lcod.darker_red) lcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y)
def render(cmap): for y in range(screen_h): for x in range(screen_w): if cmap[x][y] == '#': libtcod.console_set_char_background(game_console, x, y, orange, libtcod.BKGND_SET) if cmap[x][y] == '!': libtcod.console_set_char_background(game_console, x, y, blue, libtcod.BKGND_SET)
def get_targeting_radius(con, panel, x, y, entities, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height, bar_width, panel_height, panel_y, mouse, colors, game_state, camera, left_click, right_click, animation_console): #여기서부터 커서 libtcod.console_set_char_background(animation_console, x, y, libtcod.dark_yellow) libtcod.console_blit(animation_console, 0, 0, screen_width, screen_height, 0, 0, 0) libtcod.console_flush() #마우스 위치 변경 감지시 클리어 if mouse.dcx != 0 or mouse.dcy != 0 or mouse.dcx != 0 and mouse.dcy != 0: libtcod.console_clear(animation_console) #왼클릭 올 오른클릭 감지시 좌표 리턴 if handle_mouse(mouse).get('left_click'): left_click = (x, y) return left_click elif handle_mouse(mouse).get('right_click'): right_click = (x, y) return right_click #다음 좌표 변경까지 0.1초 대기(깜빡임 방지) sleep(0.1) libtcod.console_clear(animation_console)
def target_monster(max_range=None): gui.message('Left-click on target, or right-click to cancel.', libtcod.light_cyan) #primitive function highlighting range. Ideally would be implemented in read-only attribute of tile rangemap = defn.fov_map libtcod.map_compute_fov(rangemap, defn.player.x, defn.player.y, max_range, defn.FOV_LIGHT_WALLS, defn.FOV_ALGO) #returns a clicked monster inside FOV up to a range, or None if right-clicked while True: (x, y) = target_tile(max_range) if x is None: #player cancelled #remove highlight for y in range(defn.MAP_HEIGHT): for x in range(defn.MAP_WIDTH): if libtcod.map_is_in_fov(rangemap, x, y): libtcod.console_set_char_background(defn.con, x, y, defn.dungeon[x][y].color, libtcod.BKGND_SET) return None #return the first clicked creature, otherwise continue looping for obj in defn.dungeon[x][y].objects: if obj.creature: return obj
def target_tile(actor, max_range=None): """ Return the position of a tile left-clicked in player's FOV (optionally in a range), or (None,None) if right-clicked. """ (key, mouse) = poll() (ox, oy) = (mouse.cx, mouse.cy) using_mouse = False using_keyboard = False (kx, ky) = renderer.ScreenCoords.fromWorldCoords(actor.camera_position, actor.pos) pos = None while True: # Render the screen. This erases the inventory and shows # the names of objects under the mouse. libtcod.console_flush() (key, mouse) = poll() renderer.render_all(actor, (kx, ky)) actor.current_map.fov_needs_recompute = False if (mouse.cx != ox or mouse.cy != oy): using_mouse = True using_keyboard = False (key_pressed, direction, shift) = parse_move(key) if key_pressed: using_keyboard = True if using_mouse: (ox, oy) = (mouse.cx, mouse.cy) using_mouse = False if direction: kx += direction.x ky += direction.y if using_mouse: (kx, ky) = (mouse.cx, mouse.cy) pos = renderer.ScreenCoords.toWorldCoords(actor.camera_position, (kx, ky)) libtcod.console_set_default_background(renderer._overlay, libtcod.black) libtcod.console_clear(renderer._overlay) (ux, uy) = renderer.ScreenCoords.fromWorldCoords(actor.camera_position, actor.pos) libtcod.line_init(ux, uy, kx, ky) nx, ny = libtcod.line_step() while ((not (nx is None)) and nx >= 0 and ny >= 0 and nx < config.MAP_PANEL_WIDTH and ny < config.MAP_PANEL_HEIGHT): libtcod.console_set_char_background(renderer._overlay, nx, ny, libtcod.sepia, libtcod.BKGND_SET) nx, ny = libtcod.line_step() if mouse.rbutton_pressed or key.vk == libtcod.KEY_ESCAPE: libtcod.console_clear(renderer._overlay) return None # Accept the target if the player clicked in FOV # and within the range specified. if ((mouse.lbutton_pressed or key.vk == libtcod.KEY_ENTER) and libtcod.map_is_in_fov(actor.current_map.fov_map, pos.x, pos.y) and (max_range is None or actor.distance(pos) <= max_range)): libtcod.console_clear(renderer._overlay) return pos
def render_top_down(): for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): z = -1 for zDepth in xrange(MAP_DEPTH - 1, -1, -1): #Drop a line down on each square, compute if we can see that based on previously processed squares if map[x][y][zDepth].block_sight: z = zDepth break print str((x, y, z)) if z != -1: tile = map[x][y][z] r, g, b = tile.light_color #If player can see more than 1 adjacent? tile in that z-depth, it's a wall r += z g += z b += z libtcod.console_set_char_background(con, x, y, libtcod.Color(r, g, b), libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, libtcod.Color(0, 0, 0), libtcod.BKGND_SET) #Draw player for object in objects: object.draw() #blit the contents of "con" to the root console libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
def recompute_fov(self, clear_all=False): x,y = self.map.map_entrance if self.player is not None: x,y = self.player.pos libtcod.map_compute_fov( self.fov_map, x,y, player.Player.torch_radius, self.fov_light_walls, self.fov_algo ) for x,y, cell in self.map.iter_cells_with_coords(): visible = libtcod.map_is_in_fov(self.fov_map, x,y) if visible and not cell.explored: cell.explored = True color = libtcod.black #if True: if cell.explored: wall = cell.block_sight walkable = not cell.blocked if wall or walkable: color = { True: {True: self.color_light_wall, False: self.color_light_ground}, False: {True: self.color_dark_wall, False: self.color_dark_ground} }[visible][wall] elif not walkable: color = libtcod.Color(100,100,200) if cell.explored or clear_all: libtcod.console_set_char_background(self.con, x, y, color, libtcod.BKGND_SET)
def move(self, new): libtcod.console_set_char_foreground(0, self.x + self.cursor_pos, self.y, WHITE) libtcod.console_set_char_background(0, self.x + self.cursor_pos, self.y, BLACK) self.flush = True self.putCursor(new)
def tint_tile(coordinates, color, console): """Multiplies background color of one tile by another color. Does not affect foreground""" #Define location x0 = coordinates[0] x1 = coordinates[1] #Modify the background color lib.console_set_char_background(console, x0, x1, color, lib.BKGND_MULTIPLY)
def render_conway_sim(sim): for x in range(sim.width): for y in range(sim.height): if sim[x, y]: if sim.color: color = sim[x, y] else: color = tcod.green tcod.console_set_char_background(0, x, y, color)
def _draw_fov_using_terrain(player): """ Overly optimized: this code inlines Map.terrain_at(), Map.is_explored(), and ScreenCoords.toWorldCoords() in order to get a 2.5x speedup on large maps. """ libtcod.console_clear(_con) current_map = player.current_map pos = algebra.Location(0, 0) for screen_y in range(min(current_map.height, config.MAP_PANEL_HEIGHT)): pos.set(player.camera_position.x, player.camera_position.y + screen_y) for screen_x in range(min(current_map.width, config.MAP_PANEL_WIDTH)): # pos = ScreenCoords.toWorldCoords(player.camera_position, (screen_x, screen_y)) visible = libtcod.map_is_in_fov(current_map.fov_map, pos.x, pos.y) # terrain = current_map.terrain_at(pos) terrain = map.terrain_types[current_map.terrain[pos.x][pos.y]] if not visible: # if current_map.is_explored(pos): if current_map._explored[pos.x][pos.y]: libtcod.console_set_char_background(_con, screen_x, screen_y, terrain.unseen_color, libtcod.BKGND_SET) else: libtcod.console_set_char_background(_con, screen_x, screen_y, terrain.seen_color, libtcod.BKGND_SET) current_map.explore(pos) pos.x += 1
def render_all(): global color_light_wall global color_light_ground #go through all tiles, and set their background color render_score() for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): if map[x][y].blocked: libtcod.console_set_char_background(con, x, y, color_dark_wall, libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, color_dark_ground, libtcod.BKGND_SET) #draw all objects in the list for object in objects: if (object.move(*object.direction)): objects.remove(object) else: check_collide(object) object.draw() #blit the contents of "con" to the root console libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
def render(self): self.gamemap.fov.recompute() for x in range(self.gamemap.width): for y in range(self.gamemap.height): tile = self.gamemap.map[x][y] wall = tile.block_sight if not self.gamemap.fov.visible(x, y): if tile.explored: libtcod.console_set_char_background( self.panel, x, y, tile.shroud_bg_color, libtcod.BKGND_SET) libtcod.console_set_default_foreground( self.panel, tile.shroud_fg_color) libtcod.console_put_char(self.panel, x, y, tile.character, libtcod.BKGND_NONE) else: libtcod.console_set_char_background( self.panel, x, y, tile.bg_color, libtcod.BKGND_SET) libtcod.console_set_default_foreground( self.panel, tile.fg_color) libtcod.console_put_char(self.panel, x, y, tile.character, libtcod.BKGND_NONE) self.gamemap.map[x][y].explored = True self.player.render(self.panel)
def draw_rectangle(console, color, x, y, width, height=None, flags=tcod.BKGND_SET): """Draw a rectangle on target console. If height is not provided, draw a square by default""" if height is None: height = width for _y in xrange(y, y + height): for _x in xrange(x, x + width): tcod.console_set_char_background(console, _x, _y, color, flags)
def render(self, console: tcod.console.Console): for y in range(self.height): for x in range(self.width): wall = self.tiles[x][y].block_sight if wall: libtcod.console_set_char_background(console, x, y, color_dark_wall, libtcod.BKGND_SET) else: libtcod.console_set_char_background(console, x, y, color_dark_ground, libtcod.BKGND_SET)
def clear_target(cursor, crange, size): if crange > 0: #clear the highlighted range for tile in circle(player.x, player.y, crange): libtcod.console_set_char_background(con, tile[0], tile[1], libtcod.black, flag=libtcod.BKGND_SET) for tile in circle(cursor.x, cursor.y, size): #clear the reticle itself libtcod.console_set_char_background(con, tile[0], tile[1], libtcod.black, flag=libtcod.BKGND_SET)
def setBgColor(self, x, y, col, flag): screenX = x + self.x + 1 screenY = y + self.y + 1 if isinstance(col, type(b"")): col = getattr(libtcod, col) libtcod.console_set_char_background(self.console, screenX, screenY, col, flag)
def render_all(): global fov_recompute for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): visible = libtcod.map_is_in_fov(fov_map, x, y) wall = map[x][y].block_sight if not visible: if map[x][y].explored: if wall: libtcod.console_put_char_ex(con, x, y, wall_tile, libtcod.grey, color_dark_ground) else: libtcod.console_set_char_background(con, x, y, color_dark_ground, libtcod.BKGND_SET) else: if wall: libtcod.console_put_char_ex(con, x, y, wall_tile, libtcod.white, color_light_ground) else: libtcod.console_set_char_background(con, x, y, color_light_ground, libtcod.BKGND_SET) map[x][y].explored = True for object in objects: if object != player: object.draw() player.draw() libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0) if fov_recompute: fov_recompute = False libtcod.map_compute_fov(fov_map, player.x, player.y, TORCH_RADIUS, FOV_LIGHT_WALLS, FOV_ALGO) libtcod.console_set_default_foreground(con, libtcod.white) libtcod.console_set_default_background(panel, libtcod.black) libtcod.console_clear(panel) #messages y = 1 for (line, color) in game_msgs: libtcod.console_set_default_foreground(panel, color) libtcod.console_print_ex(panel, MSG_X, y, libtcod.BKGND_NONE, libtcod.LEFT, line) y += 1 #health bar render_bar(1, 1, BAR_WIDTH, 'HP', player.fighter.hp, player.fighter.max_hp, libtcod.light_red, libtcod.darker_red) #mana bar render_bar(1, 3, BAR_WIDTH, 'Mana', player.fighter.mana, player.fighter.max_mana, libtcod.light_blue, libtcod.darker_blue) #current dungeon level libtcod.console_print_ex(panel, 1, 5, libtcod.BKGND_NONE, libtcod.LEFT, 'Dungeon level ' + str(dungeon_level)) #names of objects under mouse libtcod.console_set_default_foreground(panel, libtcod.light_gray) libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT, get_names_under_mouse()) libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0, PANEL_Y)
def get_neighbors(size, x, y): neighbors = 0 libtcod.console_set_char_background(con, x, y, libtcod.red, libtcod.BKGND_SET) for new_x in xrange(x - size, x + size): for new_y in xrange(y - size, y + size): for tree in trees: if tree.x == new_x and tree.y == new_y: neighbors += 1 return neighbors
def updateConsole(self): for x in range(self.width): for y in range(self.height): c = self.cells[x][y] col = c.state.colour libtcod.console_set_char_background(self.console, x, y, col) if self._showFrame: libtcod.console_print(self.console, 0, self.height - 1, "Frame: " + str(self.frame))
def drawPlayers(player, visibleOffsetX, visibleOffsetY): playerX, playerY = player.GetLocation() visible, screenX, screenY = getScreenCoordinates(playerX, playerY, visibleOffsetX, visibleOffsetY) if (visible == False): # cannot see me :) return libtcod.console_put_char(0, screenX, screenY, '@',libtcod.BKGND_NONE) libtcod.console_set_char_background(0, screenX, screenY, libtcod.black, libtcod.BKGND_SET)
def drawCar(car, visibleOffsetX, visibleOffsetY, backgroundColor): visible, screenX, screenY = getScreenCoordinates(car.X, car.Y, visibleOffsetX, visibleOffsetY) if (visible == False): # cannot see me :) return libtcod.console_put_char(0, screenX, screenY, car.DisplayChar, libtcod.BKGND_NONE) libtcod.console_set_char_foreground(0, screenX, screenY, car.DisplayColor) libtcod.console_set_char_background(0, screenX, screenY, backgroundColor, libtcod.BKGND_SET)
def DrawPath(self,console): for i in range(0,libtcod.dijkstra_size(self.currentpath)): if not i == libtcod.dijkstra_size(self.currentpath)-1: x,y = libtcod.dijkstra_get(self.currentpath,i) libtcod.console_set_default_background(console,libtcod.yellow) libtcod.console_put_char(console, x, y, '=', libtcod.BKGND_SET) else: x,y = libtcod.dijkstra_get(self.currentpath,i) libtcod.console_set_char_background(console, x, y, libtcod.blue,libtcod.BKGND_SET)
def render_all(): # draw to the screen libtcod.console_clear(0) for y in range(SCREEN_HEIGHT): for x in range(SCREEN_WIDTH): wall = map[x][y].block_sight if wall: libtcod.console_set_char_background(0, x, y, libtcod.darkest_gray) else: libtcod.console_set_char_background(0, x, y, libtcod.dark_gray)
def draw_all_tiles(): for tile in TILES: tcod.console_set_char_foreground(ITEM_WINDOW, TILES.keys().index(tile), 0, TILES[tile]['color'][0]) tcod.console_set_char_background(ITEM_WINDOW, TILES.keys().index(tile), 0, TILES[tile]['color'][1]) tcod.console_set_char(ITEM_WINDOW, TILES.keys().index(tile), 0, TILES[tile]['icon'])
def highlight_mouse_position(): # mouse is updated in game.handle_keys, so we don't need to update it (x, y) = (ui.mouse.cx, ui.mouse.cy) if x < MAP_WIDTH and y < MAP_HEIGHT: map_x = x + camera_x map_y = y + camera_y if tcod.map_is_in_fov(terrain.map.fov_map, map_x, map_y): global prev_mouse_pos prev_mouse_pos = (x, y) tcod.console_set_char_background(con, x, y, MOUSE_HIGHLIGHT_COLOR)
def render_all(con, entities, game_map, fov_map, fov_recompute, screen_width, screen_height, colors, player): # Draws all the tiles in a map if fov_recompute: for y in range(game_map.height): for x in range(game_map.width): visible = libtcod.map_is_in_fov(fov_map, x, y) wall = game_map.tiles[x][y].block_sight if visible: if wall: libtcod.console_set_default_foreground( con, libtcod.black) libtcod.console_set_char_background( con, x, y, colors.get('light_wall'), libtcod.BKGND_SET) libtcod.console_put_char(con, x, y, '#', libtcod.BKGND_NONE) else: libtcod.console_set_default_foreground( con, libtcod.black) libtcod.console_set_char_background( con, x, y, colors.get('light_ground'), libtcod.BKGND_SET) libtcod.console_put_char(con, x, y, '.', libtcod.BKGND_NONE) game_map.tiles[x][y].explored = True else: if game_map.tiles[x][y].explored: if wall: libtcod.console_set_default_foreground( con, libtcod.black) libtcod.console_set_char_background( con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET) libtcod.console_put_char(con, x, y, 178, libtcod.BKGND_NONE) else: libtcod.console_set_default_foreground( con, libtcod.black) libtcod.console_set_char_background( con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET) libtcod.console_put_char(con, x, y, 176, libtcod.BKGND_NONE) else: libtcod.console_set_char_background( con, x, y, colors.get('unexplored'), libtcod.BKGND_SET) # Draws all entities on top of the tiles for entity in entities: draw_entity(con, entity, fov_map, colors) draw_UI(con, player, screen_width, screen_height) libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
def render_all(): global game_msgs, fov_recompute, dis_x, dis_y #draw all the map if fov_recompute: fov_recompute = False libtcod.map_compute_fov(fov_map, player.x, player.y, TORCH_RADIUS, FOV_LIGHT_WALLS, FOV_ALGO) for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): visible = libtcod.map_is_in_fov(fov_map, x, y) if visible: libtcod.console_set_char_background(con, x, y, libtcod.darkest_grey, libtcod.BKGND_SET) map[x][y].draw(x,y) else: libtcod.console_set_char_background(con, x, y, libtcod.black, libtcod.BKGND_SET) libtcod.console_put_char(con, x, y, ' ', libtcod.BKGND_NONE) #draw all objects in the list for object in objects: if object != player: object.draw() player.draw() fov_recompute = True #blit the contents of "con" to the root console and present it #calculate the player point dis_x = player.x - DISPLAY_WIDTH / 2 dis_y = player.y - DISPLAY_HEIGHT / 2 if dis_x < 0: dis_x = 0 elif dis_x > MAP_WIDTH - DISPLAY_WIDTH: dis_x = MAP_WIDTH - DISPLAY_WIDTH if dis_y < 0: dis_y = 0 elif dis_y > MAP_HEIGHT - DISPLAY_HEIGHT: dis_y = MAP_HEIGHT - DISPLAY_HEIGHT libtcod.console_blit(con, dis_x, dis_y, DISPLAY_WIDTH, DISPLAY_HEIGHT, 0, 0, 0) libtcod.console_set_default_background(panel, libtcod.black) libtcod.console_clear(panel) #show the player's stats render_bar(1, 1, BAR_WIDTH, 'HP', player.fighter.hp, player.fighter.max_hp, libtcod.light_red, libtcod.darker_red) #show message right the bar y = 1 for (line, color) in game_msgs: libtcod.console_set_default_foreground(panel, color) libtcod.console_print_ex(panel, MSG_X, y, libtcod.BKGND_NONE, libtcod.LEFT, line) y += 1 libtcod.console_blit(panel, 0 , 0, SCREEN_WIDTH, PANEL_HEIGHT, 0 ,0, PANEL_Y) #show message at panel2 panel2_display()
def render_all(objects, dongeon, con): for obj in objects: obj.draw(con) for y in range(dongeon.map_height): for x in range(dongeon.map_width): wall = dongeon.map[x][y].block_sight if wall: libtcod.console_set_char_background(con, x, y, dongeon.color_dark_wall, libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, dongeon.color_dark_ground, libtcod.BKGND_SET)
def draw_target(cursor, size=1, maxrange=None): global hint #draw reticle of stated size if maxrange > 0: for tile in circle(player.x, player.y, maxrange): libtcod.console_set_char_background(con, tile[0], tile[1], libtcod.darkest_red, flag=libtcod.BKGND_LIGHTEN) for tile in circle(cursor.x, cursor.y, size): libtcod.console_set_char_background(con, tile[0], tile[1], libtcod.darkest_yellow, flag=libtcod.BKGND_ADD) hint = get_names(cursor.x, cursor.y)
def apply_fade_effects(con): for e in fade_effects[:]: (x, y, color, time) = e e[3] -= 1 if e[3] <= 0: fade_effects.remove(e) tcod.console_set_char_background( con, x, y, color * (float(time) / EFFECT_FADE_TIME))
def _draw_unseen(player, screen_x, screen_y, pos, terrain, icon): global _con current_map = player.current_map sc = terrain.unseen_color if not sc: sc = map.region_colors_unseen[current_map.region_terrain[current_map.region[pos.x][pos.y]]] libtcod.console_set_char_background(_con, screen_x, screen_y, sc, libtcod.BKGND_SET) # _debug_region(current_map, screen_x, screen_y, pos) if icon: libtcod.console_set_char_foreground(_con, screen_x, screen_y, terrain.icon_color) libtcod.console_set_char(_con, screen_x, screen_y, icon)
def refresh_gui_background(self, gui): libtcod.console_clear(gui) for x in xrange(self.SCREEN_WIDTH): for y in xrange(self.SCREEN_HEIGHT): libtcod.console_set_char_background(gui, x, y, libtcod.Color(100, 100, 100)) if self.paused == True: pause_text = "***PAUSED***" for x in xrange(12): libtcod.console_set_char_background(gui, self.CAMERA_WIDTH-15+x, 0, libtcod.Color(100, 100, 200)) libtcod.console_put_char(gui, self.CAMERA_WIDTH-15+x, 0, pause_text[x], libtcod.BKGND_NONE) libtcod.console_set_char_foreground(gui, self.CAMERA_WIDTH-15+x, 0, libtcod.Color(255, 255, 255))
def render_all(map): for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): wall = map[x][y].block_sight if wall: libtcod.console_set_char_background(con, x, y, color_dark_wall, libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, color_dark_ground, libtcod.BKGND_SET) for worldobj in worldobjs: worldobj.draw() libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
def renderOverlay(): global mouse mouseX = mouse.cx mouseY = mouse.cy if running: libtcod.console_print(0, 0, 0, "Running") libtcod.console_print(0, 0, 1, "Mouse at [" + str(mouseX) + "," + str(mouseY) + "]") libtcod.console_set_char_background(0, mouseX, mouseY, libtcod.lightest_lime, libtcod.BKGND_ADDALPHA(0.2))
def drawPlayers(player, visibleOffsetX, visibleOffsetY): playerX, playerY = player.GetLocation() visible, screenX, screenY = getScreenCoordinates(playerX, playerY, visibleOffsetX, visibleOffsetY) if (visible == False): # cannot see me :) return libtcod.console_put_char(0, screenX, screenY, '@', libtcod.BKGND_NONE) libtcod.console_set_char_background(0, screenX, screenY, libtcod.black, libtcod.BKGND_SET)
def render_all(con, stats_panel, message_panel, mouse, fov_map, Player, objects): for y in range(consts.MAP_HEIGHT): for x in range(consts.MAP_WIDTH): if DebugShowWholeMap: visible = True else: visible = libtcod.map_is_in_fov(fov_map, x, y) wall = Map_Tiles[x][y].block_sight if not visible: if Map_Tiles[x][y].explored or DebugShowWholeMap: if wall: render_wall(con, x, y, consts.COLOR_DARK_WALL) else: libtcod.console_set_char_background( con, x, y, consts.COLOR_DARK_GROUND, libtcod.BKGND_SET) else: if wall: render_wall(con, x, y, consts.COLOR_LIGHT_WALL) else: libtcod.console_set_char_background( con, x, y, consts.COLOR_LIGHT_GROUND, libtcod.BKGND_SET) Map_Tiles[x][y].explored = True for obj in objects: obj.draw(con, Map_Tiles, fov_map, DebugShowWholeMap) libtcod.console_blit(con, 0, 0, consts.MAP_WIDTH, consts.MAP_HEIGHT, 0, 0, 0) # Prepare to render the GUI stats_panel libtcod.console_set_default_background(stats_panel, libtcod.black) libtcod.console_clear(stats_panel) # Render the Player stats render_bar(stats_panel, 1, 1, consts.BAR_WIDTH, 'HP', Player.fighter.hp, Player.fighter.max_hp, libtcod.red, libtcod.darker_red) # Render a list of what's under the mouse cursor libtcod.console_set_default_foreground(stats_panel, libtcod.light_gray) libtcod.console_print_ex(stats_panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT, get_names_under_mouse(mouse, fov_map, objects)) print_level_indicator(stats_panel) libtcod.console_blit(stats_panel, 0, 0, consts.SCREEN_WIDTH, consts.PANEL_HEIGHT, 0, 0, consts.PANEL_Y) # Render the message log libtcod.console_blit(message_panel.render(), 0, 0, message_panel.width, message_panel.height, 0, consts.MSG_X, consts.PANEL_Y)
def render_all(): global fov_recompute map = data.current_area.map #Define the upper left corner of the visable map start_x = data.player.x - MAP_WINDOW_WIDTH / 2 if start_x < 0: start_x = 0 elif start_x > MAP_WIDTH - MAP_WINDOW_WIDTH: start_x = MAP_WIDTH - MAP_WINDOW_WIDTH start_y = data.player.y - MAP_WINDOW_HEIGHT / 2 if start_y < 0: start_y = 0 elif start_y > MAP_HEIGHT - MAP_WINDOW_HEIGHT: start_y = MAP_HEIGHT - MAP_WINDOW_HEIGHT if fov_recompute: #Compute the FOV fov_recompute = False libtcod.map_compute_fov(data.fov_map, data.player.x, data.player.y, TORCH_RADIUS, FOV_LIGHT_WALLS, FOV_ALGO) #Recompute the light maps for each object for object in data.current_area.objects: if object.light_emittance > 0: libtcod.map_compute_fov(object.light_map, object.x, object.y, object.light_emittance, FOV_LIGHT_WALLS, FOV_ALGO) #Clear the map console ready to draw libtcod.console_clear(mapcon) #Render the map console for y in range(start_y, MAP_HEIGHT): for x in range(start_x, MAP_WIDTH): #Check that each tile is visable and lit visible = is_visible(x, y) if visible: libtcod.console_set_char_background( mapcon, x, y, map[x][y].color(True), libtcod.BKGND_SET) map[x][y].explored = True #If not, check whether it is explored. elif map[x][y].explored: libtcod.console_set_char_background( mapcon, x, y, map[x][y].color(False)) #Draw all the objects in the current area for object in data.current_area.objects: object.draw() #Blit the map to the screen libtcod.console_blit(mapcon, start_x, start_y, MAP_WINDOW_WIDTH, MAP_WINDOW_HEIGHT, 0, 0, 0) render_panel()
def show_all(self, zone, entities): """Cheat function: show all the tiles and entities in a zone.""" # this repeats process_zone and render_objects, fix this somehow for y in range(zone.height): for x in range(zone.width): wall = zone[x][y].block_sight if wall: libtcod.console_set_char_background(self.con, x, y, COLOR_WALL_DARK, libtcod.BKGND_SET) else: libtcod.console_set_char_background(self.con, x, y, COLOR_GROUND_DARK, libtcod.BKGND_SET) for ent in entities: libtcod.console_set_default_foreground(self.con, ent.color) libtcod.console_put_char(self.con, ent.x, ent.y, ent.char, libtcod.BKGND_NONE)
def render_all(): for object in objects: object.draw() for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): wall = map[x][y].block_sight if wall: libtcod.console_set_char_background(con, x, y, color_dark_wall, libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, color_dark_ground, libtcod.BKGND_SET) libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0) # display buffer 'con' information to the main terminal window
def write_array_to_background(array, console): """Writes an array of colors to the background of a console""" #Get the dimensions array. map_width = len(array) map_height = len(array[0]) #Iterate through the elements of the array and write them to the console. for x0 in range(map_width): for x1 in range(map_height): color = array[x0][x1] lib.console_set_char_background(console, x0, x1, color, lib.BKGND_SET) #return the resulting console for use in another function return console
def render_UI(VP): global SNAPSHOT ltc.console_clear(UI) #return a string with the names of all objects under the MOUSE (x, y) = (MOUSE.cx, MOUSE.cy) lx, ly = VP.screen_to_map(x, y) if lx < 0 or ly < 0: return names = [ obj.name + " | G({0}:{1}) | L({2}:{3})".format(obj.gx, obj.gy, obj.x, obj.y) for obj in SNAPSHOT['cast'] if obj.x == lx and obj.y == ly and True ] names = ' | ' + ', '.join(names) if lx < SNAPSHOT['region'].length and ly < SNAPSHOT['region'].length: tile = SNAPSHOT['region'].get_tile(lx, ly).get_info() tgx, tgy = tile['xy_global'] tlx, tly = tile['xy_local'] info = "G({0}:{1}) | L({2}:{3}) | Z: {4}".format( tgx, tgy, tlx, tly, int(tile['altitude'])) + names else: info = '-' ltc.console_set_default_background(UI, ltc.BKGND_NONE) ltc.console_set_default_foreground(UI, ltc.white) ltc.console_print_ex(UI, 0, 0, ltc.BKGND_SET, ltc.LEFT, info) ltc.console_set_default_background(UI, ltc.purple) zoomx = 50 zoomy = 40 for zy in range(zoomy): for zx in range(zoomx): ltc.console_set_char_background(UI, zx + (x - zoomx / 2), zy + (y - zoomy / 2), ltc.BKGND_LIGHTEN, ltc.BKGND_SET) ltc.console_set_char_background(UI, x, y, ltc.white, ltc.BKGND_SET) ltc.console_blit(UI, 0, 0, config.SCREEN_WIDTH, config.SCREEN_HEIGHT, 0, 0, 0, 1, .5)
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height, bar_width, panel_height, panel_y, mouse, colors, game_state): # Draw all the tiles in the game map if fov_recompute: for y in range(game_map.height): for x in range(game_map.width): visible = libtcod.map_is_in_fov(fov_map, x, y) wall = game_map.tiles[x][y].block_sight if visible: if wall: libtcod.console_set_char_background(con, x, y, colors.get('light_wall'), libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, colors.get('light_ground'), libtcod.BKGND_SET) game_map.tiles[x][y].explored = True elif game_map.tiles[x][y].explored: if wall: libtcod.console_set_char_background(con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET) entities_in_render_order = sorted(entities, key=lambda x: x.render_order.value) # Draw all entities in the list for entity in entities_in_render_order: draw_entity(con, entity, fov_map, game_map) libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0) libtcod.console_set_default_background(panel, libtcod.black) libtcod.console_clear(panel) #Print the game messages, one line at a time y = 1 for message in message_log.messages: libtcod.console_set_default_foreground(panel, message.color) libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE, libtcod.LEFT, message.text) y += 1 render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp, player.fighter.max_hp, libtcod.light_red, libtcod.darker_red) libtcod.console_print_ex(panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT, 'Dungeon level: {0}'.format(game_map.dungeon_level)) libtcod.console_set_default_foreground(panel, libtcod.light_gray) libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT, get_names_under_mouse(mouse, entities, fov_map)) libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y) if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY): if game_state == GameStates.SHOW_INVENTORY: inventory_title = 'Press the key next to the item to use it, or Esc to cancel.\n' else: inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n' inventory_menu(con, inventory_title, player.inventory, 50, screen_width, screen_height) elif game_state == GameStates.LEVEL_UP: level_up_menu(con, 'Level up! Choose a stat to raise:', player, 40, screen_width, screen_height) elif game_state == GameStates.CHARACTER_SCREEN: character_screen(player, 30, 10, screen_width, screen_height)
def render_all(con, entities, player, game_map, fov_map, fov_recompute, screen_width, screen_height, colors): if fov_recompute: for y in range(game_map.height): for x in range(game_map.width): visible=libtcod.map_is_in_fov(fov_map,x,y) wall = game_map.tiles[x][y].block_sight if visible: if wall: libtcod.console_set_char_background(con,x,y,colors.get("light_wall"),libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, colors.get('light_ground'), libtcod.BKGND_SET) game_map.tiles[x][y].explored=True elif game_map.tiles[x][y].explored: if wall: libtcod.console_set_char_background(con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET) entities_in_render_order=sorted(entities,key=lambda x:x.render_order.value) # Draw all entities in the list for entity in entities_in_render_order: draw_entity(con, entity,fov_map) libtcod.console_set_default_foreground(con,libtcod.white) libtcod.console_print_ex(con,1,screen_height -2,libtcod.BKGND_NONE,libtcod.LEFT,"HP: {0:02}/{1:02}".format(player.fighter.hp,player.fighter.max_hp)) libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
def render_all(con, entities, game_map, fov_map, fov_recompute, screen_width, screen_height, colors): # Draw all entities in the list for entity in entities: draw_entity(con, entity, fov_map) if fov_recompute: for y in range(game_map.height): for x in range(game_map.width): visible = libtcod.map_is_in_fov(fov_map, x, y) wall = game_map.tiles[x][y].block_sight if visible: if wall: libtcod.console_set_char_background( con, x, y, colors.get('light_wall'), libtcod.BKGND_SET) else: libtcod.console_set_char_background( con, x, y, colors.get('light_ground'), libtcod.BKGND_SET) game_map.tiles[x][y].explored = True elif game_map.tiles[x][y].explored: if wall: libtcod.console_set_char_background( con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET) else: libtcod.console_set_char_background( con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET) libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
def explore_and_render_zone(self, zone, fov_map): """Renders lit and unlit zone tiles and explores them""" # renderer exploring = bad, fix this for y in range(zone.height): for x in range(zone.width): lit = libtcod.map_is_in_fov(fov_map, x, y) wall = zone[x][y].block_sight if not lit: #it's out of the player's FOV #if it's not visible right now, the player can only see it if it's explored if zone[x][y].explored: if wall: libtcod.console_set_char_background( self.con, x, y, COLOR_WALL_DARK, libtcod.BKGND_SET) else: libtcod.console_set_char_background( self.con, x, y, COLOR_GROUND_DARK, libtcod.BKGND_SET) else: #it is inside the player's fov if wall: libtcod.console_set_char_background( self.con, x, y, COLOR_WALL_LIT, libtcod.BKGND_SET) else: libtcod.console_set_char_background( self.con, x, y, COLOR_GROUND_LIT, libtcod.BKGND_SET) # explore the tile if not zone[x][y].explored: zone[x][y].explored = True
def draw(self): if game.fov_recompute: # recompute FOV if needed (the player moved or something) game.fov_recompute = False # yuck, shouldn't need to reference libtcod.map_compute_fov(self.fov_map, self.protagonist.coords[0], self.protagonist.coords[1], C.TORCH_RADIUS, C.FOV_LIGHT_WALLS, C.FOV_ALGORITHM) # go through all tiles, and set their background color according to the FOV for y in range(self.height): for x in range(self.width): visible = libtcod.map_is_in_fov(self.fov_map, x, y) if not C.DEBUG else True wall = self.map[x][y].block_sight if not visible: # if it's not visible right now, the player can only see it if it's explored if self.map[x][y].explored: if wall: libtcod.console_set_char_background(self.console, x, y, C.COLOR_DARK_WALL, libtcod.BKGND_SET) # libtcod.console_put_char_ex(self.console, x, y, 2242, C.COLOR_DARK_WALL, C.COLOR_BACKGROUND) else: libtcod.console_set_char_background(self.console, x, y, C.COLOR_DARK_GROUND, libtcod.BKGND_SET) # libtcod.console_put_char_ex(self.console, x, y, 2242, C.COLOR_DARK_GROUND, C.COLOR_BACKGROUND) else: # it's visible if wall: libtcod.console_set_char_background(self.console, x, y, C.COLOR_LIGHT_WALL, libtcod.BKGND_SET) # libtcod.console_put_char_ex(self.console, x, y, 2242, C.COLOR_LIGHT_WALL, C.COLOR_BACKGROUND) else: libtcod.console_set_char_background(self.console, x, y, C.COLOR_LIGHT_GROUND, libtcod.BKGND_SET) # libtcod.console_put_char_ex(self.console, x, y, 2242, C.COLOR_LIGHT_GROUND, C.COLOR_BACKGROUND) # since it's visible, explore it self.map[x][y].explored = True
def render_all(): for object in objects: object.draw() for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): wall = map[x][y].block_sight if wall: libtcod.console_put_char_ex(con, x, y, '#', color_dark_wall, libtcod.Color(20, 20, 20)) else: libtcod.console_set_char_background(con, x, y, libtcod.Color(20, 20, 20), libtcod.BKGND_SET) libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height, bar_width, panel_height, panel_y, mouse, colors): if fov_recompute: # Draw all the tiles in the game map for y in range(game_map.height): for x in range(game_map.width): visible = libtcod.map_is_in_fov(fov_map, x, y) wall = game_map.tiles[x][y].block_sight if visible: if wall: libtcod.console_set_char_background( con, x, y, colors.get('light_wall'), libtcod.BKGND_SET) else: libtcod.console_set_char_background( con, x, y, colors.get('light_ground'), libtcod.BKGND_SET) game_map.tiles[x][y].explored = True elif game_map.tiles[x][y].explored: if wall: libtcod.console_set_char_background( con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET) else: libtcod.console_set_char_background( con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET) entities_in_reverse_order = sorted(entities, key=lambda x: x.render_order.value) # Draw all entities in the list for entity in entities_in_reverse_order: draw_entity(con, entity, fov_map) libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0) libtcod.console_set_default_background(panel, libtcod.black) libtcod.console_clear(panel) # Print the game messages, one line at a time y = 1 for message in message_log.messages: libtcod.console_set_default_foreground(panel, message.color) libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE, libtcod.LEFT, message.text) y += 1 render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp, player.fighter.max_hp, libtcod.light_red, libtcod.darker_red) libtcod.console_set_default_foreground(panel, libtcod.light_gray) libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT, get_names_under_mouse(mouse, entities, fov_map)) libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y)
def render_all(self, target): if target is not None: global color_light_wall global color_light_ground for y in xrange(self.map.height): for x in xrange(self.map.width): visible = libtcod.map_is_in_fov(self.hero.fov_map, x, y) wall = self.map.tiles[x][y].block_sight if visible: if wall: libtcod.console_set_char_background( target, x, y, color_light_wall, libtcod.BKGND_SET) else: libtcod.console_set_char_background( target, x, y, color_light_ground, libtcod.BKGND_SET) self.map.tiles[x][y].explored = True else: if self.map.tiles[x][y].explored: if wall: libtcod.console_set_char_background( target, x, y, color_dark_wall, libtcod.BKGND_SET) else: libtcod.console_set_char_background( target, x, y, color_dark_ground, libtcod.BKGND_SET) for o in self.npcs: if libtcod.map_is_in_fov(self.hero.fov_map, o.x, o.y): o.draw(target) self.hero.draw(target) libtcod.console_blit(target, 0, 0, SCREEN_WIDE, SCREEN_HIGH, 0, 0, 0)
def render_all(): global fov_map, color_dark_wall, color_light_wall global color_dark_ground, color_light_ground global fov_recompute if fov_recompute: # recompute FOV if needed (the player moved or something) fov_recompute = False libtcod.map_compute_fov(fov_map, player.x, player.y, TORCH_RADIUS, FOV_LIGHT_WALLS, FOV_ALGO) # go through all tiles, and set their background color according to the FOV for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): visible = libtcod.map_is_in_fov(fov_map, x, y) wall = map[x][y].block_sight if not visible: # if it's not visible right now, the player can only see it if it's explored if map[x][y].explored: if wall: libtcod.console_set_char_background(con, x, y, color_dark_wall, libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, color_dark_ground, libtcod.BKGND_SET) else: # it's visible if wall: libtcod.console_set_char_background(con, x, y, color_light_wall, libtcod.BKGND_SET) else: libtcod.console_set_char_background(con, x, y, color_light_ground, libtcod.BKGND_SET) # since it's visible, explore it map[x][y].explored = True # draw all objects in the list, except the player. we want it to # always appear over all other objects! so it's drawn later. for object in objects: if object != player: object.draw() player.draw() # blit the contents of "con" to the root console libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0) # prepare to render the GUI console libtcod.console_set_default_background(panel, libtcod.black) libtcod.console_clear(panel) # show the player's stats render_bar(1, 1, BAR_WIDTH, "HP", player.fighter.hp, player.fighter.max_hp, libtcod.light_red, libtcod.darker_red) # print the game messages, one line at a time y = 1 for (line, color) in game_msgs: libtcod.console_set_default_foreground(panel, color) libtcod.console_print_ex(panel, MSG_X, y, libtcod.BKGND_NONE, libtcod.LEFT, line) y += 1 libtcod.console_set_default_foreground(panel, libtcod.light_gray) libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT, get_names_under_mouse()) # blit GUI to screen libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0, PANEL_Y)
def draw(): for game_object in GameObject.game_objects: game_object.draw() for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): if (world_map[x][y].block_sight): tcod.console_set_char_background(con, x, y, color_dark_wall, tcod.BKGND_SET) else: tcod.console_set_char_background(con, x, y, color_dark_ground, tcod.BKGND_SET) tcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
def render_all(): global color_light_wall global color_light_ground #go through all tiles, and set their background color for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): wall = map[x][y].blocked if wall: libtcod.console_set_char_background(0, x, y, color_dark_wall, libtcod.BKGND_SET ) else: libtcod.console_set_char_background(0, x, y, color_dark_ground, libtcod.BKGND_SET ) if map[x][y].clearance >= 1: libtcod.console_put_char(0, x, y, str(map[x][y].clearance), libtcod.BKGND_NONE)
def _draw_unseen(player, screen_x, screen_y, pos, terrain, icon): global _con current_map = player.current_map sc = terrain.unseen_color if not sc: sc = map.region_colors_unseen[current_map.region_terrain[ current_map.region[pos.x][pos.y]]] libtcod.console_set_char_background(_con, screen_x, screen_y, sc, libtcod.BKGND_SET) # _debug_region(current_map, screen_x, screen_y, pos) if icon: libtcod.console_set_char_foreground(_con, screen_x, screen_y, terrain.icon_color) libtcod.console_set_char(_con, screen_x, screen_y, icon)