예제 #1
0
 def draw(self, con):
     #go through all tiles, and set their background color
     for y in range(self.height):
         for x in range(self.width):
             tcod.console_set_char_background(con, x, y,
                                              self.data[x][y].color,
                                              tcod.BKGND_SET)
def render_all(map):
	#go through all tiles, and set their background color
	for y in range(MAP_HEIGHT):
		for x in range(MAP_WIDTH):
			c = map[x][y].color
			if c >= 112:
				c = 255
				map[x][y].blocked = False
				map[x][y].block_sight = False
			else:
				c = 0
				map[x][y].blocked = True
				map[x][y].block_sight = True
			wall = map[x][y].block_sight
				
				
				
			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)
			

			
			#color = libtcod.Color(c,c,c) #map[x][y].block_sight

			#libtcod.console_set_char_background(con, x, y, color, libtcod.BKGND_SET)
 
	#draw all objects in the list
	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)
예제 #3
0
    def render_world(self, entities, world_map, fov_map, fov_recompute,
                     message_log, whats_under_mouse, game_state):
        if fov_recompute:
            for y in range(world_map.height):
                for x in range(world_map.width):
                    bg_color, char, fg_color = world_map.tile_render_info(
                        x, y, fov_map.fov[x][y])

                    if bg_color:
                        tcod.console_set_char_background(
                            self.con, x, y, bg_color, tcod.BKGND_SET)
                    if char and fg_color:
                        self.con.default_fg = fg_color
                        tcod.console_put_char(self.con, x, y, char,
                                              tcod.BKGND_NONE)

        entities_in_render_order = sorted(entities.all,
                                          key=lambda x: x.render_order.value)
        for entity in entities_in_render_order:
            visible = fov_map.fov[entity.x][entity.y]
            if visible:
                self.con.default_fg = entity.char.color
                tcod.console_put_char(self.con, entity.x, entity.y,
                                      entity.char.char, tcod.BKGND_NONE)

        self.con.blit(self.root)

        self.panel.default_bg = tcod.black
        self.panel.clear()
        self.render_hud(entities.player, None, message_log, whats_under_mouse)

        self.render_menus(entities.player, game_state, world_map=world_map)
예제 #4
0
def draw_map(con, game_map, fov_map, fov_recalculate, ignore_fov=False):
    """ Render the map elements (wall, floor) and their proper state (seen/unseen in/not in fov). """
    if fov_recalculate:
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = tcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                # The tile is in the FOV
                if ignore_fov or visible:
                    # Update the tile to be seen
                    game_map.tiles[x][y].seen = True
                    if wall:
                        tcod.console_set_char_background(
                            con, x, y, colors.get("light wall"),
                            tcod.BKGND_SET)
                    else:
                        tcod.console_set_char_background(
                            con, x, y, colors.get("light ground"),
                            tcod.BKGND_SET)
                else:
                    if not game_map.tiles[x][y].seen:
                        tcod.console_set_char_background(
                            con, x, y, colors.get("unseen"), tcod.BKGND_SET)
                    elif wall:
                        tcod.console_set_char_background(
                            con, x, y, colors.get("dark wall"), tcod.BKGND_SET)
                    else:
                        tcod.console_set_char_background(
                            con, x, y, colors.get("dark ground"),
                            tcod.BKGND_SET)
예제 #5
0
    def draw(self, console: int, colors: dict, force: bool = False) -> None:
        """
        """

        if self.needs_fov_recompute or force:
            for tile in self:
                visible = tcod.map_is_in_fov(self.fov_map, tile.x, tile.y)
                # XXX tile should take more responsibility for what it's color
                #     is depending on it's configuration.
                #
                color = 0x000000
                if tile.is_wall:
                    color = colors["light_wall"] if visible else colors[
                        "dark_wall"]
                if tile.is_floor:
                    color = colors["light_grnd"] if visible else colors[
                        "dark_grnd"]
                tcod.console_set_char_background(console, tile.x, tile.y,
                                                 color, tcod.BKGND_SET)
            self.needs_fov_recompute = False

        for entity in sorted(self.entities, key=lambda x: x.kind.value):
            entity.draw(console)

        tcod.console_set_default_foreground(console, tcod.white)
        tcod.console_print_ex(
            console,
            1,
            self.h - 2,
            tcod.BKGND_NONE,
            tcod.LEFT,
            f"HP: {self.player.hp:02d}/{self.player.max_hp:02d}",
        )
