def draw_chunk_map(life=None, show_faction_ownership=False): _x_min = numbers.clip(CAMERA_POS[0]/WORLD_INFO['chunk_size'], 0, MAP_SIZE[0]/WORLD_INFO['chunk_size']) _y_min = numbers.clip(CAMERA_POS[1]/WORLD_INFO['chunk_size'], 0, MAP_SIZE[1]/WORLD_INFO['chunk_size']) _x_max = numbers.clip(_x_min+WINDOW_SIZE[0], 0, MAP_SIZE[0]/WORLD_INFO['chunk_size']) _y_max = numbers.clip(_y_min+WINDOW_SIZE[1], 0, MAP_SIZE[1]/WORLD_INFO['chunk_size']) _life_chunk_key = None if life: _life_chunk_key = lfe.get_current_chunk_id(life) for x in range(_x_min, _x_max): _d_x = x-(CAMERA_POS[0]/WORLD_INFO['chunk_size']) if 0>_d_x >= WINDOW_SIZE[0]: continue for y in range(_y_min, _y_max): _d_y = y-(CAMERA_POS[1]/WORLD_INFO['chunk_size']) _draw = True _fore_color = tcod.darker_gray _back_color = tcod.darkest_gray if 0>_d_y >= WINDOW_SIZE[1]: continue _chunk_key = '%s,%s' % (x*WORLD_INFO['chunk_size'], y*WORLD_INFO['chunk_size']) if life: if not _chunk_key in life['known_chunks']: _draw = False if _draw: _type = WORLD_INFO['chunk_map'][_chunk_key]['type'] _char = 'x' if _type in ['building', 'town']: _fore_color = tcod.light_gray _char = 'B' elif _type in ['outpost', 'factory']: _fore_color = tcod.desaturated_green _back_color = tcod.desaturated_han _char = 'M' elif _type == 'field': _fore_color = tcod.yellow elif _type == 'forest': _fore_color = tcod.dark_green elif _type in ['road', 'driveway']: _fore_color = tcod.white _back_color = tcod.black _char = '.' if _chunk_key == _life_chunk_key and time.time()%1>=.5: _fore_color = tcod.white _char = 'X' gfx.blit_char_to_view(_d_x, _d_y, _char, (_fore_color, _back_color), 'chunk_map') else: gfx.blit_char_to_view(_d_x, _d_y, 'x', (tcod.darker_gray, tcod.darkest_gray), 'chunk_map')
def draw_all_items(): _view = gfx.get_view_by_name('map') for _item in ITEMS: item = ITEMS[_item] if is_item_owned(item['uid']): continue if item['pos'][0] >= CAMERA_POS[0] and item['pos'][0] < CAMERA_POS[0]+_view['draw_size'][0] and\ item['pos'][1] >= CAMERA_POS[1] and item['pos'][1] < CAMERA_POS[1]+_view['draw_size'][1]: _x = item['pos'][0] - CAMERA_POS[0] _y = item['pos'][1] - CAMERA_POS[1] gfx.blit_char_to_view(_x, _y, item['icon'], (item['color'][0], item['color'][1]), 'map')
def draw_all_items(): _view = gfx.get_view_by_name('map') for _item in ITEMS: item = ITEMS[_item] if is_item_owned(item['uid']): continue if item['pos'][0] >= CAMERA_POS[0] and item['pos'][0] < CAMERA_POS[0]+_view['draw_size'][0] and\ item['pos'][1] >= CAMERA_POS[1] and item['pos'][1] < CAMERA_POS[1]+_view['draw_size'][1]: _x = item['pos'][0]-CAMERA_POS[0] _y = item['pos'][1]-CAMERA_POS[1] gfx.blit_char_to_view(_x, _y, item['icon'], (item['color'][0], item['color'][1]), 'map')
def draw_items(view_size=MAP_WINDOW_SIZE): _view = gfx.get_view_by_name('map') for item_uid in LIFE[SETTINGS['following']]['seen_items']: if not item_uid in ITEMS: continue _item = ITEMS[item_uid] _d_x = _item['pos'][0] - CAMERA_POS[0] _d_y = _item['pos'][1] - CAMERA_POS[1] if _d_x < 0 or _d_x >= MAP_WINDOW_SIZE[ 0] or _d_y < 0 or _d_y >= MAP_WINDOW_SIZE[1]: continue if not alife.sight.is_in_fov(LIFE[SETTINGS['following']], _item['pos']): continue gfx.blit_char_to_view(_d_x, _d_y, _item['icon'], (_item['color'][0], _item['color'][1]), 'map')
def draw_items(view_size=MAP_WINDOW_SIZE): _view = gfx.get_view_by_name('map') for item_uid in LIFE[SETTINGS['following']]['seen_items']: if not item_uid in ITEMS: continue _item = ITEMS[item_uid] _d_x = _item['pos'][0]-CAMERA_POS[0] _d_y = _item['pos'][1]-CAMERA_POS[1] if _d_x < 0 or _d_x >= MAP_WINDOW_SIZE[0] or _d_y < 0 or _d_y >= MAP_WINDOW_SIZE[1]: continue if not alife.sight.is_in_fov(LIFE[SETTINGS['following']], _item['pos']): continue gfx.blit_char_to_view(_d_x, _d_y, _item['icon'], (_item['color'][0], _item['color'][1]), 'map')