Added a MainMenuDisplay class and fixed errors in display

This commit is contained in:
eichhornchen
2020-11-10 10:01:31 +01:00
parent 10bbb28471
commit 91a8919a01
6 changed files with 62 additions and 13 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python
from typing import Any
import curses
from dungeonbattle.display.display import Display
from dungeonbattle.display.texturepack import TexturePack
@ -11,19 +12,18 @@ class MapDisplay:
self.map: Map
self.player: Player
def __init__(self, screen: Any, pack: TexturePack, height : int, width : int):
self.screen = screen
def __init__(self, pack: TexturePack, height : int, width : int):
self.height = height
self.width = width
self.pack = pack
self.pad = self.newpad(m.height, m.width + 1)
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))
for e in self.map.entities:
self.pad.addstr(e.y, e.x, self.pack.PLAYER)
def display(self) -> None:
def display(self, y, x) -> None:
deltay, deltax = (self.height // 2) + 1, (self.width // 2) + 1
pminrow, pmincol = y - deltay, x - deltax
sminrow, smincol = max(-pminrow, 0), max(-pmincol, 0)
@ -42,4 +42,4 @@ class MapDisplay:
self.map = m
self.player = p
y, x = self.map.currenty, self.map.currentx
return self.display()
self.display(y,x)