Added refresh function
This commit is contained in:
parent
85a006e7b6
commit
3d98eac74b
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue