From 3d98eac74b9834e5c706f10521ab0e15d7f827ec Mon Sep 17 00:00:00 2001 From: eichhornchen Date: Fri, 6 Nov 2020 16:43:07 +0100 Subject: [PATCH] Added refresh function --- dungeonbattle/display/mapdisplay.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dungeonbattle/display/mapdisplay.py b/dungeonbattle/display/mapdisplay.py index 471aa91..8614821 100644 --- a/dungeonbattle/display/mapdisplay.py +++ b/dungeonbattle/display/mapdisplay.py @@ -1,19 +1,23 @@ #!/usr/bin/env python import curses from dungeonbattle.interfaces import Map +from dungeonbattle.settings import Settings +import dungeonbattle.texturepack class MapDisplay: - def __init__(self, m: Map, height: int, width: int): + def __init__(self, m: Map, settings : Settings, height: int, width: int): self.width = width self.height = height self.map = m self.pad = curses.newpad(m.height, m.width+1) + if Settings.TEXTURE_PACK == 'ASCII' + self.textures = ascii_textures def update_pad(self): self.pad.addstr(0, 0, self.map.draw_string()) for e in self.map.entities: - self.pad.addch(e.y, e.x, e.img) + self.pad.addch(e.y, e.x, self.textures[e.name]) def display(self, y, x): deltay, deltax = (self.height // 2) + 1, (self.width //2) + 1 @@ -29,3 +33,7 @@ class MapDisplay: self.pad.clear() self.update_pad() self.pad.refresh(pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) + + def refresh(self) : + self.display(self.map.currenty,self.map.currentx) +