diff --git a/assets/icons/settings.png b/assets/icons/settings.png new file mode 100644 index 0000000..a7e0864 Binary files /dev/null and b/assets/icons/settings.png differ diff --git a/assets/icons/settings.png.import b/assets/icons/settings.png.import new file mode 100644 index 0000000..e8afb58 --- /dev/null +++ b/assets/icons/settings.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cgaqy7lcu4x78" +path="res://.godot/imported/settings.png-9e60c86d9b162ed0f32eee17a57d027f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/icons/settings.png" +dest_files=["res://.godot/imported/settings.png-9e60c86d9b162ed0f32eee17a57d027f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/project.godot b/project.godot index 1063c9c..b0ec4a7 100644 --- a/project.godot +++ b/project.godot @@ -20,6 +20,10 @@ boot_splash/fullsize=false config/icon="res://assets/icons/logo.png" boot_splash/minimum_display_time=3 +[autoload] + +Global="*res://scripts/global.gd" + [display] window/stretch/mode="viewport" diff --git a/scenes/stages/stage_1.tscn b/scenes/stages/stage_1.tscn index 8860d8e..c79f6ed 100644 --- a/scenes/stages/stage_1.tscn +++ b/scenes/stages/stage_1.tscn @@ -600,7 +600,6 @@ one_shot = true [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] stream = ExtResource("12_2v5rl") volume_db = 1.0 -autoplay = true [connection signal="timeout" from="Path2D/Timer" to="Path2D" method="_on_timer_timeout"] [connection signal="timeout" from="Duration" to="." method="_on_duration_timeout"] diff --git a/scenes/stages/stage_2.tscn b/scenes/stages/stage_2.tscn index c4564d6..1176564 100644 --- a/scenes/stages/stage_2.tscn +++ b/scenes/stages/stage_2.tscn @@ -333,7 +333,6 @@ one_shot = true [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] stream = ExtResource("12_uwk7b") volume_db = 1.0 -autoplay = true [connection signal="timeout" from="Path2D/Timer" to="Path2D" method="_on_timer_timeout"] [connection signal="timeout" from="Path2D2/Timer" to="Path2D2" method="_on_timer_timeout"] diff --git a/scenes/stages/stage_3.tscn b/scenes/stages/stage_3.tscn index d196830..84121a0 100644 --- a/scenes/stages/stage_3.tscn +++ b/scenes/stages/stage_3.tscn @@ -314,7 +314,6 @@ one_shot = true [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] stream = ExtResource("12_1fpbf") volume_db = 1.0 -autoplay = true [connection signal="timeout" from="Path2D/Timer" to="Path2D" method="_on_timer_timeout"] [connection signal="timeout" from="Duration" to="." method="_on_duration_timeout"] diff --git a/scenes/stages/stage_4.tscn b/scenes/stages/stage_4.tscn index 239766e..3b4eb86 100644 --- a/scenes/stages/stage_4.tscn +++ b/scenes/stages/stage_4.tscn @@ -330,7 +330,6 @@ one_shot = true [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] stream = ExtResource("12_8sjqs") volume_db = 1.0 -autoplay = true [connection signal="timeout" from="Path2D/Timer" to="Path2D" method="_on_timer_timeout"] [connection signal="timeout" from="Path2D2/Timer" to="Path2D2" method="_on_timer_timeout"] diff --git a/scenes/stages/stage_5.tscn b/scenes/stages/stage_5.tscn index a505568..8813156 100644 --- a/scenes/stages/stage_5.tscn +++ b/scenes/stages/stage_5.tscn @@ -328,7 +328,6 @@ one_shot = true [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] stream = ExtResource("12_2xeuw") volume_db = 1.0 -autoplay = true [connection signal="timeout" from="Path2D/Timer" to="Path2D" method="_on_timer_timeout"] [connection signal="timeout" from="Path2D2/Timer" to="Path2D2" method="_on_timer_timeout"] diff --git a/scenes/stages/stage_6.tscn b/scenes/stages/stage_6.tscn index 00ad3d8..057a9b3 100644 --- a/scenes/stages/stage_6.tscn +++ b/scenes/stages/stage_6.tscn @@ -730,7 +730,6 @@ one_shot = true [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] stream = ExtResource("12_is64a") volume_db = 1.0 -autoplay = true [connection signal="timeout" from="Path2D/Timer" to="Path2D" method="_on_timer_timeout"] [connection signal="timeout" from="Path2D2/Timer" to="Path2D2" method="_on_timer_timeout"] diff --git a/scenes/ui/main_menu.tscn b/scenes/ui/main_menu.tscn index db6a0f6..f9a0037 100644 --- a/scenes/ui/main_menu.tscn +++ b/scenes/ui/main_menu.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=6 format=3 uid="uid://b8pdp1x331u5c"] +[gd_scene load_steps=7 format=3 uid="uid://b8pdp1x331u5c"] [ext_resource type="Texture2D" uid="uid://c1qbpse383sys" path="res://assets/backgrounds/main-bg.png" id="1_28cjd"] [ext_resource type="Script" path="res://scripts/ui/main_menu.gd" id="1_6741p"] [ext_resource type="Texture2D" uid="uid://dm8ug0o5361wn" path="res://assets/icons/logo.png" id="2_l26fo"] [ext_resource type="Theme" uid="uid://caw53lcko4jnt" path="res://themes/button.tres" id="4_4d3eq"] +[ext_resource type="Texture2D" uid="uid://cgaqy7lcu4x78" path="res://assets/icons/settings.png" id="5_kbtiw"] [ext_resource type="AudioStream" uid="uid://dhydsnb0wpl7t" path="res://assets/audio/main.mp3" id="5_xkvpi"] [node name="MainMenu" type="Control"] @@ -88,6 +89,15 @@ size_flags_horizontal = 10 theme = ExtResource("4_4d3eq") text = "Exit" +[node name="Settings" type="TextureButton" parent="TextureRect/Panel"] +layout_mode = 0 +offset_left = 52.0 +offset_top = 51.0 +offset_right = 572.0 +offset_bottom = 571.0 +scale = Vector2(0.1, 0.1) +texture_normal = ExtResource("5_kbtiw") + [node name="Timer" type="Timer" parent="."] wait_time = 30.0 one_shot = true @@ -95,11 +105,13 @@ one_shot = true [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] stream = ExtResource("5_xkvpi") volume_db = 1.0 -autoplay = true [connection signal="pressed" from="TextureRect/Panel/MarginContainer/VBoxContainer/TextureButton" to="." method="_on_logo_pressed"] [connection signal="pressed" from="TextureRect/Panel/MarginContainer/VBoxContainer/VBoxContainer/StartGame" to="." method="_on_start_game_pressed"] [connection signal="pressed" from="TextureRect/Panel/MarginContainer/VBoxContainer/VBoxContainer/HowToPlay" to="." method="_on_how_to_play_pressed"] [connection signal="pressed" from="TextureRect/Panel/MarginContainer/VBoxContainer/HBoxContainer/About" to="." method="_on_about_pressed"] [connection signal="pressed" from="TextureRect/Panel/MarginContainer/VBoxContainer/HBoxContainer/Exit" to="." method="_on_exit_pressed"] +[connection signal="mouse_entered" from="TextureRect/Panel/Settings" to="." method="_on_settings_hold"] +[connection signal="mouse_exited" from="TextureRect/Panel/Settings" to="." method="_on_settings_release"] +[connection signal="pressed" from="TextureRect/Panel/Settings" to="." method="_on_settings_pressed"] [connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/scenes/ui/select_stage.tscn b/scenes/ui/select_stage.tscn index a0bf8a2..8006340 100644 --- a/scenes/ui/select_stage.tscn +++ b/scenes/ui/select_stage.tscn @@ -223,7 +223,6 @@ text = "6" [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] stream = ExtResource("11_1rv5g") volume_db = 1.0 -autoplay = true [connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/Back" to="." method="_on_back_pressed"] [connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer2/MarginContainer/Stage 1" to="." method="_on_stage_1_pressed"] diff --git a/scenes/ui/settings.tscn b/scenes/ui/settings.tscn new file mode 100644 index 0000000..e1517fb --- /dev/null +++ b/scenes/ui/settings.tscn @@ -0,0 +1,108 @@ +[gd_scene load_steps=6 format=3 uid="uid://ons67oqg25vu"] + +[ext_resource type="Script" path="res://scripts/ui/settings.gd" id="1_kci63"] +[ext_resource type="Theme" uid="uid://bt3yyqwlp4f7j" path="res://themes/title_text.tres" id="2_2enke"] +[ext_resource type="Theme" uid="uid://caw53lcko4jnt" path="res://themes/button.tres" id="3_jiiby"] + +[sub_resource type="Theme" id="Theme_ulpvq"] +Label/font_sizes/font_size = 30 + +[sub_resource type="Theme" id="Theme_23erg"] + +[node name="Settings" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_kci63") + +[node name="Panel" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="Panel"] +layout_mode = 2 +offset_left = 20.0 +offset_top = 20.0 +offset_right = 1132.0 +offset_bottom = 82.0 + +[node name="Label" type="Label" parent="Panel/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 0 +theme = ExtResource("2_2enke") +text = "Settings" + +[node name="Back" type="Button" parent="Panel/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 10 +size_flags_vertical = 0 +theme = ExtResource("3_jiiby") +text = "Back" + +[node name="Volume" type="Label" parent="Panel"] +layout_mode = 0 +offset_left = 23.0 +offset_top = 173.0 +offset_right = 233.0 +offset_bottom = 218.0 +theme = SubResource("Theme_ulpvq") +text = "Sound Volume" + +[node name="VolumeSlider" type="HSlider" parent="Panel"] +layout_mode = 0 +offset_left = 281.0 +offset_top = 181.0 +offset_right = 634.0 +offset_bottom = 197.0 +scale = Vector2(2, 2) +min_value = -40.0 +max_value = 1.0 +value = 1.0 + +[node name="BGM" type="Label" parent="Panel"] +layout_mode = 0 +offset_left = 23.0 +offset_top = 260.0 +offset_right = 233.0 +offset_bottom = 305.0 +theme = SubResource("Theme_ulpvq") +text = "BGM" + +[node name="BGMController" type="CheckButton" parent="Panel"] +layout_mode = 0 +offset_left = 267.0 +offset_top = 256.0 +offset_right = 311.0 +offset_bottom = 280.0 +scale = Vector2(2, 2) +theme = SubResource("Theme_23erg") + +[node name="SFX" type="Label" parent="Panel"] +layout_mode = 0 +offset_left = 24.0 +offset_top = 352.0 +offset_right = 234.0 +offset_bottom = 397.0 +theme = SubResource("Theme_ulpvq") +text = "SFX" + +[node name="SFXController" type="CheckButton" parent="Panel"] +layout_mode = 0 +offset_left = 267.0 +offset_top = 347.0 +offset_right = 311.0 +offset_bottom = 371.0 +scale = Vector2(2, 2) + +[connection signal="pressed" from="Panel/HBoxContainer/Back" to="." method="_on_back_pressed"] +[connection signal="value_changed" from="Panel/VolumeSlider" to="." method="_on_volume_slider_value_changed"] +[connection signal="toggled" from="Panel/BGMController" to="." method="_on_bgm_controller_toggled"] +[connection signal="toggled" from="Panel/SFXController" to="." method="_on_sfx_controller_toggled"] diff --git a/scripts/global.gd b/scripts/global.gd new file mode 100644 index 0000000..30596d1 --- /dev/null +++ b/scripts/global.gd @@ -0,0 +1,6 @@ +extends Node + + +var sound_volume = 1 +var bgm_status = true +var sfx_status = true \ No newline at end of file diff --git a/scripts/stages/1/game_manager.gd b/scripts/stages/1/game_manager.gd index 4b6e0df..9adff6f 100644 --- a/scripts/stages/1/game_manager.gd +++ b/scripts/stages/1/game_manager.gd @@ -23,6 +23,10 @@ func _ready(): # Init Engine time scale Engine.time_scale = 1.0 + # Check BGM Status + if Global.bgm_status: + $AudioStreamPlayer.play() + # Set Duration & Start Timer duration.wait_time = config.game['duration'] duration.start() diff --git a/scripts/stages/2/game_manager.gd b/scripts/stages/2/game_manager.gd index 1e92ff2..df8a468 100644 --- a/scripts/stages/2/game_manager.gd +++ b/scripts/stages/2/game_manager.gd @@ -22,6 +22,10 @@ func _ready(): # Init Engine time scale Engine.time_scale = 1.0 + # Check BGM Status + if Global.bgm_status: + $AudioStreamPlayer.play() + # Set Duration & Start Timer duration.wait_time = config.game['duration'] duration.start() diff --git a/scripts/stages/3/game_manager.gd b/scripts/stages/3/game_manager.gd index e6df6aa..c4cf6a4 100644 --- a/scripts/stages/3/game_manager.gd +++ b/scripts/stages/3/game_manager.gd @@ -21,6 +21,10 @@ func _ready(): # Init Engine time scale Engine.time_scale = 1.0 + + # Check BGM Status + if Global.bgm_status: + $AudioStreamPlayer.play() # Set Duration & Start Timer duration.wait_time = config.game['duration'] diff --git a/scripts/stages/4/game_manager.gd b/scripts/stages/4/game_manager.gd index 2728772..7f8e1d4 100644 --- a/scripts/stages/4/game_manager.gd +++ b/scripts/stages/4/game_manager.gd @@ -21,6 +21,10 @@ func _ready(): # Init Engine time scale Engine.time_scale = 1.0 + + # Check BGM Status + if Global.bgm_status: + $AudioStreamPlayer.play() # Set Duration & Start Timer duration.wait_time = config.game['duration'] diff --git a/scripts/stages/5/game_manager.gd b/scripts/stages/5/game_manager.gd index c6f7930..50b727d 100644 --- a/scripts/stages/5/game_manager.gd +++ b/scripts/stages/5/game_manager.gd @@ -22,6 +22,10 @@ func _ready(): # Init Engine time scale Engine.time_scale = 1.0 + # Check BGM Status + if Global.bgm_status: + $AudioStreamPlayer.play() + # Set Duration & Start Timer duration.wait_time = config.game['duration'] duration.start() diff --git a/scripts/stages/6/game_manager.gd b/scripts/stages/6/game_manager.gd index b6bee33..17a3bbd 100644 --- a/scripts/stages/6/game_manager.gd +++ b/scripts/stages/6/game_manager.gd @@ -21,6 +21,10 @@ func _ready(): # Init Engine time scale Engine.time_scale = 1.0 + + # Check BGM Status + if Global.bgm_status: + $AudioStreamPlayer.play() # Set Duration & Start Timer duration.wait_time = config.game['duration'] diff --git a/scripts/towers/tower.gd b/scripts/towers/tower.gd index e04e082..1ff0fbd 100644 --- a/scripts/towers/tower.gd +++ b/scripts/towers/tower.gd @@ -59,7 +59,10 @@ func _physics_process(_delta): func _shoot(): if bullet: - shoot.play() + # Check SFX Status + if Global.sfx_status: + shoot.play() + var bullet_instance: Node2D = bullet.instantiate() bullet_instance.dir = rotation bullet_instance.rotation = rotation diff --git a/scripts/ui/main_menu.gd b/scripts/ui/main_menu.gd index 6dc5b95..7e67883 100644 --- a/scripts/ui/main_menu.gd +++ b/scripts/ui/main_menu.gd @@ -21,6 +21,10 @@ func _ready(): if OS.get_name() == "Web": $TextureRect/Panel/MarginContainer/VBoxContainer/HBoxContainer/Exit.hide() + # Check BGM Status + if Global.bgm_status: + $AudioStreamPlayer.play() + func _on_logo_pressed(): if timer.is_stopped(): timer.start() @@ -51,5 +55,14 @@ func _on_how_to_play_pressed(): func _on_about_pressed(): get_tree().change_scene_to_file("res://scenes/ui/about.tscn") +func _on_settings_pressed(): + get_tree().change_scene_to_file("res://scenes/ui/settings.tscn") + +func _on_settings_hold(): + $TextureRect/Panel/Settings.modulate = Color(0.541176, 0.541176, 0.541176, 1) + +func _on_settings_release(): + $TextureRect/Panel/Settings.modulate = Color(1, 1, 1, 1) + func _on_exit_pressed(): get_tree().quit() \ No newline at end of file diff --git a/scripts/ui/select_stage.gd b/scripts/ui/select_stage.gd index d5548ca..453d78d 100644 --- a/scripts/ui/select_stage.gd +++ b/scripts/ui/select_stage.gd @@ -36,6 +36,10 @@ func _ready(): _: pass + # Check BGM Status + if Global.bgm_status: + $AudioStreamPlayer.play() + func _on_back_pressed(): get_tree().change_scene_to_file("res://scenes/ui/main_menu.tscn") diff --git a/scripts/ui/settings.gd b/scripts/ui/settings.gd new file mode 100644 index 0000000..5f89de7 --- /dev/null +++ b/scripts/ui/settings.gd @@ -0,0 +1,23 @@ +extends Control + + +var bus_master = AudioServer.get_bus_index("Master") + +func _ready(): + $Panel/VolumeSlider.value = Global.sound_volume + $Panel/BGMController.button_pressed = Global.bgm_status + $Panel/SFXController.button_pressed = Global.sfx_status + +func _on_back_pressed(): + get_tree().change_scene_to_file("res://scenes/ui/main_menu.tscn") + +func _on_volume_slider_value_changed(value): + AudioServer.set_bus_volume_db(bus_master, value) + AudioServer.set_bus_mute(bus_master, value == $Panel/VolumeSlider.min_value) + Global.sound_volume = value + +func _on_bgm_controller_toggled(button_pressed): + Global.bgm_status = button_pressed + +func _on_sfx_controller_toggled(button_pressed): + Global.sfx_status = button_pressed \ No newline at end of file