From f51914161e1d1c8a6c12eced2a3012614907f37f Mon Sep 17 00:00:00 2001 From: KingGurke Date: Mon, 2 Oct 2023 11:43:44 +0200 Subject: [PATCH 1/2] implemented level select, options menu, different audio buses & sliders --- default_bus_layout.tres | 15 ++ src/game/{ => levels}/level.gd | 0 src/game/{level1.tscn => levels/level_1.tscn} | 87 ++++++--- src/game/player.tscn | 7 +- src/game/player_controller.gd | 2 +- src/{game => gui/hud}/hud.tscn | 4 +- src/{game => gui/hud}/hud_controller.gd | 0 src/gui/menu/level.tscn | 12 ++ src/gui/menu/main.gd | 19 +- src/gui/menu/main.tscn | 176 +++++++++++++++++- src/gui/menu/options.gd | 11 +- src/gui/menu/options.tscn | 132 ++++++++++++- src/gui/menu/volume_slider.gd | 14 ++ src/gui/menu_theme.tres | 52 ++++++ 14 files changed, 485 insertions(+), 46 deletions(-) create mode 100644 default_bus_layout.tres rename src/game/{ => levels}/level.gd (100%) rename src/game/{level1.tscn => levels/level_1.tscn} (52%) rename src/{game => gui/hud}/hud.tscn (90%) rename src/{game => gui/hud}/hud_controller.gd (100%) create mode 100644 src/gui/menu/level.tscn create mode 100644 src/gui/menu/volume_slider.gd create mode 100644 src/gui/menu_theme.tres diff --git a/default_bus_layout.tres b/default_bus_layout.tres new file mode 100644 index 0000000..14246c5 --- /dev/null +++ b/default_bus_layout.tres @@ -0,0 +1,15 @@ +[gd_resource type="AudioBusLayout" format=3 uid="uid://c5151ugetnkpy"] + +[resource] +bus/1/name = &"Music" +bus/1/solo = false +bus/1/mute = false +bus/1/bypass_fx = false +bus/1/volume_db = 0.0 +bus/1/send = &"Master" +bus/2/name = &"Sfx" +bus/2/solo = false +bus/2/mute = false +bus/2/bypass_fx = false +bus/2/volume_db = 0.0 +bus/2/send = &"Master" diff --git a/src/game/level.gd b/src/game/levels/level.gd similarity index 100% rename from src/game/level.gd rename to src/game/levels/level.gd diff --git a/src/game/level1.tscn b/src/game/levels/level_1.tscn similarity index 52% rename from src/game/level1.tscn rename to src/game/levels/level_1.tscn index 20ed01d..b5df79e 100644 --- a/src/game/level1.tscn +++ b/src/game/levels/level_1.tscn @@ -1,13 +1,13 @@ [gd_scene load_steps=10 format=3 uid="uid://c77xk0mywwt5f"] -[ext_resource type="Script" path="res://src/game/level.gd" id="1_hv75i"] -[ext_resource type="PackedScene" uid="uid://ckau5s2tsb3oc" path="res://src/game/player.tscn" id="2_5nf51"] -[ext_resource type="Texture2D" uid="uid://dio3rrptd6w7c" path="res://assets/bg2.png" id="2_bk3ik"] -[ext_resource type="PackedScene" uid="uid://cdlbh3smpgg42" path="res://src/game/hud.tscn" id="2_w64nx"] -[ext_resource type="Texture2D" uid="uid://ds0un04pocx6i" path="res://assets/track90.png" id="3_jtw40"] -[ext_resource type="Texture2D" uid="uid://dmcrms0qu0mtt" path="res://assets/finish2.png" id="4_rxurh"] -[ext_resource type="Texture2D" uid="uid://bq151lkkfdlf4" path="res://assets/sign.png" id="7_g24mp"] -[ext_resource type="AudioStream" uid="uid://dh5jxxwim7ra8" path="res://assets/sounds/music/death_by_waveshaper.wav" id="8_ppkte"] +[ext_resource type="Script" path="res://src/game/levels/level.gd" id="1_s3rsn"] +[ext_resource type="Texture2D" uid="uid://dio3rrptd6w7c" path="res://assets/bg2.png" id="2_57sr6"] +[ext_resource type="Texture2D" uid="uid://ds0un04pocx6i" path="res://assets/track90.png" id="3_en5wc"] +[ext_resource type="Texture2D" uid="uid://dmcrms0qu0mtt" path="res://assets/finish2.png" id="4_qeube"] +[ext_resource type="PackedScene" uid="uid://ckau5s2tsb3oc" path="res://src/game/player.tscn" id="5_2n8nj"] +[ext_resource type="PackedScene" uid="uid://cdlbh3smpgg42" path="res://src/gui/hud/hud.tscn" id="6_r1i0q"] +[ext_resource type="Texture2D" uid="uid://bq151lkkfdlf4" path="res://assets/sign.png" id="7_xmahe"] +[ext_resource type="AudioStream" uid="uid://dh5jxxwim7ra8" path="res://assets/sounds/music/death_by_waveshaper.wav" id="8_qlkhp"] [sub_resource type="Curve2D" id="Curve2D_ll8bj"] _data = { @@ -16,7 +16,7 @@ _data = { point_count = 7 [node name="level1" type="Node2D" node_paths=PackedStringArray("path", "line", "player", "finish")] -script = ExtResource("1_hv75i") +script = ExtResource("1_s3rsn") starting_width = 400.0 shrink_factor = 5.0 path = NodePath("TrackPath") @@ -31,7 +31,7 @@ offset_top = -3355.0 offset_right = 19845.0 offset_bottom = 12825.0 scale = Vector2(0.5, 0.5) -texture = ExtResource("2_bk3ik") +texture = ExtResource("2_57sr6") stretch_mode = 1 [node name="TrackPath" type="Path2D" parent="."] @@ -40,47 +40,82 @@ curve = SubResource("Curve2D_ll8bj") [node name="TrackLine" type="Line2D" parent="."] self_modulate = Color(0.164706, 0.658824, 0.858824, 1) texture_repeat = 2 -texture = ExtResource("3_jtw40") +texture = ExtResource("3_en5wc") texture_mode = 2 begin_cap_mode = 2 [node name="FinishLine" type="Line2D" parent="."] texture_repeat = 2 width = 40.0 -texture = ExtResource("4_rxurh") +texture = ExtResource("4_qeube") texture_mode = 1 begin_cap_mode = 2 end_cap_mode = 2 round_precision = 32 antialiased = true -[node name="player" parent="." instance=ExtResource("2_5nf51")] +[node name="player" parent="." instance=ExtResource("5_2n8nj")] position = Vector2(27, -55) brake_strength = 800.0 [node name="CanvasLayer" type="CanvasLayer" parent="."] -[node name="hud" parent="CanvasLayer" instance=ExtResource("2_w64nx")] +[node name="hud" parent="CanvasLayer" instance=ExtResource("6_r1i0q")] size_flags_horizontal = 3 -[node name="curveSign" type="PointLight2D" parent="."] -position = Vector2(-1914, -560) -scale = Vector2(0.1, 0.1) -color = Color(1, 0.0627451, 0.694118, 1) -energy = 20.0 -texture = ExtResource("7_g24mp") +[node name="Node2D" type="Node2D" parent="."] -[node name="curveSign2" type="PointLight2D" parent="."] -position = Vector2(-1997, -491) -scale = Vector2(0.1, 0.1) -color = Color(1, 0.0627451, 0.694118, 1) +[node name="curveSign3" type="PointLight2D" parent="Node2D"] +position = Vector2(-1720, 2263) +rotation = -1.182 +scale = Vector2(0.3, 0.3) +color = Color(0.690196, 0.545098, 0.0509804, 1) energy = 20.0 -texture = ExtResource("7_g24mp") +texture = ExtResource("7_xmahe") + +[node name="curveSign" type="PointLight2D" parent="Node2D"] +position = Vector2(-2040, 2122) +rotation = -1.27745 +scale = Vector2(0.3, 0.3) +color = Color(0.690196, 0.545098, 0.0509804, 1) +energy = 20.0 +texture = ExtResource("7_xmahe") + +[node name="curveSign2" type="PointLight2D" parent="Node2D"] +position = Vector2(-2337, -124) +scale = Vector2(0.3, 0.3) +color = Color(0.933333, 0, 0.0235294, 1) +energy = 20.0 +texture = ExtResource("7_xmahe") + +[node name="curveSign4" type="PointLight2D" parent="Node2D"] +position = Vector2(-2447, 113) +scale = Vector2(0.3, 0.3) +color = Color(0.933333, 0, 0.0235294, 1) +energy = 20.0 +texture = ExtResource("7_xmahe") + +[node name="curveSign5" type="PointLight2D" parent="Node2D"] +position = Vector2(2664, -97.0001) +rotation = 1.74374 +scale = Vector2(0.3, 0.3) +color = Color(0.690196, 0.545098, 0.0509804, 1) +energy = 20.0 +texture = ExtResource("7_xmahe") + +[node name="curveSign6" type="PointLight2D" parent="Node2D"] +position = Vector2(2899, 56) +rotation = 2.04177 +scale = Vector2(0.3, 0.3) +color = Color(0.690196, 0.545098, 0.0509804, 1) +energy = 20.0 +texture = ExtResource("7_xmahe") [node name="level_music" type="AudioStreamPlayer" parent="."] -stream = ExtResource("8_ppkte") +stream = ExtResource("8_qlkhp") volume_db = -29.953 autoplay = true +bus = &"Music" [connection signal="distance_changed" from="." to="CanvasLayer/hud" method="_on_level_distance_changed"] [connection signal="speed_changed" from="player" to="CanvasLayer/hud" method="_on_player_speed_changed"] diff --git a/src/game/player.tscn b/src/game/player.tscn index f4c7e26..6f77f74 100644 --- a/src/game/player.tscn +++ b/src/game/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://ckau5s2tsb3oc"] +[gd_scene load_steps=9 format=3 uid="uid://ckau5s2tsb3oc"] [ext_resource type="Script" path="res://src/game/player_controller.gd" id="1_g4ij8"] [ext_resource type="Texture2D" uid="uid://bx4nammvn7hea" path="res://assets/vehicle2.png" id="2_ifw0w"] @@ -55,13 +55,16 @@ rotation_smoothing_speed = 10.0 [node name="engine_sounds" type="AudioStreamPlayer" parent="."] stream = ExtResource("4_4ajo8") -volume_db = -40.467 +volume_db = -30.204 autoplay = true +bus = &"Sfx" [node name="damage_sounds" type="AudioStreamPlayer" parent="."] stream = ExtResource("5_rvolc") volume_db = -25.297 +bus = &"Sfx" [node name="death_sound" type="AudioStreamPlayer" parent="."] stream = ExtResource("6_i0vg5") volume_db = -25.297 +bus = &"Sfx" diff --git a/src/game/player_controller.gd b/src/game/player_controller.gd index a362dbb..98c65b5 100644 --- a/src/game/player_controller.gd +++ b/src/game/player_controller.gd @@ -44,7 +44,7 @@ func _process(delta): if !dead: var acc_d = acc * delta - var rev_d = rev * delta +# var rev_d = rev * delta var turn_d = turn_speed * delta var brake_d = brake_strength * delta var turn_factor = 1 diff --git a/src/game/hud.tscn b/src/gui/hud/hud.tscn similarity index 90% rename from src/game/hud.tscn rename to src/gui/hud/hud.tscn index a4cd584..9b248db 100644 --- a/src/game/hud.tscn +++ b/src/gui/hud/hud.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://cdlbh3smpgg42"] -[ext_resource type="Script" path="res://src/game/hud_controller.gd" id="1_ckegs"] +[ext_resource type="Script" path="res://src/gui/hud/hud_controller.gd" id="1_3pkgo"] [sub_resource type="LabelSettings" id="LabelSettings_pv71o"] font_size = 40 @@ -15,7 +15,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_ckegs") +script = ExtResource("1_3pkgo") speed = NodePath("Speedometer") distance = NodePath("Distancemeter") diff --git a/src/game/hud_controller.gd b/src/gui/hud/hud_controller.gd similarity index 100% rename from src/game/hud_controller.gd rename to src/gui/hud/hud_controller.gd diff --git a/src/gui/menu/level.tscn b/src/gui/menu/level.tscn new file mode 100644 index 0000000..6ddeeab --- /dev/null +++ b/src/gui/menu/level.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=3 uid="uid://dyo5dblkfivwn"] + +[ext_resource type="Theme" uid="uid://dpktnl3r5wul1" path="res://src/gui/menu_theme.tres" id="1_62uke"] + +[node name="level" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_62uke") diff --git a/src/gui/menu/main.gd b/src/gui/menu/main.gd index 8672252..15a5ec1 100644 --- a/src/gui/menu/main.gd +++ b/src/gui/menu/main.gd @@ -1,5 +1,8 @@ extends Control +@export var main_menu: Control +@export var level_select: Control + # Called when the node enters the scene tree for the first time. func _ready(): @@ -12,12 +15,24 @@ func _process(delta): func _on_start_button_pressed(): - get_tree().change_scene("res://game/main.tscn") +# get_tree().change_scene("res://game/main.tscn") + main_menu.hide() + level_select.show() func _on_options_button_pressed(): - var options = load("res://menu/options.tscn").instance() + var options = load("res://src/gui/menu/options.tscn").instantiate() get_tree().current_scene.add_child((options)) func _on_quit_button_pressed(): get_tree().quit() + +func _on_back_button_pressed(): + level_select.hide() + main_menu.show() + +func _on_level_button_pressed(level:int): + load_level("res://src/game/levels/level_%s.tscn" % level) + +func load_level(path: String): + get_tree().change_scene_to_file(path) diff --git a/src/gui/menu/main.tscn b/src/gui/menu/main.tscn index d918948..5c7e38b 100644 --- a/src/gui/menu/main.tscn +++ b/src/gui/menu/main.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=6 format=3 uid="uid://bgtkxeh3lciik"] +[gd_scene load_steps=8 format=3 uid="uid://bgtkxeh3lciik"] [ext_resource type="Script" path="res://src/gui/menu/main.gd" id="1_p5r7q"] +[ext_resource type="AudioStream" uid="uid://dh5jxxwim7ra8" path="res://assets/sounds/music/death_by_waveshaper.wav" id="2_yc480"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2u7je"] bg_color = Color(1, 1, 1, 1) @@ -35,25 +36,37 @@ corner_radius_top_right = 5 corner_radius_bottom_right = 5 corner_radius_bottom_left = 5 +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5it3g"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 10 +corner_radius_top_right = 10 +corner_radius_bottom_right = 10 +corner_radius_bottom_left = 10 + [sub_resource type="Theme" id="Theme_67fiq"] Button/colors/font_color = Color(0, 0, 0, 1) Button/colors/font_focus_color = Color(0, 0, 0, 1) Button/colors/font_hover_color = Color(0, 0, 0, 1) -Button/colors/font_hover_pressed_color = Color(0, 0, 0, 1) +Button/colors/font_hover_pressed_color = Color(1, 1, 1, 1) Button/colors/font_pressed_color = Color(1, 1, 1, 1) Button/styles/hover = SubResource("StyleBoxFlat_2u7je") Button/styles/normal = SubResource("StyleBoxFlat_uo2yv") Button/styles/pressed = SubResource("StyleBoxFlat_sjhib") +Panel/styles/panel = SubResource("StyleBoxFlat_5it3g") -[node name="Menu" type="Control"] +[node name="Menu" type="Control" node_paths=PackedStringArray("main_menu", "level_select")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 +offset_top = 1.0 +offset_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 theme = SubResource("Theme_67fiq") script = ExtResource("1_p5r7q") +main_menu = NodePath("VBoxContainer") +level_select = NodePath("LevelSelect") [node name="VBoxContainer" type="VBoxContainer" parent="."] layout_mode = 1 @@ -86,6 +99,163 @@ layout_mode = 2 focus_neighbor_bottom = NodePath("../StartButton") text = "Quit" +[node name="LevelSelect" type="Panel" parent="."] +visible = false +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -131.0 +offset_top = -231.0 +offset_right = 132.0 +offset_bottom = 169.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="LevelSelect"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -86.5 +offset_top = -65.0 +offset_right = 85.5 +offset_bottom = 127.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer2" type="VBoxContainer" parent="LevelSelect/VBoxContainer"] +layout_mode = 2 + +[node name="Row1" type="BoxContainer" parent="LevelSelect/VBoxContainer/VBoxContainer2"] +layout_mode = 2 + +[node name="1" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row1"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "1" + +[node name="2" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row1"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "2" + +[node name="3" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row1"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "3" + +[node name="4" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row1"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "4" + +[node name="Row2" type="BoxContainer" parent="LevelSelect/VBoxContainer/VBoxContainer2"] +layout_mode = 2 + +[node name="5" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row2"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "5" + +[node name="6" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row2"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "6" + +[node name="7" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row2"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "7" + +[node name="8" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row2"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "8" + +[node name="Row3" type="BoxContainer" parent="LevelSelect/VBoxContainer/VBoxContainer2"] +layout_mode = 2 + +[node name="9" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row3"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "9" + +[node name="10" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row3"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "10" + +[node name="11" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row3"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "11" + +[node name="12" type="Button" parent="LevelSelect/VBoxContainer/VBoxContainer2/Row3"] +custom_minimum_size = Vector2(40, 40) +layout_mode = 2 +size_flags_horizontal = 4 +text = "12" + +[node name="MarginContainer" type="MarginContainer" parent="LevelSelect/VBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_top = 20 + +[node name="BackButton" type="Button" parent="LevelSelect/VBoxContainer/MarginContainer"] +custom_minimum_size = Vector2(120, 40) +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 +focus_neighbor_bottom = NodePath("../StartButton") +text = "Back" + +[node name="Label" type="Label" parent="LevelSelect"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -52.0 +offset_top = 24.0 +offset_right = 52.0 +offset_bottom = 50.0 +grow_horizontal = 2 +text = "LEVEL SELECT" +horizontal_alignment = 1 + +[node name="MenuMusic" type="AudioStreamPlayer" parent="."] +stream = ExtResource("2_yc480") +volume_db = -29.953 +autoplay = true +bus = &"Music" + [connection signal="pressed" from="VBoxContainer/StartButton" to="." method="_on_start_button_pressed"] [connection signal="pressed" from="VBoxContainer/OptionsButton" to="." method="_on_options_button_pressed"] [connection signal="pressed" from="VBoxContainer/QuitButton" to="." method="_on_quit_button_pressed"] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row1/1" to="." method="_on_level_button_pressed" binds= [1]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row1/2" to="." method="_on_level_button_pressed" binds= [2]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row1/3" to="." method="_on_level_button_pressed" binds= [3]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row1/4" to="." method="_on_level_button_pressed" binds= [4]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row2/5" to="." method="_on_level_button_pressed" binds= [5]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row2/6" to="." method="_on_level_button_pressed" binds= [6]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row2/7" to="." method="_on_level_button_pressed" binds= [7]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row2/8" to="." method="_on_level_button_pressed" binds= [8]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row3/9" to="." method="_on_level_button_pressed" binds= [9]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row3/10" to="." method="_on_level_button_pressed" binds= [10]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row3/11" to="." method="_on_level_button_pressed" binds= [11]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row3/12" to="." method="_on_level_button_pressed" binds= [12]] +[connection signal="pressed" from="LevelSelect/VBoxContainer/MarginContainer/BackButton" to="." method="_on_back_button_pressed"] diff --git a/src/gui/menu/options.gd b/src/gui/menu/options.gd index a1bbfe7..bf87ee8 100644 --- a/src/gui/menu/options.gd +++ b/src/gui/menu/options.gd @@ -1,11 +1,4 @@ extends Control - -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass +func _on_back_button_pressed(): + queue_free() diff --git a/src/gui/menu/options.tscn b/src/gui/menu/options.tscn index d5ca166..b22f5fe 100644 --- a/src/gui/menu/options.tscn +++ b/src/gui/menu/options.tscn @@ -1,6 +1,8 @@ -[gd_scene load_steps=2 format=3 uid="uid://fqg6y7xp34u0"] +[gd_scene load_steps=4 format=3 uid="uid://fqg6y7xp34u0"] [ext_resource type="Script" path="res://src/gui/menu/options.gd" id="1_0813x"] +[ext_resource type="Theme" uid="uid://dpktnl3r5wul1" path="res://src/gui/menu_theme.tres" id="1_stpo1"] +[ext_resource type="Script" path="res://src/gui/menu/volume_slider.gd" id="3_2vqm2"] [node name="options" type="Control"] layout_mode = 3 @@ -9,4 +11,132 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +theme = ExtResource("1_stpo1") script = ExtResource("1_0813x") + +[node name="Background" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -131.0 +offset_top = -231.0 +offset_right = 132.0 +offset_bottom = 169.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Label" type="Label" parent="Background"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -52.0 +offset_top = 24.0 +offset_right = 52.0 +offset_bottom = 50.0 +grow_horizontal = 2 +text = "OPTIONS" +horizontal_alignment = 1 + +[node name="VBoxContainer" type="VBoxContainer" parent="Background"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -102.0 +offset_top = -84.0 +offset_right = 102.0 +offset_bottom = 120.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Label" type="Label" parent="Background/VBoxContainer"] +layout_mode = 2 +text = "AUDIO" +horizontal_alignment = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="Background/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="Background/VBoxContainer/HBoxContainer"] +custom_minimum_size = Vector2(65, 0) +layout_mode = 2 +text = "MASTER" + +[node name="MarginContainer" type="MarginContainer" parent="Background/VBoxContainer/HBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_top = 3 + +[node name="HSlider" type="HSlider" parent="Background/VBoxContainer/HBoxContainer/MarginContainer"] +custom_minimum_size = Vector2(125, 0) +layout_mode = 2 +max_value = 1.0 +step = 0.001 +script = ExtResource("3_2vqm2") +bus_name = "Master" + +[node name="HBoxContainer2" type="HBoxContainer" parent="Background/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="Background/VBoxContainer/HBoxContainer2"] +custom_minimum_size = Vector2(65, 0) +layout_mode = 2 +text = "MUSIC" + +[node name="MarginContainer" type="MarginContainer" parent="Background/VBoxContainer/HBoxContainer2"] +layout_mode = 2 +theme_override_constants/margin_top = 3 + +[node name="HSlider" type="HSlider" parent="Background/VBoxContainer/HBoxContainer2/MarginContainer"] +custom_minimum_size = Vector2(125, 0) +layout_mode = 2 +max_value = 1.0 +step = 0.001 +script = ExtResource("3_2vqm2") +bus_name = "Music" + +[node name="HBoxContainer3" type="HBoxContainer" parent="Background/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="Background/VBoxContainer/HBoxContainer3"] +custom_minimum_size = Vector2(65, 0) +layout_mode = 2 +text = "SFX" + +[node name="MarginContainer" type="MarginContainer" parent="Background/VBoxContainer/HBoxContainer3"] +layout_mode = 2 +theme_override_constants/margin_top = 3 + +[node name="HSlider" type="HSlider" parent="Background/VBoxContainer/HBoxContainer3/MarginContainer"] +custom_minimum_size = Vector2(125, 0) +layout_mode = 2 +max_value = 1.0 +step = 0.001 +script = ExtResource("3_2vqm2") +bus_name = "Sfx" + +[node name="BackButton" type="Button" parent="Background"] +custom_minimum_size = Vector2(120, 40) +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -60.0 +offset_top = -64.0 +offset_right = 60.0 +offset_bottom = -24.0 +grow_horizontal = 2 +grow_vertical = 0 +size_flags_horizontal = 4 +size_flags_vertical = 8 +focus_neighbor_bottom = NodePath("../StartButton") +text = "Back" + +[connection signal="pressed" from="Background/BackButton" to="." method="_on_back_button_pressed"] diff --git a/src/gui/menu/volume_slider.gd b/src/gui/menu/volume_slider.gd new file mode 100644 index 0000000..ddf117c --- /dev/null +++ b/src/gui/menu/volume_slider.gd @@ -0,0 +1,14 @@ +extends HSlider + +@export +var bus_name: String + +var bus_index: int + +func _ready() -> void: + bus_index = AudioServer.get_bus_index(bus_name) + value_changed.connect(_on_value_changed) + value = db_to_linear(AudioServer.get_bus_volume_db(bus_index)) + +func _on_value_changed(value: float) -> void: + AudioServer.set_bus_volume_db(bus_index, linear_to_db(value)) diff --git a/src/gui/menu_theme.tres b/src/gui/menu_theme.tres new file mode 100644 index 0000000..e1cb7fe --- /dev/null +++ b/src/gui/menu_theme.tres @@ -0,0 +1,52 @@ +[gd_resource type="Theme" load_steps=5 format=3 uid="uid://dpktnl3r5wul1"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2u7je"] +bg_color = Color(1, 1, 1, 1) +border_width_left = 2 +border_width_top = 2 +border_width_right = 2 +border_width_bottom = 2 +border_color = Color(0, 0, 0, 1) +border_blend = true +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_uo2yv"] +bg_color = Color(1, 1, 1, 1) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_sjhib"] +bg_color = Color(0, 0, 0, 1) +border_width_left = 2 +border_width_top = 2 +border_width_right = 2 +border_width_bottom = 2 +border_color = Color(1, 1, 1, 1) +border_blend = true +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5it3g"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 10 +corner_radius_top_right = 10 +corner_radius_bottom_right = 10 +corner_radius_bottom_left = 10 + +[resource] +Button/colors/font_color = Color(0, 0, 0, 1) +Button/colors/font_focus_color = Color(0, 0, 0, 1) +Button/colors/font_hover_color = Color(0, 0, 0, 1) +Button/colors/font_hover_pressed_color = Color(1, 1, 1, 1) +Button/colors/font_pressed_color = Color(1, 1, 1, 1) +Button/styles/hover = SubResource("StyleBoxFlat_2u7je") +Button/styles/normal = SubResource("StyleBoxFlat_uo2yv") +Button/styles/pressed = SubResource("StyleBoxFlat_sjhib") +Panel/styles/panel = SubResource("StyleBoxFlat_5it3g") From b0475b16978eecef01baac9621576c3c08bab27b Mon Sep 17 00:00:00 2001 From: KingGurke Date: Mon, 2 Oct 2023 16:35:08 +0200 Subject: [PATCH 2/2] added pause menu in level and ability to load levels from main menu --- project.godot | 5 +++ src/game/levels/level.gd | 17 ++++++++ src/game/levels/level_1.tscn | 24 +++++++++- src/gui/menu/level.gd | 13 ++++++ src/gui/menu/level.tscn | 73 ++++++++++++++++++++++++++++++- src/gui/menu/main.gd | 5 ++- src/gui/menu/main.tscn | 85 +++++++++++++++++++++++------------- src/gui/menu/options.gd | 1 + src/gui/menu/options.tscn | 4 +- 9 files changed, 190 insertions(+), 37 deletions(-) create mode 100644 src/gui/menu/level.gd diff --git a/project.godot b/project.godot index f30f100..316c5fc 100644 --- a/project.godot +++ b/project.godot @@ -61,3 +61,8 @@ reverse={ , 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":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null) ] } +pause={ +"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":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} diff --git a/src/game/levels/level.gd b/src/game/levels/level.gd index fc8bdad..ad7e092 100644 --- a/src/game/levels/level.gd +++ b/src/game/levels/level.gd @@ -21,6 +21,8 @@ extends Node2D ## reference to the line node used to draw the finish line @export var finish: Line2D +@export var menu: Control + signal distance_changed(new_distance) #variables @@ -31,6 +33,7 @@ var lap_distance = 0. var start var finish_right var finish_left +var paused = false # Called when the node enters the scene tree for the first time. func _ready(): @@ -53,6 +56,10 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): + + if Input.is_action_just_pressed("pause") && running: + pause() + if (running): # shrinking the track width -= shrink_factor * delta @@ -86,6 +93,16 @@ func _process(delta): distance_changed.emit(get_total_distance()) # print_debug("player distance driven: ", get_total_distance(), " distance since last check: ", off_diff) +func pause(): + if !paused: + Engine.time_scale = 0 + menu.show() + paused = true + else: + Engine.time_scale = 1 + menu.hide() + paused = false + func update_line(): line.set_width(width) diff --git a/src/game/levels/level_1.tscn b/src/game/levels/level_1.tscn index b5df79e..ae3c76a 100644 --- a/src/game/levels/level_1.tscn +++ b/src/game/levels/level_1.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=10 format=3 uid="uid://c77xk0mywwt5f"] +[gd_scene load_steps=11 format=3 uid="uid://c77xk0mywwt5f"] [ext_resource type="Script" path="res://src/game/levels/level.gd" id="1_s3rsn"] [ext_resource type="Texture2D" uid="uid://dio3rrptd6w7c" path="res://assets/bg2.png" id="2_57sr6"] [ext_resource type="Texture2D" uid="uid://ds0un04pocx6i" path="res://assets/track90.png" id="3_en5wc"] [ext_resource type="Texture2D" uid="uid://dmcrms0qu0mtt" path="res://assets/finish2.png" id="4_qeube"] [ext_resource type="PackedScene" uid="uid://ckau5s2tsb3oc" path="res://src/game/player.tscn" id="5_2n8nj"] +[ext_resource type="PackedScene" uid="uid://dyo5dblkfivwn" path="res://src/gui/menu/level.tscn" id="6_hs25h"] [ext_resource type="PackedScene" uid="uid://cdlbh3smpgg42" path="res://src/gui/hud/hud.tscn" id="6_r1i0q"] [ext_resource type="Texture2D" uid="uid://bq151lkkfdlf4" path="res://assets/sign.png" id="7_xmahe"] [ext_resource type="AudioStream" uid="uid://dh5jxxwim7ra8" path="res://assets/sounds/music/death_by_waveshaper.wav" id="8_qlkhp"] @@ -15,7 +16,7 @@ _data = { } point_count = 7 -[node name="level1" type="Node2D" node_paths=PackedStringArray("path", "line", "player", "finish")] +[node name="level1" type="Node2D" node_paths=PackedStringArray("path", "line", "player", "finish", "menu")] script = ExtResource("1_s3rsn") starting_width = 400.0 shrink_factor = 5.0 @@ -23,6 +24,7 @@ path = NodePath("TrackPath") line = NodePath("TrackLine") player = NodePath("player") finish = NodePath("FinishLine") +menu = NodePath("CanvasLayer/menu_box/level") [node name="TextureRect" type="TextureRect" parent="."] self_modulate = Color(0.827451, 0.521569, 0.313726, 1) @@ -63,6 +65,24 @@ brake_strength = 800.0 [node name="hud" parent="CanvasLayer" instance=ExtResource("6_r1i0q")] size_flags_horizontal = 3 +[node name="menu_box" type="Control" parent="CanvasLayer"] +layout_mode = 3 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -20.0 +offset_right = 20.0 +offset_bottom = 20.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="level" parent="CanvasLayer/menu_box" instance=ExtResource("6_hs25h")] +visible = false +layout_mode = 1 + [node name="Node2D" type="Node2D" parent="."] [node name="curveSign3" type="PointLight2D" parent="Node2D"] diff --git a/src/gui/menu/level.gd b/src/gui/menu/level.gd new file mode 100644 index 0000000..ca3f655 --- /dev/null +++ b/src/gui/menu/level.gd @@ -0,0 +1,13 @@ +extends Control + +func _on_continue_button_pressed(): + get_tree().current_scene.pause() + +func _on_menu_button_pressed(): + get_tree().current_scene.pause() + get_tree().change_scene_to_file("res://src/gui/menu/main.tscn") + +func _on_options_button_pressed(): + var options = load("res://src/gui/menu/options.tscn").instantiate() + get_parent().add_child((options)) + hide() diff --git a/src/gui/menu/level.tscn b/src/gui/menu/level.tscn index 6ddeeab..b51e6c8 100644 --- a/src/gui/menu/level.tscn +++ b/src/gui/menu/level.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=2 format=3 uid="uid://dyo5dblkfivwn"] +[gd_scene load_steps=3 format=3 uid="uid://dyo5dblkfivwn"] [ext_resource type="Theme" uid="uid://dpktnl3r5wul1" path="res://src/gui/menu_theme.tres" id="1_62uke"] +[ext_resource type="Script" path="res://src/gui/menu/level.gd" id="2_6ldjx"] [node name="level" type="Control"] layout_mode = 3 @@ -10,3 +11,73 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 theme = ExtResource("1_62uke") +script = ExtResource("2_6ldjx") + +[node name="Pause" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -131.0 +offset_top = -231.0 +offset_right = 132.0 +offset_bottom = 169.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Label" type="Label" parent="Pause"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -52.0 +offset_top = 24.0 +offset_right = 52.0 +offset_bottom = 50.0 +grow_horizontal = 2 +text = "PAUSED" +horizontal_alignment = 1 + +[node name="VBoxContainer" type="VBoxContainer" parent="Pause"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -59.5 +offset_top = 3.0 +offset_right = 60.5 +offset_bottom = 131.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="ContinueButton" type="Button" parent="Pause/VBoxContainer"] +custom_minimum_size = Vector2(120, 40) +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 +focus_neighbor_bottom = NodePath("../StartButton") +text = "CONTINUE" + +[node name="OptionsButton" type="Button" parent="Pause/VBoxContainer"] +custom_minimum_size = Vector2(120, 40) +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 +focus_neighbor_bottom = NodePath("../StartButton") +text = "OPTIONS" + +[node name="MenuButton" type="Button" parent="Pause/VBoxContainer"] +custom_minimum_size = Vector2(120, 40) +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 +focus_neighbor_bottom = NodePath("../StartButton") +text = "TO MENU" + +[connection signal="pressed" from="Pause/VBoxContainer/ContinueButton" to="." method="_on_continue_button_pressed"] +[connection signal="pressed" from="Pause/VBoxContainer/OptionsButton" to="." method="_on_options_button_pressed"] +[connection signal="pressed" from="Pause/VBoxContainer/MenuButton" to="." method="_on_menu_button_pressed"] diff --git a/src/gui/menu/main.gd b/src/gui/menu/main.gd index 15a5ec1..f5bdd96 100644 --- a/src/gui/menu/main.gd +++ b/src/gui/menu/main.gd @@ -6,7 +6,7 @@ extends Control # Called when the node enters the scene tree for the first time. func _ready(): - $VBoxContainer/StartButton.grab_focus() + $Main/VBoxContainer/StartButton.grab_focus() # Called every frame. 'delta' is the elapsed time since the previous frame. @@ -22,7 +22,8 @@ func _on_start_button_pressed(): func _on_options_button_pressed(): var options = load("res://src/gui/menu/options.tscn").instantiate() - get_tree().current_scene.add_child((options)) + get_parent().add_child((options)) + hide() func _on_quit_button_pressed(): get_tree().quit() diff --git a/src/gui/menu/main.tscn b/src/gui/menu/main.tscn index 5c7e38b..6745e4a 100644 --- a/src/gui/menu/main.tscn +++ b/src/gui/menu/main.tscn @@ -65,39 +65,57 @@ grow_horizontal = 2 grow_vertical = 2 theme = SubResource("Theme_67fiq") script = ExtResource("1_p5r7q") -main_menu = NodePath("VBoxContainer") +main_menu = NodePath("Main") level_select = NodePath("LevelSelect") -[node name="VBoxContainer" type="VBoxContainer" parent="."] +[node name="Main" type="Panel" parent="."] layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -200.0 -offset_top = -44.0 -offset_right = 200.0 -offset_bottom = 156.0 +offset_left = -131.0 +offset_top = -231.0 +offset_right = 132.0 +offset_bottom = 169.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="Main"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -59.5 +offset_top = 3.0 +offset_right = 60.5 +offset_bottom = 131.0 grow_horizontal = 2 grow_vertical = 2 alignment = 1 -[node name="StartButton" type="Button" parent="VBoxContainer"] +[node name="StartButton" type="Button" parent="Main/VBoxContainer"] +custom_minimum_size = Vector2(120, 40) layout_mode = 2 +size_flags_horizontal = 4 focus_neighbor_top = NodePath("../QuitButton") -text = "Start! -" +text = "PLAY" -[node name="OptionsButton" type="Button" parent="VBoxContainer"] +[node name="OptionsButton" type="Button" parent="Main/VBoxContainer"] +custom_minimum_size = Vector2(120, 40) layout_mode = 2 -text = "Options -" +size_flags_horizontal = 4 +text = "OPTIONS" -[node name="QuitButton" type="Button" parent="VBoxContainer"] +[node name="QuitButton" type="Button" parent="Main/VBoxContainer"] +custom_minimum_size = Vector2(120, 40) layout_mode = 2 +size_flags_horizontal = 4 focus_neighbor_bottom = NodePath("../StartButton") -text = "Quit" +text = "QUIT" [node name="LevelSelect" type="Panel" parent="."] visible = false @@ -212,18 +230,6 @@ layout_mode = 2 size_flags_horizontal = 4 text = "12" -[node name="MarginContainer" type="MarginContainer" parent="LevelSelect/VBoxContainer"] -layout_mode = 2 -theme_override_constants/margin_top = 20 - -[node name="BackButton" type="Button" parent="LevelSelect/VBoxContainer/MarginContainer"] -custom_minimum_size = Vector2(120, 40) -layout_mode = 2 -size_flags_horizontal = 4 -size_flags_vertical = 8 -focus_neighbor_bottom = NodePath("../StartButton") -text = "Back" - [node name="Label" type="Label" parent="LevelSelect"] layout_mode = 1 anchors_preset = 5 @@ -237,15 +243,34 @@ grow_horizontal = 2 text = "LEVEL SELECT" horizontal_alignment = 1 +[node name="BackButton" type="Button" parent="LevelSelect"] +custom_minimum_size = Vector2(120, 40) +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -60.0 +offset_top = -109.0 +offset_right = 60.0 +offset_bottom = -69.0 +grow_horizontal = 2 +grow_vertical = 0 +size_flags_horizontal = 4 +size_flags_vertical = 8 +focus_neighbor_bottom = NodePath("../StartButton") +text = "BACK" + [node name="MenuMusic" type="AudioStreamPlayer" parent="."] stream = ExtResource("2_yc480") volume_db = -29.953 autoplay = true bus = &"Music" -[connection signal="pressed" from="VBoxContainer/StartButton" to="." method="_on_start_button_pressed"] -[connection signal="pressed" from="VBoxContainer/OptionsButton" to="." method="_on_options_button_pressed"] -[connection signal="pressed" from="VBoxContainer/QuitButton" to="." method="_on_quit_button_pressed"] +[connection signal="pressed" from="Main/VBoxContainer/StartButton" to="." method="_on_start_button_pressed"] +[connection signal="pressed" from="Main/VBoxContainer/OptionsButton" to="." method="_on_options_button_pressed"] +[connection signal="pressed" from="Main/VBoxContainer/QuitButton" to="." method="_on_quit_button_pressed"] [connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row1/1" to="." method="_on_level_button_pressed" binds= [1]] [connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row1/2" to="." method="_on_level_button_pressed" binds= [2]] [connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row1/3" to="." method="_on_level_button_pressed" binds= [3]] @@ -258,4 +283,4 @@ bus = &"Music" [connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row3/10" to="." method="_on_level_button_pressed" binds= [10]] [connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row3/11" to="." method="_on_level_button_pressed" binds= [11]] [connection signal="pressed" from="LevelSelect/VBoxContainer/VBoxContainer2/Row3/12" to="." method="_on_level_button_pressed" binds= [12]] -[connection signal="pressed" from="LevelSelect/VBoxContainer/MarginContainer/BackButton" to="." method="_on_back_button_pressed"] +[connection signal="pressed" from="LevelSelect/BackButton" to="." method="_on_back_button_pressed"] diff --git a/src/gui/menu/options.gd b/src/gui/menu/options.gd index bf87ee8..4aa028d 100644 --- a/src/gui/menu/options.gd +++ b/src/gui/menu/options.gd @@ -1,4 +1,5 @@ extends Control func _on_back_button_pressed(): + get_parent().get_child(0).show() queue_free() diff --git a/src/gui/menu/options.tscn b/src/gui/menu/options.tscn index b22f5fe..7e16c34 100644 --- a/src/gui/menu/options.tscn +++ b/src/gui/menu/options.tscn @@ -129,9 +129,9 @@ anchor_top = 1.0 anchor_right = 0.5 anchor_bottom = 1.0 offset_left = -60.0 -offset_top = -64.0 +offset_top = -109.0 offset_right = 60.0 -offset_bottom = -24.0 +offset_bottom = -69.0 grow_horizontal = 2 grow_vertical = 0 size_flags_horizontal = 4