68483c648e
Die Hauptszene verbindet Kern, Karte, Figur, Anzeige und Dateien: fester Takt, Laufen, Stein schlagen in Reichweite, Speichern mit F5, Laden mit F9, Pause mit Esc, automatisches Speichern alle zwei Minuten und beim Schließen. Die Karte erscheint in Platzhalterfarben, bis in M1d ein Stil gewählt ist. Ein Werkzeug macht Bildschirmfotos ohne Handarbeit. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
59 lines
1.5 KiB
GDScript
59 lines
1.5 KiB
GDScript
class_name Hud
|
|
extends CanvasLayer
|
|
## Text over the game: the stone count, short messages and a help line.
|
|
|
|
const MESSAGE_SECONDS := 2.5
|
|
|
|
var _stone := Label.new()
|
|
var _message := Label.new()
|
|
var _help := Label.new()
|
|
var _message_left := 0.0
|
|
|
|
|
|
func _ready() -> void:
|
|
_stone.position = Vector2(16, 12)
|
|
_stone.add_theme_font_size_override("font_size", 22)
|
|
_message.position = Vector2(16, 48)
|
|
_message.add_theme_font_size_override("font_size", 18)
|
|
_help.text = tr("HELP")
|
|
_help.add_theme_font_size_override("font_size", 14)
|
|
for label: Label in [_stone, _message, _help]:
|
|
label.add_theme_color_override("font_outline_color", Color.BLACK)
|
|
label.add_theme_constant_override("outline_size", 4)
|
|
add_child(label)
|
|
_help.set_anchors_and_offsets_preset(Control.PRESET_BOTTOM_LEFT, Control.PRESET_MODE_MINSIZE, 16)
|
|
|
|
|
|
func _process(delta: float) -> void:
|
|
if _message_left <= 0.0:
|
|
return
|
|
_message_left -= delta
|
|
if _message_left <= 0.0:
|
|
_message.text = ""
|
|
|
|
|
|
func show_stone(count: int) -> void:
|
|
_stone.text = tr("STONE_COUNT") % count
|
|
|
|
|
|
## Shows the text for `key` for a few seconds.
|
|
func flash(key: String) -> void:
|
|
_message.text = tr(key)
|
|
_message_left = MESSAGE_SECONDS
|
|
|
|
|
|
## Shows or hides the pause notice. It stays until the game continues.
|
|
func show_paused(paused: bool) -> void:
|
|
_message.text = tr("PAUSED") if paused else ""
|
|
_message_left = 0.0
|
|
|
|
|
|
## The text currently shown as a message. Tests read it.
|
|
func message() -> String:
|
|
return _message.text
|
|
|
|
|
|
## The text currently shown as the stone count. Tests read it.
|
|
func stone_text() -> String:
|
|
return _stone.text
|