MapDisplay extends Display
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user