Example #1
0
 def load(self):
     for j, line in enumerate(mapfile):
         for i, char in enumerate(line):
             if char == '#':
                 self.region[i][j].drawn = True
                 libtcod.console_set_back(con, i, j, WALL, libtcod.BKGND_SET)
     mapfile.close()
Example #2
0
def render_all():
    libtcod.map_compute_fov(path_map, player.x, player.y, 0, True, libtcod.FOV_SHADOW)

    libtcod.console_set_background_color(map_con, libtcod.black)
    libtcod.console_clear(map_con)

    for y in range(MAP_HEIGHT):
        for x in range(MAP_WIDTH):
            if not libtcod.map_is_in_fov(path_map, x, y):
                if explore_map[x][y]:
                    libtcod.console_set_back(map_con, x, y, tile_map[x][y].hidden_color, libtcod.BKGND_SET)
            else:
                libtcod.console_set_background_color(map_con, tile_map[x][y].vis_color)
                libtcod.console_set_foreground_color(map_con, tile_map[x][y].char_color)
                libtcod.console_put_char(map_con, x, y, tile_map[x][y].char, libtcod.BKGND_SET)
                explore_map[x][y] = True

    entities = items + creatures
    for entity in entities:
        entity.sprite.render()

    render_panel()
    render_inventory()

    blit_consoles()
Example #3
0
 def draw(self):
     for y in range(MAP_HEIGHT):
         for x in range(MAP_WIDTH):
             wall = world.region[x][y].block_sight
             if wall:
                 libtcod.console_set_back(con, x, y, WALL, libtcod.BKGND_SET )
             else:
                 libtcod.console_set_back(con, x, y, GROUND, libtcod.BKGND_SET )
Example #4
0
def render_all():
    global fov_recompute
    fov_recompute = True
    # go through all tiles, and set their background color according to the FOV
    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)
    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: # it's out of the player's FOV
                if map[x][y].explored:
                    libtcod.console_put_char_ex(con, x, y, *map[x][y].render_data(False))
            else: # it's visible
                libtcod.console_put_char_ex(con, x, y, *map[x][y].render_data(True))
                mouse = libtcod.mouse_get_status()
                if x == mouse.cx and y == mouse.cy:
                    libtcod.console_set_back(con, x, y, libtcod.yellow, libtcod.BKGND_SET)
                map[x][y].explored = True    
    for object in objects:
        if libtcod.map_is_in_fov(fov_map, object.x, object.y):
            object.draw()
    player.draw()
    # prepare to render the GUI panel
    libtcod.console_set_background_color(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_foreground_color(panel, color)
        libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, line)
        y += 1
    # show the player's stats
    render_bar(1, 1, BAR_WIDTH, 'HP', player.fighter.hp, player.fighter.max_hp,
        libtcod.dark_green, libtcod.red)

    # display names of objects under the mouse
    libtcod.console_set_foreground_color(panel, libtcod.light_gray)
    libtcod.console_print_left(panel, 1, 0, libtcod.BKGND_NONE, get_names_under_mouse())
    
    # Display on main console
    libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
    # blit the contents of "panel" to the root console
    libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0, PANEL_Y)
Example #5
0
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_back(con, x, y, color_dark_wall, libtcod.BKGND_SET )
            else:
                libtcod.console_set_back(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)
Example #6
0
def render_all():
    global color_dark_wall
    global color_dark_ground

    #Go through tiles, set BG color
    for y in range(MAP_HEIGHT):
        for x in range(MAP_WIDTH):
            wall = map[x][y].block_sight
            if wall:
                libtcod.console_set_back(con, x, y, color_dark_wall,
                                         libtcod.BKGND_SET)
            else:
                libtcod.console_set_back(con, x, y, color_dark_ground,
                                         libtcod.BKGND_SET)

    #Draw all objects in the object list
    for object in objects:
        object.draw()

    #Blit the contents of the "con" console to the root console
    libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
