9f65823f2d
Das Startmenü führt zu einer Vitrine, die den gewählten Stil an einer kleinen Szene zeigt: Fels, toter und lebendiger Boden, Lebensmoos, eine Ranke, die Steine in eine erwachende Ruine trägt, eine wachsende Faserpflanze, ein hüpfendes Weidetier und zwei Spielfiguren. Knöpfe, die Tasten 1 bis 3 und F2 wechseln den Stil, Esc führt zurück ins Menü. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
41 lines
1.3 KiB
GDScript
41 lines
1.3 KiB
GDScript
class_name InputSetup
|
|
extends RefCounted
|
|
## Registers the game's input actions in code, so that project.godot holds no
|
|
## serialized input events. Keys are physical positions, so WASD stays in
|
|
## place on German keyboards too.
|
|
|
|
|
|
static func install() -> void:
|
|
_add_keys("move_up", [KEY_W, KEY_UP])
|
|
_add_keys("move_down", [KEY_S, KEY_DOWN])
|
|
_add_keys("move_left", [KEY_A, KEY_LEFT])
|
|
_add_keys("move_right", [KEY_D, KEY_RIGHT])
|
|
_add_keys("save_game", [KEY_F5])
|
|
_add_keys("load_game", [KEY_F9])
|
|
_add_keys("toggle_pause", [KEY_ESCAPE])
|
|
_add_keys("next_style", [KEY_F2])
|
|
_add_keys("back", [KEY_ESCAPE])
|
|
_add_keys("style_1", [KEY_1])
|
|
_add_keys("style_2", [KEY_2])
|
|
_add_keys("style_3", [KEY_3])
|
|
_add_mouse_button("dig", MOUSE_BUTTON_LEFT)
|
|
|
|
|
|
static func _add_keys(action: StringName, keys: Array[Key]) -> void:
|
|
if InputMap.has_action(action):
|
|
return
|
|
InputMap.add_action(action)
|
|
for key in keys:
|
|
var event := InputEventKey.new()
|
|
event.physical_keycode = key
|
|
InputMap.action_add_event(action, event)
|
|
|
|
|
|
static func _add_mouse_button(action: StringName, button: MouseButton) -> void:
|
|
if InputMap.has_action(action):
|
|
return
|
|
InputMap.add_action(action)
|
|
var event := InputEventMouseButton.new()
|
|
event.button_index = button
|
|
InputMap.action_add_event(action, event)
|