diff --git a/dungeonbattle/display/display.py b/dungeonbattle/display/display.py index 333f2e9..c5f8ccc 100644 --- a/dungeonbattle/display/display.py +++ b/dungeonbattle/display/display.py @@ -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: diff --git a/dungeonbattle/display/mapdisplay.py b/dungeonbattle/display/mapdisplay.py index b795c8a..1a77f7d 100644 --- a/dungeonbattle/display/mapdisplay.py +++ b/dungeonbattle/display/mapdisplay.py @@ -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: diff --git a/dungeonbattle/display/statsdisplay.py b/dungeonbattle/display/statsdisplay.py index 60e239b..26d0315 100644 --- a/dungeonbattle/display/statsdisplay.py +++ b/dungeonbattle/display/statsdisplay.py @@ -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): diff --git a/dungeonbattle/game.py b/dungeonbattle/game.py index b67d38f..3af8e63 100644 --- a/dungeonbattle/game.py +++ b/dungeonbattle/game.py @@ -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)) diff --git a/example_map2.txt b/example_map2.txt deleted file mode 100644 index 4111fae..0000000 --- a/example_map2.txt +++ /dev/null @@ -1,17 +0,0 @@ - ####### ############# - #.....# #...........# - #.....# #####...........# - #.....# #...............# - #.##### #.###...........# - #.# #.# #...........# - #.# #.# ############# - #.# #.# - #.#### #.# - #....# #.# - ####.###################.# - #.....................# ################# - #.....................# #...............# - #.....................#######...............# - #...........................................# - #.....................#######...............# - ####################### #################