Corrected bugs(some still remain)

This commit is contained in:
eichhornchen 2020-11-10 10:49:11 +01:00
parent 91a8919a01
commit 002de68a0a
5 changed files with 13 additions and 30 deletions

View File

@ -6,16 +6,16 @@ from dungeonbattle.display.mapdisplay import MapDisplay
from dungeonbattle.display.statsdisplay import StatsDisplay
from dungeonbattle.display.menudisplay import MenuDisplay
from dungeonbattle.interfaces import Map
from .entities.player import Player
from dungeonbattle.entities.player import Player
class Display:
map: Map
player: Player
def __init__(self, screen: Any, texture: Any):
def __init__(self, screen: Any, m: Map, texture: Any):
self.screen = screen
self.texture = texture
self.mapdisplay = MapDisplay(self.texture, curses.LINES * 4//5, curses.COLS)
self.map = m
self.mapdisplay = MapDisplay(self.map, self.texture, curses.LINES * 4//5, curses.COLS)
self.statsdisplay = StatsDisplay(curses.LINES//5, curses.COLS, curses.LINES * 4//5, 0)
def refresh(self, m : Map, p : Player) -> None:

View File

@ -2,20 +2,19 @@
from typing import Any
import curses
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:
self.map: Map
self.player: Player
player: Player
def __init__(self, pack: TexturePack, height : int, width : int):
def __init__(self, m: Map, pack: TexturePack, height : int, width : int):
self.height = height
self.width = width
self.pack = pack
self.map = m
self.pad = curses.newpad(m.height, m.width + 1)
def update_pad(self) -> None:

View File

@ -1,12 +1,11 @@
from typing import Any
import curses
from dungeonbattle.display.display import Display
from dungeonbattle.entities.player import Player
class StatsDisplay(Display):
self.player: Player
class StatsDisplay():
player: Player
def __init__(self, height: int, width: int,
topleftx: int, toplefty: int):

View File

@ -51,10 +51,12 @@ class Game:
"""
# TODO generate a new map procedurally
self.map = Map.load("example_map.txt")
self.map.currenty = 1
self.map.currentx = 6
self.player = Player()
self.player.move(1, 6)
self.map.add_entity(self.player)
self.display = Display(screen, TexturePack.get_pack(self.settings.TEXTURE_PACK))
self.display = Display(screen, self.map, TexturePack.get_pack(self.settings.TEXTURE_PACK))
# self.menu_display = MenuDisplay(screen, self.main_menu, 0, 0)
@staticmethod
@ -71,7 +73,7 @@ class Game:
while True:
screen.clear()
screen.refresh()
self.display.refresh()
self.display.refresh(self.map, self.player)
key = screen.getkey()
self.handle_key_pressed(self.translate_key(key))

View File

@ -1,17 +0,0 @@
####### #############
#.....# #...........#
#.....# #####...........#
#.....# #...............#
#.##### #.###...........#
#.# #.# #...........#
#.# #.# #############
#.# #.#
#.#### #.#
#....# #.#
####.###################.#
#.....................# #################
#.....................# #...............#
#.....................#######...............#
#...........................................#
#.....................#######...............#
####################### #################