MapDisplay extends Display

This commit is contained in:
Yohann D'ANELLO
2020-11-08 23:03:59 +01:00
parent 8ccf8c7b67
commit dc3f55cff3
3 changed files with 16 additions and 14 deletions

View File

@ -1,20 +1,22 @@
#!/usr/bin/env python
import curses
from typing import Any
from dungeonbattle.display.display import Display
from dungeonbattle.display.texturepack import TexturePack
from dungeonbattle.entities.player import Player
from dungeonbattle.interfaces import Map
class MapDisplay:
def __init__(self, m: Map, pack: TexturePack, height: int, width: int,
init_pad: bool = True):
self.width = width
self.height = height
class MapDisplay(Display):
def __init__(self, screen: Any, m: Map, player: Player, pack: TexturePack):
super().__init__(screen)
self.height = self.rows
self.width = self.cols
self.pack = pack
self.map = m
if init_pad:
self.pad = curses.newpad(m.height, m.width + 1)
self.player = player
self.pad = curses.newpad(m.height, m.width + 1)
def update_pad(self) -> None:
self.pad.addstr(0, 0, self.map.draw_string(self.pack))
@ -35,3 +37,6 @@ class MapDisplay:
self.pad.clear()
self.update_pad()
self.pad.refresh(pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol)
def refresh(self) -> None:
return self.display(self.player.y, self.player.x)