Show the current dungeon level on the main interface
This commit is contained in:
parent
9e817cd103
commit
6462fe06ac
12
engine.py
12
engine.py
@ -9,7 +9,7 @@ from tcod.map import compute_fov
|
||||
|
||||
import exceptions
|
||||
from message_log import MessageLog
|
||||
from render_functions import render_bar, render_names_at_mouse_location
|
||||
import render_functions
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from entity import Actor
|
||||
@ -49,14 +49,20 @@ class Engine:
|
||||
|
||||
self.message_log.render(console=console, x=21, y=45, width=40, height=5)
|
||||
|
||||
render_bar(
|
||||
render_functions.render_bar(
|
||||
console,
|
||||
current_value=self.player.fighter.hp,
|
||||
maximum_value=self.player.fighter.max_hp,
|
||||
total_width=20,
|
||||
)
|
||||
|
||||
render_names_at_mouse_location(console, x=21, y=44, engine=self)
|
||||
render_functions.render_dungeon_level(
|
||||
console,
|
||||
dungeon_level=self.game_world.current_floor,
|
||||
location=(0, 47)
|
||||
)
|
||||
|
||||
render_functions.render_names_at_mouse_location(console, x=21, y=44, engine=self)
|
||||
|
||||
def save_as(self, filename: str) -> None:
|
||||
"""Save this Engine instance as a compressed file."""
|
||||
|
@ -404,9 +404,15 @@ class MainGameEventHandler(EventHandler):
|
||||
action: Optional[Action] = None
|
||||
|
||||
key = event.sym
|
||||
modifier = event.mod
|
||||
|
||||
player = self.engine.player
|
||||
|
||||
if key == tcod.event.K_PERIOD and modifier & (
|
||||
tcod.event.KMOD_LSHIFT | tcod.event.KMOD_RSHIFT
|
||||
):
|
||||
return actions.TakeStairsAction(player)
|
||||
|
||||
if key in MOVE_KEYS:
|
||||
dx, dy = MOVE_KEYS[key]
|
||||
action = BumpAction(player, dx, dy)
|
||||
|
@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import Tuple, TYPE_CHECKING
|
||||
|
||||
import color
|
||||
|
||||
@ -49,6 +49,19 @@ def render_bar(
|
||||
)
|
||||
|
||||
|
||||
def render_dungeon_level(
|
||||
console: Console,
|
||||
dungeon_level: int,
|
||||
location: Tuple[int, int]
|
||||
) -> None:
|
||||
"""
|
||||
Render the level the player is currently on, at the given location.
|
||||
"""
|
||||
x, y = location
|
||||
|
||||
console.print(x, y, string=f"Dungeon level: {dungeon_level}")
|
||||
|
||||
|
||||
def render_names_at_mouse_location(
|
||||
console: Console,
|
||||
x: int,
|
||||
|
@ -36,6 +36,7 @@ def new_game() -> Engine:
|
||||
engine = Engine(player)
|
||||
|
||||
engine.game_world = GameWorld(
|
||||
engine=engine,
|
||||
max_rooms=max_rooms,
|
||||
room_min_size=room_min_size,
|
||||
room_max_size=room_max_size,
|
||||
|
Loading…
Reference in New Issue
Block a user