From 9a97a0cc9e965d5b9de45da8a62e4f299c06fd17 Mon Sep 17 00:00:00 2001 From: TechieDamien Date: Sat, 2 Aug 2025 14:50:37 +0100 Subject: [PATCH] Adds key bindings for (re)starting and exitting --- Scripts/game_over_menu.gd | 7 +++++++ Scripts/main_menu.gd | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Scripts/game_over_menu.gd b/Scripts/game_over_menu.gd index 4467db7..eb1552b 100644 --- a/Scripts/game_over_menu.gd +++ b/Scripts/game_over_menu.gd @@ -18,3 +18,10 @@ func back(): get_tree().change_scene_to_packed(main_menu) GridManager.current_allowed_spawns.clear() GameManager.score = 0 + +func _unhandled_input(event: InputEvent) -> void: + if event is InputEventKey: + if event.is_action_pressed("ui_accept"): + restart() + if event.is_action_pressed("ui_cancel"): + back() diff --git a/Scripts/main_menu.gd b/Scripts/main_menu.gd index a5ca60c..e176ec2 100644 --- a/Scripts/main_menu.gd +++ b/Scripts/main_menu.gd @@ -14,6 +14,13 @@ func _ready() -> void: $Buttons/Quit.visible = false $Buttons/SourceCode.text = "Source Code (Opens in another tab)" +func _unhandled_input(event: InputEvent) -> void: + if event is InputEventKey: + if event.is_action_pressed("ui_accept"): + start_game() + if event.is_action_pressed("ui_cancel") and !OS.has_feature("web"): + quit() + func start_game() -> void: get_tree().change_scene_to_packed(main_scene)