-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender_functions.py
29 lines (22 loc) · 1.04 KB
/
render_functions.py
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
import libtcodpy as libtcod
def render_all(con, entities,game_map,screen_width, screen_height,colors):
#render all the game map tiles
for y in range(game_map.height):
for x in range(game_map.width):
wall=game_map.tiles[x][y].blocked
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 the listed entities
for entity in entities:
draw_entity(con,entity)
libtcod.console_blit(con,0,0,screen_width, screen_height, 0, 0, 0)
def clear_all(con,entities):
for entity in entities:
clear_entity(con, entity)
def draw_entity(con, entity):
libtcod.console_set_default_foreground(con, entity.color)
libtcod.console_put_char(con, entity.x, entity.y, entity.char, libtcod.BKGND_NONE)
def clear_entity(con, entity):
libtcod.console_put_char(con, entity.x, entity.y, ' ', libtcod.BKGND_NONE)