-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender_functions.py
More file actions
49 lines (37 loc) · 1.77 KB
/
render_functions.py
File metadata and controls
49 lines (37 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from enum import Enum
class RenderOrder(Enum):
CORPSE = 1
ITEM = 2
ACTOR = 3
def render_all(con, entities, player, game_map, fov_recompute, root_console, screen_width, screen_height, colors):
if fov_recompute:
# Draw all the tiles in the game map:
for x, y in game_map:
wall = not game_map.transparent[x, y];
if game_map.fov[x, y]:
if wall:
con.draw_char(x, y, None, fg=None, bg=colors.get('light_wall'));
else:
con.draw_char(x, y, None, fg=None, bg=colors.get('light_ground'));
game_map.explored[x][y] = True;
elif game_map.explored[x][y]:
if wall:
con.draw_char(x, y, None, fg=None, bg=colors.get('dark_wall'));
else:
con.draw_char(x, y, None, fg=None, bg=colors.get('dark_ground'));
# sorteia as entidades para renderizarem na ordem certa.
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, game_map.fov);
con.draw_str(1, screen_height - 2, 'HP: {0:02}/{1:02}'.format(player.fighter.hp, player.fighter.max_hp));
root_console.blit(con, 0, 0, screen_width, screen_height, 0, 0);
def clear_all(con, entities):
for entity in entities:
clear_entity(con, entity);
def draw_entity(con, entity, fov):
if fov[entity.x, entity.y]:
con.draw_char(entity.x, entity.y, entity.char, entity.color, bg=None);
def clear_entity(con, entity):
# erase the character that represents this object
con.draw_char(entity.x, entity.y, ' ', entity.color, bg=None);