Handle player position in game display

This commit is contained in:
Yohann D'ANELLO
2020-10-23 15:14:19 +02:00
parent eea9b45f6c
commit d264bb45cf
2 changed files with 37 additions and 7 deletions

View File

@@ -4,14 +4,16 @@ from dungeonbattle.interfaces import Map
class MapDisplay:
def __init__(self, m: Map):
def __init__(self, m: Map, player):
self.map = m
self.pad = curses.newpad(m.height, m.width+1)
self.player = player
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.addstr(self.player.getPosY(), self.player.getPosX(), '🐿')
def display(self, y, x):
deltay, deltax = (curses.LINES // 2) + 1, (curses.COLS //2) + 1