-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui_debug_panel.py
More file actions
49 lines (37 loc) · 1.54 KB
/
ui_debug_panel.py
File metadata and controls
49 lines (37 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""A UI panel which draws debug information."""
from __future__ import annotations
import tcod.console
import tcod.event
import game.managers.global_manager as global_manager
from game.components import Position
from game.constants import COLOR_NAVY, COLOR_WHITE
from game.tags import IsPlayer
from game.ui.ui_panel import UIPanel
class UIDebugPanel(UIPanel):
def __init__(self) -> None:
self.is_visible = False
def on_event(self, event: tcod.event.Event) -> None:
"""Called on events."""
def on_draw(self, console: tcod.console.Console) -> None:
"""Called when the panel is being drawn."""
# A selection of test frame drawing.
console.draw_frame(x=0, y=0, width=3, height=3, decoration="╔═╗║ ║╚═╝")
console.draw_frame(x=3, y=0, width=3, height=3, decoration="┌─┐│ │└─┘")
console.draw_frame(x=6, y=0, width=3, height=3, decoration="123456789")
console.draw_frame(x=9, y=0, width=3, height=3, decoration="/-\\| |\\-/")
# A test rectangle.
console.draw_rect(15, 15, 6, 6, 0, COLOR_WHITE, COLOR_NAVY)
# Get the player entity.
(player,) = global_manager.world.Q.all_of(tags=[IsPlayer])
# Draw debug info at the top center of the screen.
console.print_box(
0,
0,
console.width,
0,
f"\nPlayer pos: {player.components[Position].x, player.components[Position].y}",
COLOR_WHITE,
COLOR_NAVY,
1,
2,
)