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.statsdisplay import StatsDisplay
from dungeonbattle.display.menudisplay import MenuDisplay from dungeonbattle.display.menudisplay import MenuDisplay
from dungeonbattle.interfaces import Map from dungeonbattle.interfaces import Map
from .entities.player import Player from dungeonbattle.entities.player import Player
class Display: class Display:
map: Map
player: Player player: Player
def __init__(self, screen: Any, texture: Any): def __init__(self, screen: Any, m: Map, texture: Any):
self.screen = screen self.screen = screen
self.texture = texture 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) self.statsdisplay = StatsDisplay(curses.LINES//5, curses.COLS, curses.LINES * 4//5, 0)
def refresh(self, m : Map, p : Player) -> None: def refresh(self, m : Map, p : Player) -> None:

View File

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

View File

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

View File

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

View File

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