From 032832a6b0a7495fa1f478cb5a91c67a0227d53f Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Fri, 15 Mar 2024 14:00:31 +0100 Subject: [PATCH] shortcuts --- project.godot | 7 ++++++- scenes/boot_splash/BootSplash.gd | 10 ++++++++++ scenes/boot_splash/BootSplash.tscn | 27 +++++++++++++++++++++++++++ scenes/main_menu/MainMenu.tscn | 16 +++++++++++++++- scenes/main_menu/NewGameButton.gd | 5 ++++- scenes/playground/Playground.gd | 3 ++- 6 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 scenes/boot_splash/BootSplash.gd create mode 100644 scenes/boot_splash/BootSplash.tscn diff --git a/project.godot b/project.godot index 64f6156..fcb1cc1 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="pong" -run/main_scene="res://scenes/main_menu/MainMenu.tscn" +run/main_scene="res://scenes/boot_splash/BootSplash.tscn" config/features=PackedStringArray("4.2", "Forward Plus") config/icon="res://icon.svg" @@ -42,3 +42,8 @@ left_down={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) ] } +confirm={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null) +] +} diff --git a/scenes/boot_splash/BootSplash.gd b/scenes/boot_splash/BootSplash.gd new file mode 100644 index 0000000..d23fc3b --- /dev/null +++ b/scenes/boot_splash/BootSplash.gd @@ -0,0 +1,10 @@ +extends Node2D + + +func _ready(): + await get_tree().create_timer(1.0).timeout # Replace with function body. + get_tree().change_scene_to_file("res://scenes/main_menu/MainMenu.tscn") + + +func _process(delta): + pass diff --git a/scenes/boot_splash/BootSplash.tscn b/scenes/boot_splash/BootSplash.tscn new file mode 100644 index 0000000..d143f33 --- /dev/null +++ b/scenes/boot_splash/BootSplash.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=4 format=3 uid="uid://dsimi4xibt3ig"] + +[ext_resource type="Script" path="res://scenes/boot_splash/BootSplash.gd" id="1_qt4f0"] + +[sub_resource type="SystemFont" id="SystemFont_iaru5"] + +[sub_resource type="Theme" id="Theme_cneuf"] +default_font = SubResource("SystemFont_iaru5") +default_font_size = 120 + +[node name="BootSplash" type="Node2D"] +script = ExtResource("1_qt4f0") + +[node name="TeletypeGames" type="RichTextLabel" parent="."] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = 112.0 +offset_top = 224.0 +offset_right = 1056.0 +offset_bottom = 416.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = SubResource("Theme_cneuf") +text = "Teletype Games" diff --git a/scenes/main_menu/MainMenu.tscn b/scenes/main_menu/MainMenu.tscn index 96c2dbf..2d5d6ef 100644 --- a/scenes/main_menu/MainMenu.tscn +++ b/scenes/main_menu/MainMenu.tscn @@ -1,9 +1,21 @@ -[gd_scene load_steps=4 format=3 uid="uid://c71cjy50eonxj"] +[gd_scene load_steps=8 format=3 uid="uid://c71cjy50eonxj"] [ext_resource type="Theme" uid="uid://bbasvjlc0fdo8" path="res://default_theme.tres" id="1_gow2p"] [ext_resource type="Script" path="res://scenes/main_menu/NewGameButton.gd" id="2_xmp3k"] [ext_resource type="Script" path="res://scenes/main_menu/ExitButton.gd" id="3_r42kx"] +[sub_resource type="InputEventKey" id="InputEventKey_3qeo8"] +keycode = 32 + +[sub_resource type="Shortcut" id="Shortcut_heomt"] +events = [SubResource("InputEventKey_3qeo8")] + +[sub_resource type="InputEventKey" id="InputEventKey_p7j63"] +keycode = 4194305 + +[sub_resource type="Shortcut" id="Shortcut_lofla"] +events = [SubResource("InputEventKey_p7j63")] + [node name="MainMenu" type="Node2D"] [node name="NewGameContainer" type="PanelContainer" parent="."] @@ -17,6 +29,7 @@ layout_mode = 2 custom_minimum_size = Vector2(300, 100) layout_mode = 2 theme = ExtResource("1_gow2p") +shortcut = SubResource("Shortcut_heomt") text = "New Game" script = ExtResource("2_xmp3k") @@ -33,6 +46,7 @@ layout_mode = 2 custom_minimum_size = Vector2(300, 100) layout_mode = 2 theme = ExtResource("1_gow2p") +shortcut = SubResource("Shortcut_lofla") text = "Exit" script = ExtResource("3_r42kx") diff --git a/scenes/main_menu/NewGameButton.gd b/scenes/main_menu/NewGameButton.gd index 63be4c2..63f2d15 100644 --- a/scenes/main_menu/NewGameButton.gd +++ b/scenes/main_menu/NewGameButton.gd @@ -1,4 +1,7 @@ extends Button + func _on_pressed(): - get_tree().change_scene_to_file("res://scenes/playground/Playground.tscn") + get_tree().change_scene_to_file("res://scenes/playground/Playground.tscn") + + diff --git a/scenes/playground/Playground.gd b/scenes/playground/Playground.gd index 16b2224..bd2ec39 100644 --- a/scenes/playground/Playground.gd +++ b/scenes/playground/Playground.gd @@ -31,7 +31,8 @@ func _ready(): func _process(delta): - pass + if Input.is_key_pressed(KEY_ESCAPE): + get_tree().quit() func _on_goal_area_left_body_entered(body):