Looks like I fixed some spacing at some point. Moved Game_map and render_functions to the parent directory. For some reason they were in the venv folder. Added requirements.txt. Going to begin updating code to use latest version of tcod.
This commit is contained in:
33
render_functions.py
Normal file
33
render_functions.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import tcod as tc
|
||||
|
||||
def render_all(con, entities, game_map, screen_width, screen_height, colors):
|
||||
# Draw all 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:
|
||||
tc.console_set_char_background(con, x, y, colors.get('dark_wall'), tc.BKGND_SET)
|
||||
else:
|
||||
tc.console_set_char_background(con, x, y, colors.get('dark_ground'), tc.BKGND_SET)
|
||||
|
||||
# Draw all entities in the list
|
||||
for entity in entities:
|
||||
draw_entity(con, entity)
|
||||
|
||||
tc. 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):
|
||||
tc.console_set_default_foreground(con, entity.color)
|
||||
tc.console_put_char(con, entity.x, entity.y, entity.char, tc.BKGND_NONE)
|
||||
|
||||
|
||||
def clear_entity(con, entity):
|
||||
# Erase the charect that represents this object
|
||||
tc.console_put_char(con, entity.x, entity.y, ' ', tc.BKGND_NONE)
|
||||
Reference in New Issue
Block a user