예제 #6
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, game_state):
    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

                color_name = None
                if visible:
                    if wall:
                        color_name = "light_wall"

                    else:
                        color_name = "light_ground"

                    game_map.tiles[x][y].explored = True

                elif game_map.tiles[x][y].explored:
                    if wall:
                        color_name = "dark_wall"

                    else:
                        color_name = "dark_ground"
                if color_name:    
                    libtcod.console_set_char_background(con, x, y, colors.get(color_name), 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_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = "Press the key of your love story to use item or Esc to cancel.\n"
        else:
            inventory_title = "Press the key of your love story to drop item or Esc to cancel.\n"
        
        inventory_menu(con, inventory_title, player.inventory, 50, screen_width, screen_height)

    libtcod.console_set_default_foreground(con, libtcod.lighter_magenta)
    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_fuchsia, libtcod.dark_fuchsia)
                
    libtcod.console_set_default_foreground(panel, libtcod.lighter_violet)
    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)
예제 #7
0
def renderAll(console, player, entities, gameMap, screenWidth, screenHeight):

    (minY, maxY, minX, maxX) = getView(player, screenWidth, screenHeight)

    for y in range(minY, maxY):
        for x in range(minX, maxX):
            wall = gameMap.tiles[x][y].blocked
            xMapped = x - minX
            yMapped = y - minY
            if wall:
                tcod.console_set_char_background(console, xMapped, yMapped,
                                                 tcod.dark_blue,
                                                 tcod.BKGND_SET)
            else:
                tcod.console_set_char_background(console, xMapped, yMapped,
                                                 tcod.dark_green,
                                                 tcod.BKGND_SET)

    # Draw Player
    tcod.tcod.console_set_default_foreground(console, player.color)
    tcod.console_put_char(console, player.x - minX, player.y - minY,
                          player.char, tcod.BKGND_NONE)

    # Draw Entities in List
    for entity in entities:
        drawEntity(console, entity)

    # Blit Changes
    tcod.console_blit(console, 0, 0, screenWidth, screenWidth, 0, 0, 0)
예제 #8
0
 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)
예제 #9
0
def refresh_chars(con, hl_tool, hl_char, hl_color):
    char_start_x, char_start_y = CHAR_MENU_BOX[0]
    char_end_x, char_end_y = CHAR_MENU_BOX[1]
    for y in range(char_start_y + 1, char_end_y):
        for x in range(char_start_x + 1, char_end_x):
            libtcod.console_put_char(con, x, y, ' ', libtcod.BKGND_NONE)
            libtcod.console_set_char_background(con, x, y, libtcod.black)
    draw_ui(con, hl_tool, hl_char, hl_color)
예제 #10
0
def refresh_tools(con, hl_tool, hl_char, hl_color):
    tools_start_x, tools_start_y = TOOLS_BOX[0]
    tools_end_x, tools_end_y = TOOLS_BOX[1]
    for y in range(tools_start_y + 1, tools_end_y):
        for x in range(tools_start_x + 1, tools_end_x):
            libtcod.console_put_char(con, x, y, ' ', libtcod.BKGND_NONE)
            libtcod.console_set_char_background(con, x, y, libtcod.black)
    draw_ui(con, hl_tool, hl_char, hl_color)
예제 #11
0
    def draw(self, con, mouse):
        px, py = self.charToPos(self.cursorPos)

        con.print(self.x, self.y, self.text, tcod.Color(168, 168, 168),
                  tcod.Color(0, 0, 168))
        tcod.console_set_char_background(con, self.x + px, self.y + py,
                                         tcod.Color(0, 168, 168))

        self.saveBtn.draw(con, mouse)
예제 #12
0
def render_map():
   # Draw all the tiles in the game map
    for y in range(game_map.height):
        for x in range(game_map.width):
            wall = game_map.tiles[x][y].block_sight

            if wall:
                tcod.console_set_char_background(con, x, y, colors.get('dark_wall'), tcod.BKGND_SET)
            else:
                tcod.console_set_char_background(con, x, y, colors.get('dark_ground'), tcod.BKGND_SET)