Example #7
0
	def on_apply(self):
		actor = self.actor
		
		messages.Basic('Your mind expands to fill the world around you.', actor, self.symbol)
		
		#for (x, y) in self.actor.map.floodfill(self.actor.x, self.actor.y, 1000, True):
		#	self.actor.memory.update(x, y, scry_color_filter)
		
		for i, points in enumerate(actor.map.iter_floodfill(actor.x, actor.y, 20, True)):
			for (x, y) in points:
				actor.memory.update(x, y, scry_color_filter)
			
			draw_map(actor)
			
			for (x, y) in points:
				libtcod.console_set_back(0, x, y, libtcod.violet)
				libtcod.console_set_fore(0, x, y, libtcod.light_violet)
			
			libtcod.console_flush()
			libtcod.sys_sleep_milli(50)
		
		return True
Example #8
0
def render_all():
    global fov_map, color_dark_wall, color_light_wall
    global color_dark_ground, color_light_ground
    global fov_recompute, FOV_TORCH, FOV_TORCHX, FOV_NOISE, noise

    dx = 0.0
    dy = 0.0
    di = 0.0

    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)
    if FOV_TORCH:
        FOV_TORCHX += 0.2
        tdx = [FOV_TORCHX + 20.0]
        dx = libtcod.noise_simplex(noise, tdx) * 1.5
        tdx[0] += 30.0
        dy = libtcod.noise_simplex(noise, tdx) * 1.5
        di = 0.2 * libtcod.noise_simplex(noise, [FOV_TORCHX])
        FOV_NOISE = libtcod.noise_new(1, 1.0, 1.0)

        # 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_back(con, x, y, color_dark_wall, libtcod.BKGND_SET)
                        else:
                            libtcod.console_set_back(con, x, y, color_dark_ground, libtcod.BKGND_SET)
                else:
                    # it's visible
                    if wall:
                        libtcod.console_set_back(con, x, y, color_light_wall, libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_back(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)
Example #9
0
 def draw_map(self):
     game_map = self.state.game_map
     fov_map = self.state.fov_map
     for x in xrange(len(game_map)):
         for y in range(len(game_map[x])):
             visible = libtcod.map_is_in_fov(fov_map, x, y)
             wall = game_map[x][y].block_sight
             if not visible and game_map[x][y].explored:
                 if wall:
                     libtcod.console_set_back(self.console, x, y, color_dark_wall, libtcod.BKGND_SET)
                 else:
                     libtcod.console_set_back(self.console, x, y, color_dark_ground, libtcod.BKGND_SET)
             elif visible:
                 if wall:
                     libtcod.console_set_back(self.console, x, y, color_light_wall, libtcod.BKGND_SET)
                 else:
                     libtcod.console_set_back(self.console, x, y, color_light_ground, libtcod.BKGND_SET)
                 game_map[x][y].explore()
Example #10
0
def draw_blood():
	libtcod.console_set_background_color(0, libtcod.black)
	libtcod.console_clear(0)
	
	for (x, y), value in MAP.iteritems():
		if value != 0:
			right, left = MAP.get((x+1, y), 0) == 0, MAP.get((x-1,y), 0) == 0
			if right and not left:
				libtcod.console_set_back(0, x,  y, COLOR_LIGHTBLOOD, libtcod.BKGND_SET)
			
			elif left and not right:
				libtcod.console_set_back(0, x,  y, COLOR_SHADOWBLOOD, libtcod.BKGND_SET)
			
			else:
				libtcod.console_set_back(0, x,  y, COLOR_BLOOD, libtcod.BKGND_SET)

	libtcod.console_set_background_color(0, COLOR_BLOOD)
	libtcod.console_rect(0, 0, 0,  WIDTH, 5, False, libtcod.BKGND_SET)
Example #11
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:
		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)
			tile = map[x][y].sort
			if not visible:
				if map[x][y].explored:
					if tile == 'wall':
						libtcod.console_set_back(con, x, y, color_dark_wall, libtcod.BKGND_SET)
					elif tile == 'metal1':
						libtcod.console_set_back(con, x, y, color_dark_metal1, libtcod.BKGND_SET)
					elif tile == 'metal2':
						libtcod.console_set_back(con, x, y, color_dark_metal2, libtcod.BKGND_SET)
					else:
						libtcod.console_set_back(con, x, y, color_dark_ground, libtcod.BKGND_SET)
			else:
				if tile == 'wall':
					libtcod.console_set_back(con, x, y, color_light_wall, libtcod.BKGND_SET)
				elif tile == 'metal1':
					libtcod.console_set_back(con, x, y, color_light_metal1, libtcod.BKGND_SET)
				elif tile == 'metal2':
					libtcod.console_set_back(con, x, y, color_light_metal2, libtcod.BKGND_SET)
				else:
					libtcod.console_set_back(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, MAP_WIDTH, MAP_HEIGHT, 0, 0, 0)

	libtcod.console_set_background_color(panel, libtcod.black)
	libtcod.console_clear(panel)
	
	y = 1
	for (line, color) in game_msgs:
		libtcod.console_set_foreground_color(panel, color)
		libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, line)
		y += 1

	render_bar(1, 1, BAR_WIDTH, 'John\'s Oxygen', player.spaceman.oxygen, player.spaceman.max_oxygen, libtcod.light_red, libtcod.darker_red)
	render_bar(1, 3, BAR_WIDTH, 'Adam\'s Oxygen', npc.spaceman.oxygen, npc.spaceman.max_oxygen, libtcod.light_magenta, libtcod.darker_magenta)

	libtcod.console_set_foreground_color(panel, libtcod.light_gray)
	libtcod.console_print_left(panel, 1, 0, libtcod.BKGND_NONE, get_names_under_mouse())

	libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0, PANEL_Y)

	for object in objects:
		object.clear()
