Use map display

This commit is contained in:
Yohann D'ANELLO 2020-10-23 15:00:59 +02:00
parent 7d97befee4
commit eea9b45f6c
2 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,5 @@
from .interfaces import Map from .interfaces import Map
from .mapdisplay import MapDisplay
from .term_manager import TermManager from .term_manager import TermManager
@ -13,8 +14,10 @@ class Game:
def _start_game(self, screen): def _start_game(self, screen):
# TODO Generate map, or make the possibility to load another one # TODO Generate map, or make the possibility to load another one
m = Map.load("example_map.txt") m = Map.load("example_map.txt")
d = MapDisplay(m)
screen.refresh()
while True: while True:
screen.addstr(0, 0, m.draw_string()) d.display(1, 6)
screen.refresh() screen.refresh()
key = screen.getkey() key = screen.getkey()
self.handle_key_pressed(key) self.handle_key_pressed(key)

View File

@ -9,8 +9,7 @@ class MapDisplay:
self.pad = curses.newpad(m.height, m.width+1) self.pad = curses.newpad(m.height, m.width+1)
def update_pad(self): def update_pad(self):
for i in range(self.map.height): self.pad.addstr(0, 0, self.map.draw_string())
self.pad.addstr(i, 0, self.map.tiles[i])
for e in self.map.entities: for e in self.map.entities:
self.pad.addch(e.y, e.x, e.img) self.pad.addch(e.y, e.x, e.img)