예제 #13
0
def make_map():
    # global map
    for y in range(SCREEN_HEIGHT):
        for x in range(SCREEN_WIDTH):
            r = tcod.random_get_int(0, 0, len(colors) - 1)
            color = colors[r]
            tcod.console_set_char_background(
                con, x, y, tcod.Color(color[0], color[1], color[2]),
                tcod.BKGND_SET)
    tcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
예제 #14
0
파일: maze.py 프로젝트: dongzeyuan/bbt
def render_all(con, game_map, colors):
    for y in range(game_map.height):
        for x in range(game_map.width):

            wall = game_map.tiles[x][y].block_sight

            if not wall:
                tcod.console_set_char_background(
                    con, x, y, game_map.tiles[x][y].color, tcod.BKGND_SET)
            else:
                tcod.console_set_char_background(
                    con, x, y, game_map.tiles[x][y].color, tcod.BKGND_SET)
예제 #15
0
 def render_lit_map(self, game_map, fov_map):
     for y in range(game_map.height):
         for x in range(game_map.width):
             bg_color, char, char_color = game_map.tile_render_info(
                 x, y, fov_map.fov[x][y])
             if bg_color:
                 tcod.console_set_char_background(self.con, x, y, bg_color,
                                                  tcod.BKGND_SET)
             if char and char_color:
                 self.con.default_fg = char_color
                 tcod.console_put_char(self.con, x, y, char,
                                       tcod.BKGND_NONE)
예제 #16
0
    def draw(self, con, mouse):
        px, py = self.charToPos(self.cursorPos)

        con.draw_frame(self.x, self.y, self.width, self.height,
                       self.entity.name, True, tcod.Color(168, 168, 168),
                       tcod.Color(0, 0, 168))
        con.print(self.x + 1, self.y + 2, self.text, tcod.Color(168, 168, 168),
                  tcod.Color(0, 0, 168))
        tcod.console_set_char_background(con, self.x + 1 + px, self.y + 2 + py,
                                         tcod.Color(0, 168, 168))

        self.saveBtn.draw(con, mouse)
예제 #17
0
    def process(self):
        target = None
        target_text = None
        for entity, (position, render, target) in self.world.get_components(
                Position, Render, Target):
            libtcod.console_set_char_background(self.consoles_map.console,
                                                position.x, position.y,
                                                render.color,
                                                libtcod.BKGND_SET)
            target_text = target.text
            target = position

        if target is None:
            return

        x = self.config.ui.bar_width + 3
        y = 0
        w = self.config.ui.width - x
        h = self.config.ui.height
        self.consoles_ui.console.draw_rect(x,
                                           y,
                                           w,
                                           h,
                                           ord(" "),
                                           fg=libtcod.black,
                                           bg=libtcod.black,
                                           bg_blend=libtcod.BKGND_SET)

        creature = self.map.entities[target.x][target.y]
        self.log.debug("Look creature: " + str(creature))
        if creature is not None:
            self.draw_creature(creature)
            return

        items = self.map.items[target.x][target.y]
        self.log.debug("Look items: " + str(creature))
        if items is not None and len(items) > 0:
            self.draw_items(items)
            return

        tile = self.map.tiles[target.x][target.y]
        self.log.debug("Look tile: " + str(tile))
        if tile is not None:
            self.draw_tile(tile)

        if target_text:
            libtcod.console_set_default_foreground(self.consoles_ui.console,
                                                   libtcod.orange)
            self.draw_text(target_text, self.config.ui.bar_width + 3, 1)
            libtcod.console_set_default_foreground(self.consoles_ui.console,
                                                   libtcod.white)
예제 #18
0
def render_all(con, entities, player, game_map, fov_map, fov_recompute, SCREEN_WIDTH, SCREEN_HEIGHT, colors):
	if fov_recompute:	
	# Draw all 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)
	
	# Draw all entities in the list
	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)

	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)
예제 #19
0
 def draw(self):
     global ignore_FOV
     for y in range(MAP_HEIGHT):
         for x in range(MAP_WIDTH):
             visible = libtcod.map_is_in_fov(self.fov_map, x,
                                             y) or ignore_FOV
             wall = self.map[x][y].block_sight
             if not visible:
                 # If the tile isn't visible by the player, first check to see
                 # if it has already been explored
                 if self.map[x][y].explored:
                     # If the tile has been explored, color it dark
                     if wall:
                         libtcod.console_set_char_background(
                             con, x, y, self.color_dark_wall,
                             libtcod.BKGND_SET)
                     else:
                         libtcod.console_set_char_background(
                             con, x, y, self.color_dark_ground,
                             libtcod.BKGND_SET)
             else:
                 # Color it light to show that it's within the player's FOV
                 if wall:
                     libtcod.console_set_char_background(
                         con, x, y, self.color_light_wall,
                         libtcod.BKGND_SET)
                 else:
                     libtcod.console_set_char_background(
                         con, x, y, self.color_light_ground,
                         libtcod.BKGND_SET)
                 self.map[x][y].explored = True