Example #12
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
        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:
                        # it's out of the player's FOV
                        if wall:
                            libtcod.console_set_back(con, x, y, color_dark_wall, libtcod.BKGND_SET)
                        else:
                            libtcod.console_set_back(con, x, y, color_dark_ground, libtcod.BKGND_SET)
                else:
                    # it's visible
                    if wall:
                        libtcod.console_set_back(con, x, y, color_light_wall, libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_back(con, x, y, color_light_ground, libtcod.BKGND_SET)
                        # since it's visible, explore it
                    map[x][y].explored = True

                # draw all objects
    for object in objects:
        if object != player:
            if object.stairs and map[object.x][object.y].explored:
                libtcod.console_set_foreground_color(con, object.color)
                libtcod.console_put_char(con, object.x, object.y, object.char, libtcod.BKGND_NONE)
            else:
                object.draw()
    player.draw()

    # blit 'con' to '0'
    libtcod.console_blit(con, 0, 0, MAP_WIDTH, MAP_HEIGHT, 0, 0, 0)

    # prepare to render the GUI panel
    libtcod.console_set_background_color(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_foreground_color(panel, color)
        libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, 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)
    libtcod.console_print_left(panel, 1, 0, libtcod.BKGND_NONE, get_names_under_mouse())

    # display names of objects under the mouse
    libtcod.console_set_foreground_color(panel, libtcod.light_gray)
    libtcod.console_print_left(panel, 1, 2, libtcod.BKGND_NONE, "Current floor: " + str(current_floor))

    # blit the contents of "panel" to the root console
    libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0, PANEL_Y)
