From eea9b45f6cd7a891339773fa9a296121b2f4e31b Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 23 Oct 2020 15:00:59 +0200 Subject: [PATCH] Use map display --- dungeonbattle/game.py | 5 ++++- dungeonbattle/mapdisplay.py | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dungeonbattle/game.py b/dungeonbattle/game.py index 92d7722..d220c23 100644 --- a/dungeonbattle/game.py +++ b/dungeonbattle/game.py @@ -1,4 +1,5 @@ from .interfaces import Map +from .mapdisplay import MapDisplay from .term_manager import TermManager @@ -13,8 +14,10 @@ class Game: def _start_game(self, screen): # TODO Generate map, or make the possibility to load another one m = Map.load("example_map.txt") + d = MapDisplay(m) + screen.refresh() while True: - screen.addstr(0, 0, m.draw_string()) + d.display(1, 6) screen.refresh() key = screen.getkey() self.handle_key_pressed(key) diff --git a/dungeonbattle/mapdisplay.py b/dungeonbattle/mapdisplay.py index f482b37..52d63c1 100644 --- a/dungeonbattle/mapdisplay.py +++ b/dungeonbattle/mapdisplay.py @@ -9,8 +9,7 @@ class MapDisplay: self.pad = curses.newpad(m.height, m.width+1) def update_pad(self): - for i in range(self.map.height): - self.pad.addstr(i, 0, self.map.tiles[i]) + self.pad.addstr(0, 0, self.map.draw_string()) for e in self.map.entities: self.pad.addch(e.y, e.x, e.img)