Phase 0: Greybox-Fundament
- Input-Map: alle Actions aus SPEC 9 (Tastatur + Xbox/PS5, physische Keycodes, Deadzone 0.2) - 11 Autoload-Skelette (SPEC 8) mit Doku-Bloecken, ohne Logik - Greybox-Testszene test_ground.tscn: Boden, Hindernisse, Spieler-Kapsel, Third-Person-Kamera (WoW-Zoom via SpringArm3D), WorldEnvironment - Debug-Overlay: FPS, aktives Eingabegeraet, Position, Kamera-Zoom - test_ground.tscn als Main Scene gesetzt Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
commit
f4c67ceead
40 changed files with 1064 additions and 0 deletions
58
scripts/ui/debug_overlay.gd
Normal file
58
scripts/ui/debug_overlay.gd
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
extends CanvasLayer
|
||||
## Debug-Overlay für Phase 0.
|
||||
##
|
||||
## Zeigt FPS, das zuletzt benutzte Eingabegerät (Tastatur/Maus, Xbox- oder
|
||||
## PS5-Controller), die Spielerposition und die aktuelle Kamera-Distanz an.
|
||||
## Die provisorische Geräteerkennung wandert in einer späteren Phase in das
|
||||
## Autoload InputPrompts (dynamische Button-Prompts, SPEC.md Abschnitt 2).
|
||||
|
||||
const JOY_MOTION_THRESHOLD := 0.2
|
||||
const PLAYSTATION_NAME_HINTS: Array[String] = [
|
||||
"ps5", "ps4", "dualsense", "dualshock", "sony", "playstation",
|
||||
]
|
||||
|
||||
@export var player_path: NodePath
|
||||
|
||||
var _active_device := "Tastatur/Maus"
|
||||
var _player: CharacterBody3D
|
||||
|
||||
@onready var _info_label: Label = $InfoLabel
|
||||
|
||||
|
||||
## Löst die Spieler-Referenz aus dem exportierten Pfad auf.
|
||||
func _ready() -> void:
|
||||
_player = get_node_or_null(player_path) as CharacterBody3D
|
||||
|
||||
|
||||
## Merkt sich das zuletzt benutzte Eingabegerät anhand des Event-Typs;
|
||||
## Stick-Rauschen unterhalb der Deadzone wird ignoriert.
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey or event is InputEventMouseButton or event is InputEventMouseMotion:
|
||||
_active_device = "Tastatur/Maus"
|
||||
elif event is InputEventJoypadButton:
|
||||
_active_device = _describe_joypad(event.device)
|
||||
elif event is InputEventJoypadMotion and absf(event.axis_value) > JOY_MOTION_THRESHOLD:
|
||||
_active_device = _describe_joypad(event.device)
|
||||
|
||||
|
||||
## Baut den Anzeigetext jedes Frame neu auf.
|
||||
func _process(_delta: float) -> void:
|
||||
var lines := PackedStringArray()
|
||||
lines.append("FPS: %d" % Engine.get_frames_per_second())
|
||||
lines.append("Eingabegerät: %s" % _active_device)
|
||||
if is_instance_valid(_player):
|
||||
var pos := _player.global_position
|
||||
lines.append("Position: (%.1f, %.1f, %.1f)" % [pos.x, pos.y, pos.z])
|
||||
if _player.has_method("get_camera_zoom"):
|
||||
lines.append("Kamera-Zoom: %.1f m" % _player.get_camera_zoom())
|
||||
_info_label.text = "\n".join(lines)
|
||||
|
||||
|
||||
## Ordnet einen Controller anhand seines Gerätenamens der PS5- oder
|
||||
## Xbox-Familie zu.
|
||||
func _describe_joypad(device: int) -> String:
|
||||
var joy_name := Input.get_joy_name(device).to_lower()
|
||||
for hint in PLAYSTATION_NAME_HINTS:
|
||||
if joy_name.contains(hint):
|
||||
return "PS5-Controller"
|
||||
return "Xbox-Controller"
|
||||
Loading…
Add table
Add a link
Reference in a new issue