Example #13
0
def renderAll():
    global fovMap, color_dark_wall, color_light_wall
    global color_dark_ground, color_light_ground
    global fovRecompute
    
    if fovRecompute:
        #message("Recomputing the FOV", libtcod.orange)
        fovRecompute = False
        libtcod.map_compute_fov(fovMap, 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(fovMap, x, y)
                wall = map[x][y].block_sight
                visited = map[x][y].explored
                if not visible:
                    if visited:
                        #if a tile is not visible but it was visited, we still display it
                        if wall:
                            #message("Not visible and a wall", libtcod.orange)
                            libtcod.console_set_back(con, x, y, color_dark_wall, libtcod.BKGND_SET)
                        else:
                            libtcod.console_set_back(con, x, y, color_dark_ground, libtcod.BKGND_SET)
                else:
                    #Once we see a tile it is considered explored
                    map[x][y].explored = True
                    
                    #currently visible to the player
                    if wall:
                        #message("Visible and a wall", libtcod.orange)
                        libtcod.console_set_back(con, x, y, color_light_wall, libtcod.BKGND_SET)
                    else:
                        #message("Visible and ground", libtcod.orange)
                        libtcod.console_set_back(con, x, y, color_light_ground, libtcod.BKGND_SET)

    #draw all objects in the list
    for object in objects:
        if object != player:
            object.draw()
    #draw player last so it is always on top
    player.draw()
 
    #blit the contents of "con" to the root console
    libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)

    #prepares the GUI panel
    libtcod.console_set_background_color(panel, libtcod.black)
    libtcod.console_clear(panel)

    #shows the players stats
    renderBar(1, 1, BAR_WIDTH, "HP", player.fighter.hp, player.fighter.max_hp,
        libtcod.light_red, libtcod.darker_red)

    #message(the game messages, one line at a time, libtcod.orange)
    y=1
    for(line, color) in gameMessages:
        libtcod.console_set_foreground_color(panel, color)
        libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, line)
        y += 1

    #display names under the mouse
    libtcod.console_set_foreground_color(panel, libtcod.light_gray)
    libtcod.console_print_left(panel, 1, 0, libtcod.BKGND_NONE, getNamesUnderMouse())

    #blit the panel to the root console
    libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0, PANEL_Y)
Example #14
0
def highlight_tile(x, y):
	# consider changing the hue to yellow instead of the color
	libtcod.console_set_back(0, x, y, libtcod.yellow)
	libtcod.console_set_fore(0, x, y, libtcod.dark_yellow)
Example #15
0
def render_entire_map():
    map_width, map_height = map_size
    for x in range(map_width):
        for y in range(map_height):
            tcod.console_set_back(0, x, y, game_map[x][y])
Example #16
0
def render_all():
    global color_dark_wall, color_light_wall
    global color_dark_ground, color_light_ground
    global fov_recompute

    if fov_recompute:
        #recompute FOV if needed (such as player movement or spellcasting or light or something)
        fov_recompute = True
        libtcod.map_compute_fov(fov_map, player.x, player.y, TORCH_RADIUS,
                                FOV_LIGHT_WALLS, FOV_ALGO)

        #Go through tiles, set BG color
        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:
                    #Even if it isn't visible it should be "remembered"
                    if map[x][y].explored:
                        #out of player FOV
                        if wall:
                            libtcod.console_set_back(con, x, y,
                                                     color_dark_wall,
                                                     libtcod.BKGND_SET)
                        else:
                            libtcod.console_set_back(con, x, y,
                                                     color_dark_ground,
                                                     libtcod.BKGND_SET)
                else:
                    #it is visible
                    if wall:
                        libtcod.console_set_back(con, x, y, color_light_wall,
                                                 libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_back(con, x, y, color_light_ground,
                                                 libtcod.BKGND_SET)
                    map[x][y].explored = True

        #Draw all objects in the object list
        for object in objects:
            if object != player:
                object.draw()
        player.draw()

        #Blit the contents of the "con" console to the root console
        libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)

        #prepare to render GUI panels
        libtcod.console_set_background_color(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_foreground_color(panel, color)
            libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE,
                                       line)
            y += 1

        #show player's stats
        render_bar(1, 1, BAR_WIDTH, 'HP', player.combat.hp,
                   player.combat.max_hp, libtcod.light_red, libtcod.darker_red)
        libtcod.console_print_left(panel, 1, 3, libtcod.BKGND_NONE,
                                   'Dungeon level ' + str(dungeon_level))

        #Display names of things under mouse
        libtcod.console_set_foreground_color(panel, libtcod.light_gray)
        libtcod.console_print_left(panel, 1, 0, libtcod.BKGND_NONE,
                                   get_names_under_mouse())

        #blit the contents of the 'panel' to the root console
        libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0,
                             PANEL_Y)
