diff options
author | Logan <logan@cflip.net> | 2023-01-30 16:49:29 -0700 |
---|---|---|
committer | Logan <logan@cflip.net> | 2023-01-30 16:49:29 -0700 |
commit | 393260b3573e08f0914017ca702843f677bd1546 (patch) | |
tree | 1fc8418f5215776af81d539e860dd5dfec14acdb | |
parent | 9ebeb1c836deb561f53b49f004d95a685dec6880 (diff) |
Added pausemenu and various changes to interface.
-rw-r--r-- | project.godot | 5 | ||||
-rw-r--r-- | scenes/interface.tscn | 153 | ||||
-rw-r--r-- | scenes/pausemenu.tscn | 67 | ||||
-rw-r--r-- | scripts/interface.gd | 10 | ||||
-rw-r--r-- | scripts/pausemenu.gd | 27 |
5 files changed, 250 insertions, 12 deletions
diff --git a/project.godot b/project.godot index fb0c0b3..c608eb4 100644 --- a/project.godot +++ b/project.godot @@ -63,6 +63,11 @@ shoot={ "events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) ] } +escape={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} [physics] diff --git a/scenes/interface.tscn b/scenes/interface.tscn index e36bd9b..169d551 100644 --- a/scenes/interface.tscn +++ b/scenes/interface.tscn @@ -1,8 +1,112 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=7 format=2] -[ext_resource path="res://theme_data/interface_theme.tres" type="Theme" id=1] +[ext_resource path="res://scenes/pausemenu.tscn" type="PackedScene" id=1] [ext_resource path="res://textures/hourglass.png" type="Texture" id=2] [ext_resource path="res://scripts/interface.gd" type="Script" id=3] +[ext_resource path="res://theme_data/interface_theme.tres" type="Theme" id=4] + +[sub_resource type="Animation" id=1] +length = 0.001 +tracks/0/type = "value" +tracks/0/path = NodePath(".:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ false ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("../ChangeLabel:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ false ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("../ChangeLabel:modulate") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 1 ) ] +} +tracks/3/type = "value" +tracks/3/path = NodePath(".:modulate") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 1 ) ] +} + +[sub_resource type="Animation" id=2] +resource_name = "blinking" +length = 4.0 +tracks/0/type = "value" +tracks/0/path = NodePath(".:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 1, +"values": [ true, false ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("../ChangeLabel:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0, 3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 1, +"values": [ true, false ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("../ChangeLabel:modulate") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0, 0.5, 1, 1.5, 2, 2.5, 3 ), +"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1, 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ] +} +tracks/3/type = "value" +tracks/3/path = NodePath(".:modulate") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/keys = { +"times": PoolRealArray( 0, 0.5, 2.5, 3 ), +"transitions": PoolRealArray( 1, 1, 1, 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ] +} [node name="Interface" type="CanvasLayer"] script = ExtResource( 3 ) @@ -18,7 +122,7 @@ margin_top = 104.0 margin_right = 216.0 margin_bottom = 116.0 rect_scale = Vector2( 0.8, 0.8 ) -theme = ExtResource( 1 ) +theme = ExtResource( 4 ) text = "000" align = 2 @@ -27,20 +131,45 @@ margin_top = -2.0 margin_right = 48.0 margin_bottom = 14.0 rect_scale = Vector2( 0.8, 0.8 ) -theme = ExtResource( 1 ) +theme = ExtResource( 4 ) text = "Score:" [node name="Timer" type="Timer" parent="."] -[node name="Control" type="Control" parent="."] +[node name="LoseLabel" type="Label" parent="."] visible = false - -[node name="Label" type="Label" parent="Control"] margin_top = 40.0 margin_right = 214.0 margin_bottom = 80.0 -text = "YOU LOSE. YOU WIN NOTHING. -GOOD DAY SIR!" +theme = ExtResource( 4 ) +text = "YOU RAN OUT OF TIME! +RESTART?" +align = 1 + +[node name="Difficulty" type="Control" parent="."] +margin_top = 40.0 +margin_right = 40.0 +margin_bottom = 80.0 + +[node name="AnimationPlayer" type="AnimationPlayer" parent="Difficulty"] +root_node = NodePath("../MessageLabel") +anims/RESET = SubResource( 1 ) +anims/blinking = SubResource( 2 ) + +[node name="MessageLabel" type="Label" parent="Difficulty"] +visible = false +margin_right = 214.0 +theme = ExtResource( 4 ) +text = "DIFFICULT PHASE CHANGED:" +align = 1 + +[node name="ChangeLabel" type="Label" parent="Difficulty"] +visible = false +margin_top = 14.0 +margin_right = 214.0 +margin_bottom = 30.0 +custom_colors/font_color_shadow = Color( 0.788235, 0.0823529, 0.0823529, 1 ) +text = "TEST" align = 1 [node name="PhaseLabel" type="Label" parent="."] @@ -48,7 +177,11 @@ margin_top = 112.0 margin_right = 88.0 margin_bottom = 128.0 rect_scale = Vector2( 0.5, 0.5 ) -theme = ExtResource( 1 ) +theme = ExtResource( 4 ) text = "Next Phase: " +[node name="PauseMenu" parent="." instance=ExtResource( 1 )] +pause_mode = 2 +visible = false + [connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] diff --git a/scenes/pausemenu.tscn b/scenes/pausemenu.tscn new file mode 100644 index 0000000..ab9fc87 --- /dev/null +++ b/scenes/pausemenu.tscn @@ -0,0 +1,67 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/pausemenu.gd" type="Script" id=1] + +[node name="Menu" type="Control"] +margin_right = 214.0 +margin_bottom = 120.0 +script = ExtResource( 1 ) + +[node name="ColorRect" type="ColorRect" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +color = Color( 0, 0, 0, 0.54902 ) + +[node name="Label" type="Label" parent="."] +anchor_left = 0.5 +anchor_right = 0.5 +margin_left = -24.0 +margin_right = 24.0 +margin_bottom = 16.0 +custom_colors/font_color_shadow = Color( 0.270588, 0.294118, 0.443137, 1 ) +text = "PAUSED" + +[node name="Control" type="Control" parent="."] +margin_right = 428.0 +margin_bottom = 240.0 +rect_scale = Vector2( 0.5, 0.5 ) + +[node name="VBoxContainer" type="VBoxContainer" parent="Control"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -50.0 +margin_top = -76.0 +margin_right = 50.0 +margin_bottom = 76.0 + +[node name="RestartButton" type="Button" parent="Control/VBoxContainer"] +margin_right = 100.0 +margin_bottom = 22.0 +text = "Restart" + +[node name="HelpButton" type="Button" parent="Control/VBoxContainer"] +margin_top = 26.0 +margin_right = 100.0 +margin_bottom = 48.0 +disabled = true +text = "Help" + +[node name="OptionsButton" type="Button" parent="Control/VBoxContainer"] +margin_top = 52.0 +margin_right = 100.0 +margin_bottom = 74.0 +disabled = true +text = "Options" + +[node name="QuitButton" type="Button" parent="Control/VBoxContainer"] +margin_top = 78.0 +margin_right = 100.0 +margin_bottom = 100.0 +text = "Quit" + +[connection signal="pressed" from="Control/VBoxContainer/RestartButton" to="." method="_on_RestartButton_pressed"] +[connection signal="pressed" from="Control/VBoxContainer/HelpButton" to="." method="_on_HelpButton_pressed"] +[connection signal="pressed" from="Control/VBoxContainer/OptionsButton" to="." method="_on_OptionsButton_pressed"] +[connection signal="pressed" from="Control/VBoxContainer/QuitButton" to="." method="_on_QuitButton_pressed"] diff --git a/scripts/interface.gd b/scripts/interface.gd index a242ae2..d61b8d5 100644 --- a/scripts/interface.gd +++ b/scripts/interface.gd @@ -2,6 +2,8 @@ extends CanvasLayer var time_left = 30 var phase_index = 0 +var phase_type = ["RANDOM", "INCREASED RANGE"] +var paused = false func _ready(): update_labels() @@ -17,7 +19,11 @@ func update_labels(): if phase_index < $"../Basketball".phase_increment.size() - 1: if $"../Basketball".phase_increment[phase_index] <= global_variables.score: phase_index += 1 - $PhaseLabel.text = "Next Phase: " + str($"../Basketball".phase_increment[phase_index] - global_variables.score) + $Difficulty/ChangeLabel.text = phase_type[$"../Basketball".phase - 1] + $Difficulty/AnimationPlayer.play("blinking") + var phase_difference = $"../Basketball".phase_increment[phase_index] - global_variables.score + if phase_difference >= 0: + $PhaseLabel.text = "Next Phase: " + str($"../Basketball".phase_increment[phase_index] - global_variables.score) func update_timer(): $TimerLabel.set_text("%03d" % time_left) @@ -29,4 +35,4 @@ func _on_Timer_timeout(): else: global_variables.timer_zero = true $Timer.stop() - $Control.visible = true + $LoseLabel.visible = true diff --git a/scripts/pausemenu.gd b/scripts/pausemenu.gd new file mode 100644 index 0000000..6b0acdb --- /dev/null +++ b/scripts/pausemenu.gd @@ -0,0 +1,27 @@ +extends Control + +func _input(event): + if event.is_action_pressed("escape"): + var pause_toggle = !get_tree().paused + get_tree().paused = pause_toggle + visible = pause_toggle + +func _on_RestartButton_pressed(): + get_tree().reload_current_scene() + get_tree().paused = false + reset_variables() + +func _on_HelpButton_pressed(): + pass + +func _on_OptionsButton_pressed(): + pass + +func _on_QuitButton_pressed(): + get_tree().change_scene("res://scenes/mainmenu.tscn") + get_tree().paused = false + reset_variables() + +func reset_variables(): + global_variables.score = 0 + global_variables.timer_zero = false |