def render_all_indoors(source_con, dest_con, panel_con, entities_list, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height, kolors, game_type, interface_skin, hp_bar_width, panel_height, panel_y, mouse):
    floor_char = chr(298) #256+32+10 (11th char, third row is the empty square)
    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 = tcod.map_is_in_fov(fov_map, x, y)
                #not sure this logic is correct, what about sight blocking but movement non-blocking tiles, example magical darkness?
                wall = game_map.tiles[x][y].block_sight and game_map.tiles[x][y].blocked
                door = game_map.tiles[x][y].door
                floodfill_done = game_map.tiles[x][y].floodfilled
                #If it's visible make it light colored and mark explored
                if visible:
                    if wall:
                        tcod.console_put_char_ex(source_con, x, y, 35, kolors['console_white'], kolors['light_wall'])
                    else:
                        if door:
                            tcod.console_put_char_ex(source_con, x, y, 43, kolors['console_white'], kolors['light_door'])
                        else:
                            tcod.console_set_char_background(source_con, x, y, kolors['light_ground'], tcod.BKGND_SET)
                    #Mark tiles as explored
                    game_map.tiles[x][y].explored = True
                #If it is not visible but is explored make it dark colored
                elif game_map.tiles[x][y].explored or game_type == 'viewer':
                    if floodfill_done:
                        tcod.console_set_char_background(source_con, x, y, kolors['purple_fill'], tcod.BKGND_SET)
                    elif wall:
                        tcod.console_set_char_background(source_con, x, y, kolors['dark_wall'], tcod.BKGND_SET)
                    elif door:
                        tcod.console_put_char_ex(source_con, x, y, 43, kolors['console_white'], kolors['dark_door'])
                        #tcod.console_set_char_background(source_con, x, y, kolors['dark_door'], tcod.BKGND_SET)
                    else:
                        tcod.console_set_char_background(source_con, x, y, kolors['dark_ground'], tcod.BKGND_SET)
예제 #21
0
def render_all(con: libtcod.console.Console, entities: List[Entity],
               game_map: GameMap, fov_map: libtcod.map.Map,
               fov_recompute: bool, screen_width: int, screen_height: int,
               colors: Dict[str, libtcod.Color]) -> None:
    # Draw 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['light_wall'], libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors['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['dark_wall'], libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors['dark_ground'],
                            libtcod.BKGND_SET)

    # Draw all entities
    for entity in entities:
        draw_entity(con, entity, fov_map)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
예제 #22
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_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)
    # Draw all entities in the list, blits the changes to screen
    for entity in entities_in_render_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)
예제 #23
0
 def update(self):
     """Update the world's console buffer with current map data."""
     for x in range (0, self.width):
         for y in range (0, self.height):
             cell_value = tcod.heightmap_get_value(self.elevation, x, y)
             cell_value = int(cell_value * 127) + 127
             tcod.map_set_properties(self.map, x, y, (cell_value < 150), (cell_value < 150 and cell_value > 75))
             if not tcod.map_is_transparent(self.map, x, y):
                 cell_color = tcod.white
             elif not tcod.map_is_walkable(self.map, x, y):
                 cell_color = tcod.blue
             else:
                 cell_color = tcod.black
             tcod.console_set_char_background(self.console, x, y, cell_color)