Example #17
0
 def draw(self):
     if self.region[cursor.x][cursor.y].drawn:
         libtcod.console_set_back(con, cursor.x, cursor.y, WALL, libtcod.BKGND_SET)
     else:
         libtcod.console_set_back(con, cursor.x, cursor.y, GROUND, libtcod.BKGND_SET)
Example #18
0
 def render(self, console=False, export=False):
     
     if not self._displayWidth or not self._displayHeight:
         print ('ERROR: Display dimensions not set, can not render Map.')
         sys.exit()
     if (self.width < self._displayWidth or self.height < self._displayHeight):
         print ('ERROR: Map size smaller than display size.')
         sys.exit()
     
     
     if console == False:
         console = self._displayCon
     
     if export:
         _offsetX = 0
         _offsetY = 0
         zoom = 0
     else:
         _offsetX = self._offsetX
         _offsetY = self._offsetY
         zoom = self._zoomLevel
     
     
     for cy in range(0, tcod.console_get_height(console) ):
         for cx in range(0, tcod.console_get_width(console) ):
             
             mx = cx + _offsetX
             my = cy + _offsetY
             
             c = self.coords[mx][my]
             
             tcod.console_put_char_ex(
                 console, cx, cy, 
                 c.char, 
                 c.fg(), c.bg())
             
             
             if (self._displayOverlay != None):
                 #TODO: generate overlays once, and move this stuff to the display layer.
                 if (self._displayOverlay == self.OVERLAY_TEMP):
                     
                     bgOverlay = c.tempColor
                 
                 elif (self._displayOverlay == self.OVERLAY_SALT):
                     
                     bgOverlay = c.saltColor
                 
                 elif (self._displayOverlay == self.OVERLAY_RAIN):
                     
                     bgOverlay = c.rainColor
                 
                 elif (self._displayOverlay == self.OVERLAY_BIOME):
                     
                     bgOverlay = c.biome.overlayColor
                 
                 
                 tcod.console_set_back(console, cx, cy, bgOverlay, tcod.BKGND_ALPHA(0.8))
             
             
     if not export:
         
         if ( self._zoomLevel == 0):
             height = self.height
             width = self.width
         elif (self._zoomLevel == 1):
             height = self.height/self.zoomFactor # / self.zoomLevel, right??
             width = self.width/self.zoomFactor
         
         if (self._selectedY <= self._displayHeight/2):
             self._hudY = self._selectedY
         elif (self._selectedY >= height - self._displayHeight/2):
             self._hudY = \
                 self._displayHeight/2 + (self._selectedY - (height - self._displayHeight/2))
         
         if ( self.showCrosshair ):
             if (self._selectedX <= self._displayWidth/2):
                 self._hudX = self._selectedX
             elif (self._selectedX >= width - self._displayWidth/2):
                 self._hudX = self._displayWidth - (width - self._selectedX)
             
             tcod.console_put_char(console, self._hudX, self._hudY, 'X', tcod.BKGND_NONE)
             tcod.console_set_fore(console, self._hudX, self._hudY, tcod.Color(255, 0, 127))
         
         
         if (self._displayStats):
             self._printStats(console)
     
     return console
Example #19
0
def renderAll():
    global fovMap, color_dark_wall, color_light_wall
    global color_dark_ground, color_light_ground
    global fovRecompute

    if fovRecompute:
        #message("Recomputing the FOV", libtcod.orange)
        fovRecompute = False
        libtcod.map_compute_fov(fovMap, 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(fovMap, x, y)
                wall = map[x][y].block_sight
                visited = map[x][y].explored
                if not visible:
                    if visited:
                        #if a tile is not visible but it was visited, we still display it
                        if wall:
                            #message("Not visible and a wall", libtcod.orange)
                            libtcod.console_set_back(con, x, y,
                                                     color_dark_wall,
                                                     libtcod.BKGND_SET)
                        else:
                            libtcod.console_set_back(con, x, y,
                                                     color_dark_ground,
                                                     libtcod.BKGND_SET)
                else:
                    #Once we see a tile it is considered explored
                    map[x][y].explored = True

                    #currently visible to the player
                    if wall:
                        #message("Visible and a wall", libtcod.orange)
                        libtcod.console_set_back(con, x, y, color_light_wall,
                                                 libtcod.BKGND_SET)
                    else:
                        #message("Visible and ground", libtcod.orange)
                        libtcod.console_set_back(con, x, y, color_light_ground,
                                                 libtcod.BKGND_SET)

    #draw all objects in the list
    for object in objects:
        if object != player:
            object.draw()
    #draw player last so it is always on top
    player.draw()

    #blit the contents of "con" to the root console
    libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)

    #prepares the GUI panel
    libtcod.console_set_background_color(panel, libtcod.black)
    libtcod.console_clear(panel)

    #shows the players stats
    renderBar(1, 1, BAR_WIDTH, "HP", player.fighter.hp, player.fighter.max_hp,
              libtcod.light_red, libtcod.darker_red)

    #message(the game messages, one line at a time, libtcod.orange)
    y = 1
    for (line, color) in gameMessages:
        libtcod.console_set_foreground_color(panel, color)
        libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, line)
        y += 1

    #display names under the mouse
    libtcod.console_set_foreground_color(panel, libtcod.light_gray)
    libtcod.console_print_left(panel, 1, 0, libtcod.BKGND_NONE,
                               getNamesUnderMouse())

    #blit the panel to the root console
    libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0,
                         PANEL_Y)