예제 #24
0
def render_all(con, entities, ego, 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].blocked_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_sorted = sorted(entities, key=lambda x: x.render_order.value)
    # Draw all entities in the list
    for entity in entities_sorted:
        draw_entity(con, entity, fov_map)

    libtcod.console_set_default_background(con, libtcod.white)
    libtcod.console_print_ex(con, 1, screen_height - 2, libtcod.BKGND_NONE, libtcod.LEFT,
                             'HP: {0:02}/{1:02}'.format(ego.fighter.hp, ego.fighter.max_hp))

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
예제 #25
0
def render_all():
    global color_light_wall, color_dark_wall
    global color_light_ground, color_dark_ground
    global FOV_map, FOV_recompute

    if FOV_recompute:
        FOV_recompute = False
        tcod.map_compute_fov(FOV_map, player.x, player.y, TORCH_RADIUS, FOV_LIGHT_WALLS, FOV_ALGO)

    # Iterate Room Tiles and Set Color
    for y in range(MAP_HEIGHT):
        for x in range(MAP_WIDTH):
            visible = tcod.map_is_in_fov(FOV_map, x, y)
            wall = map[x][y].block_sight
            if not visible:
                if map[x][y].explored:
                    if wall:
                        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)
            else:
                if wall:
                    tcod.console_set_char_background(con, x, y, color_light_wall, tcod.BKGND_SET)
                else:
                    tcod.console_set_char_background(con, x, y, color_light_ground, tcod.BKGND_SET)
                map[x][y].explored = True

    for object in objects:  # Object List
        object.draw()       # Draw All Objects

    tcod.console_blit(con, 0, 0 , SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0) # Blit Contents To Root Console
예제 #26
0
        def render_all():
            # draw all objects in the list
            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:
                        tcod.console_set_char_background(con, x, y, colour_dark_wall, tcod.BKGND_SET)
                    else:
                        tcod.console_set_char_background(con, x, y, colour_dark_ground, tcod.BKGND_SET)

            tcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
예제 #27
0
def render_all(con, entities, 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)

    # Draw all entities in the list
    for entity in entities:
        draw_entity(con, entity, fov_map)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
예제 #28
0
def draw_tile(con, x, y, tile, visible=True):
    if (visible == True):
        # TODO fov code?
        if (not tile.explored == True):
            tile.explored = True

        if (tile.blocking == True):
            # Draw a wall tile
            tcod.console_set_char_background(con, x, y, color_light_wall,
                                             tcod.BKGND_SET)
        elif (tile.walkable == True and tile.blocking == False):
            # if not a blocking tile, draw a walkable tile
            tcod.console_set_char_background(con, x, y, color_walkable_tile,
                                             tcod.BKGND_SET)
    elif (visible == False):
        if (tile.explored == True):
            if (tile.blocking == True):
                # Draw a wall tile
                tcod.console_set_char_background(con, x, y, color_dark_wall,
                                                 tcod.BKGND_SET)
            elif (tile.walkable == True and tile.blocking == False):
                # if not a blocking tile, draw a walkable tile
                tcod.console_set_char_background(con, x, y,
                                                 color_walkable_dark_tile,
                                                 tcod.BKGND_SET)

    else:
        # if not any of those, draw an empty tile TODO
        return
예제 #29
0
def render_all(con, entities, game_map, screen_width, screen_height, colors):
    for y in range(game_map.height):
        for x in range(game_map.width):
            wall = game_map.tiles[x][y].block_sight

            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)

    for entity in entities:
        draw_entity(con, entity)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
예제 #30
0
def update(player, game_map):
    global field
    for y in range(game_map.height):
        for x in range(game_map.width):
            tcod.console_set_char_background(field, x, y,
                                             game_map.tiles[y][x].color,
                                             tcod.BKGND_SET)

    print_entity(player)
    tcod.console_blit(field, 0, 0, variables.screen_width,
                      variables.screen_height, 0, 0, 0)
    tcod.console_flush()
    clear_entity(player)
    return None
def render_all():
    global color_dark_wall, color_light_wall
    global color_dark_ground, 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].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 )
 
    #draw all objects in the list
    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 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)
 
    #show the player's stats
    libtcod.console_set_default_foreground(con, libtcod.white)
    libtcod.console_print_ex(0, 1, SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, libtcod.LEFT,
        'HP: ' + str(player.fighter.hp) + '/' + str(player.fighter.max_hp))
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
    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 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, MAP_WIDTH, MAP_HEIGHT, 0, 0, 0)
 
 
    #prepare to render the GUI panel
    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)
 
    #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
 
    #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)
 
    #display names of objects under the 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())
 
    #blit the contents of "panel" to the root console
    libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0, PANEL_Y)
예제 #35
0
def test_console_set_char_background(console, bg):
    libtcodpy.console_set_char_background(console, 0, 0, bg, libtcodpy.BKGND_SET)
    assert_char(console, 0, 0, bg=bg)