Example #20
0
def render_all():
    global color_light_wall, color_light_ground
    global color_dark_wall, color_dark_ground
    global fov_map, fov_recompute
    global player, map

    # draw the map
    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:
                    # 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 map[x][y].explored:
                        if wall:
                            libtcod.console_set_back(con, x, y,
                                                     color_dark_wall,
                                                     libtcod.BKGND_SET)
                        else:
                            libtcod.console_set_back(con, x, y,
                                                     color_dark_ground,
                                                     libtcod.BKGND_SET)
                else:
                    # it's visible
                    # explore the tile since it is visible right now
                    map[x][y].explored = True
                    if wall:
                        libtcod.console_set_back(con, x, y, color_light_wall,
                                                 libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_back(con, x, y, color_light_ground,
                                                 libtcod.BKGND_SET)

    # draw all objects in the list, except the player, we want it to
    # always appear over all the other objects! so it's drawn later.
    for object in objects:
        if object != player:
            object.draw()
    player.draw()

    # blit off-screen console to root one
    libtcod.console_blit(con, 0, 0, MAP_WIDTH, MAP_HEIGHT, 0, 0, 0)

    # prepare to render the GUI panel
    libtcod.console_set_background_color(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_foreground_color(panel, color)
        libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, 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.dark_red)

    # mouse look command
    libtcod.console_set_foreground_color(panel, libtcod.light_gray)
    libtcod.console_print_left(panel, 1, 0, libtcod.BKGND_NONE,
                               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)
Example #21
0
def render_all():
    global color_light_wall, color_light_ground
    global color_dark_wall, color_dark_ground
    global fov_map, fov_recompute
    global player, map, dungeon_level, stairs

    # draw the map
    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:
                    # 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 map[x][y].explored:
                        if wall:
                            libtcod.console_set_back(con, x, y, color_dark_wall, libtcod.BKGND_SET )
                        else:
                            libtcod.console_set_back(con, x, y, color_dark_ground, libtcod.BKGND_SET )
                else:
                    # it's visible
                    # explore the tile since it is visible right now
                    map[x][y].explored = True
                    if wall:
                        libtcod.console_set_back(con, x, y, color_light_wall, libtcod.BKGND_SET )
                    else:
                        libtcod.console_set_back(con, x, y, color_light_ground, libtcod.BKGND_SET )

    # draw all objects in the list, except the player, we want it to
    # always appear over all the other objects! so it's drawn later.
    for object in objects:
        if object != player:
            object.draw()
    player.draw()

    # blit off-screen console to root one
    libtcod.console_blit(con, 0, 0, MAP_WIDTH, MAP_HEIGHT, 0, 0, 0)

    # prepare to render the GUI panel
    libtcod.console_set_background_color(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_foreground_color(panel, color)
        libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, 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.dark_red)

    # dungeon level
    libtcod.console_print_left(panel, 1, 3, libtcod.BKGND_NONE, 'Dungeon level ' + str(dungeon_level))

    # mouse look command
    libtcod.console_set_foreground_color(panel, libtcod.light_gray)
    libtcod.console_print_left(panel, 1, 0, libtcod.BKGND_NONE, 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)
Example #22
0
def draw_title():
	for (x, y) in TITLE_TILES:
		libtcod.console_set_back(0, x,  y, COLOR_TITLE, libtcod.BKGND_ADD)
Example #23
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:
        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)
            tile = map[x][y].sort
            if not visible:
                if map[x][y].explored:
                    if tile == 'wall':
                        libtcod.console_set_back(con, x, y, color_dark_wall,
                                                 libtcod.BKGND_SET)
                    elif tile == 'metal1':
                        libtcod.console_set_back(con, x, y, color_dark_metal1,
                                                 libtcod.BKGND_SET)
                    elif tile == 'metal2':
                        libtcod.console_set_back(con, x, y, color_dark_metal2,
                                                 libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_back(con, x, y, color_dark_ground,
                                                 libtcod.BKGND_SET)
            else:
                if tile == 'wall':
                    libtcod.console_set_back(con, x, y, color_light_wall,
                                             libtcod.BKGND_SET)
                elif tile == 'metal1':
                    libtcod.console_set_back(con, x, y, color_light_metal1,
                                             libtcod.BKGND_SET)
                elif tile == 'metal2':
                    libtcod.console_set_back(con, x, y, color_light_metal2,
                                             libtcod.BKGND_SET)
                else:
                    libtcod.console_set_back(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, MAP_WIDTH, MAP_HEIGHT, 0, 0, 0)

    libtcod.console_set_background_color(panel, libtcod.black)
    libtcod.console_clear(panel)

    y = 1
    for (line, color) in game_msgs:
        libtcod.console_set_foreground_color(panel, color)
        libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, line)
        y += 1

    render_bar(1, 1, BAR_WIDTH, 'John\'s Oxygen', player.spaceman.oxygen,
               player.spaceman.max_oxygen, libtcod.light_red,
               libtcod.darker_red)
    render_bar(1, 3, BAR_WIDTH, 'Adam\'s Oxygen', npc.spaceman.oxygen,
               npc.spaceman.max_oxygen, libtcod.light_magenta,
               libtcod.darker_magenta)

    libtcod.console_set_foreground_color(panel, libtcod.light_gray)
    libtcod.console_print_left(panel, 1, 0, libtcod.BKGND_NONE,
                               get_names_under_mouse())

    libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0,
                         PANEL_Y)

    for object in objects:
        object.clear()
Example #24
0
def render_all():
    global fov_map, color_dark_wall, color_light_wall
    global color_dark_ground, color_light_ground
    global fov_recompute, make_map
     
    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_back(con, x, y, color_dark_wall, libtcod.BKGND_SET)
                        else:
                            libtcod.console_set_back(con, x, y, color_dark_ground, libtcod.BKGND_SET)
                else:
                    #it's visible
                    if wall:
                        libtcod.console_set_back(con, x, y, color_light_wall, libtcod.BKGND_SET )
                    else:
                        libtcod.console_set_back(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_background_color(panel, libtcod.black)
    libtcod.console_clear(panel)
 
    #print the game messages, one line at a time
    y = 0
    for (line, color) in game_msgs:
        libtcod.console_set_foreground_color(panel, color)
        libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, line)
        y += 1
 
    #show the player's stats
    render_bar(1, 0, BAR_WIDTH, 'HP', player.fighter.hp, player.fighter.max_hp,
        libtcod.light_red, libtcod.darker_red)
    #render_bar(2, 0, BAR_WIDTH, 'MP', player.fighter.mp, player.fighter.mp,
    #    libtcod.light_blue, libtcod.darker_blue)
 
    #blit the contents of "panel" to the root console
    libtcod.console_blit(panel, 0, 0, MAP_WIDTH, PANEL_HEIGHT, 0, 0, SCREEN_HEIGHT-PANEL_HEIGHT)
Example #25
0
    def render(self, console=False, export=False):

        if not self._displayWidth or not self._displayHeight:
            print('ERROR: Display dimensions not set, can not render Map.')
            sys.exit()
        if (self.width < self._displayWidth
                or self.height < self._displayHeight):
            print('ERROR: Map size smaller than display size.')
            sys.exit()

        if console == False:
            console = self._displayCon

        if export:
            _offsetX = 0
            _offsetY = 0
            zoom = 0
        else:
            _offsetX = self._offsetX
            _offsetY = self._offsetY
            zoom = self._zoomLevel

        for cy in range(0, tcod.console_get_height(console)):
            for cx in range(0, tcod.console_get_width(console)):

                mx = cx + _offsetX
                my = cy + _offsetY

                c = self.coords[mx][my]

                tcod.console_put_char_ex(console, cx, cy, c.char, c.fg(),
                                         c.bg())

                if (self._displayOverlay != None):
                    #TODO: generate overlays once, and move this stuff to the display layer.
                    if (self._displayOverlay == self.OVERLAY_TEMP):

                        bgOverlay = c.tempColor

                    elif (self._displayOverlay == self.OVERLAY_SALT):

                        bgOverlay = c.saltColor

                    elif (self._displayOverlay == self.OVERLAY_RAIN):

                        bgOverlay = c.rainColor

                    elif (self._displayOverlay == self.OVERLAY_BIOME):

                        bgOverlay = c.biome.overlayColor

                    tcod.console_set_back(console, cx, cy, bgOverlay,
                                          tcod.BKGND_ALPHA(0.8))

        if not export:

            if (self._zoomLevel == 0):
                height = self.height
                width = self.width
            elif (self._zoomLevel == 1):
                height = self.height / self.zoomFactor  # / self.zoomLevel, right??
                width = self.width / self.zoomFactor

            if (self._selectedY <= self._displayHeight / 2):
                self._hudY = self._selectedY
            elif (self._selectedY >= height - self._displayHeight / 2):
                self._hudY = \
                    self._displayHeight/2 + (self._selectedY - (height - self._displayHeight/2))

            if (self.showCrosshair):
                if (self._selectedX <= self._displayWidth / 2):
                    self._hudX = self._selectedX
                elif (self._selectedX >= width - self._displayWidth / 2):
                    self._hudX = self._displayWidth - (width - self._selectedX)

                tcod.console_put_char(console, self._hudX, self._hudY, 'X',
                                      tcod.BKGND_NONE)
                tcod.console_set_fore(console, self._hudX, self._hudY,
                                      tcod.Color(255, 0, 127))

            if (self._displayStats):
                self._printStats(console)

        return console