Implement UI and Game Sounds

This commit is contained in:
Snoweuph 2023-04-04 19:50:55 +02:00
parent 18afcf6bf9
commit 073a3083e5
5 changed files with 40 additions and 2 deletions

Binary file not shown.

View file

@ -1,8 +1,10 @@
[gd_scene load_steps=5 format=3 uid="uid://drs4bhpd3vrh2"] [gd_scene load_steps=7 format=3 uid="uid://drs4bhpd3vrh2"]
[ext_resource type="Script" path="res://Scripts/GameManager.gd" id="1_lps27"] [ext_resource type="Script" path="res://Scripts/GameManager.gd" id="1_lps27"]
[ext_resource type="Texture2D" uid="uid://vv33w22kwgpc" path="res://Assets/tile.png" id="2_wiemx"] [ext_resource type="Texture2D" uid="uid://vv33w22kwgpc" path="res://Assets/tile.png" id="2_wiemx"]
[ext_resource type="Script" path="res://Scripts/TileColors.gd" id="3_gnesl"] [ext_resource type="Script" path="res://Scripts/TileColors.gd" id="3_gnesl"]
[ext_resource type="AudioStream" uid="uid://d1ofn1jqfbxpk" path="res://Assets/sounds/apple.wav" id="4_a0lry"]
[ext_resource type="AudioStream" uid="uid://ccoi138at5ti1" path="res://Assets/sounds/bonk.wav" id="5_btrdr"]
[sub_resource type="Resource" id="Resource_22g0s"] [sub_resource type="Resource" id="Resource_22g0s"]
script = ExtResource("3_gnesl") script = ExtResource("3_gnesl")
@ -47,3 +49,9 @@ script = ExtResource("1_lps27")
map_size = 10 map_size = 10
texture = ExtResource("2_wiemx") texture = ExtResource("2_wiemx")
tile_color = SubResource("Resource_22g0s") tile_color = SubResource("Resource_22g0s")
[node name="AudioStreamPlayer Eat Apple" type="AudioStreamPlayer" parent="AspectRatioContainer/Map"]
stream = ExtResource("4_a0lry")
[node name="AudioStreamPlayer Bonk" type="AudioStreamPlayer" parent="AspectRatioContainer/Map"]
stream = ExtResource("5_btrdr")

View file

@ -1,7 +1,10 @@
[gd_scene load_steps=3 format=3 uid="uid://c7ok1re4seqsh"] [gd_scene load_steps=6 format=3 uid="uid://c7ok1re4seqsh"]
[ext_resource type="Script" path="res://Scripts/Main Menu Buttons.gd" id="1_abac4"] [ext_resource type="Script" path="res://Scripts/Main Menu Buttons.gd" id="1_abac4"]
[ext_resource type="Theme" uid="uid://clkt54a4wy6tn" path="res://Assets/Base.tres" id="1_b1d2h"] [ext_resource type="Theme" uid="uid://clkt54a4wy6tn" path="res://Assets/Base.tres" id="1_b1d2h"]
[ext_resource type="AudioStream" uid="uid://b0wk8jyi64qbd" path="res://Assets/sounds/start.wav" id="3_bxs37"]
[ext_resource type="AudioStream" uid="uid://d4bi0dxjmvfyx" path="res://Assets/sounds/change.wav" id="4_gb8rx"]
[ext_resource type="AudioStream" uid="uid://d0o66pmjueo1x" path="res://Assets/sounds/menu_change.wav" id="5_xb4d6"]
[node name="Control" type="Control"] [node name="Control" type="Control"]
layout_mode = 3 layout_mode = 3
@ -141,10 +144,27 @@ theme = ExtResource("1_b1d2h")
theme_override_font_sizes/font_size = 96 theme_override_font_sizes/font_size = 96
text = "Back" text = "Back"
[node name="AudioStreamPlayer Start" type="AudioStreamPlayer" parent="."]
stream = ExtResource("3_bxs37")
[node name="AudioStreamPlayer Change UI" type="AudioStreamPlayer" parent="."]
stream = ExtResource("4_gb8rx")
[node name="AudioStreamPlayer Change Value" type="AudioStreamPlayer" parent="."]
stream = ExtResource("5_xb4d6")
[connection signal="focus_entered" from="." to="." method="_on_focus_entered"]
[connection signal="focus_entered" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Start Button" to="." method="_on_focus_entered"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Start Button" to="." method="_on_start_button_pressed"] [connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Start Button" to="." method="_on_start_button_pressed"]
[connection signal="focus_entered" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Settings Button" to="." method="_on_focus_entered"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Settings Button" to="." method="_on_settings_button_pressed"] [connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Settings Button" to="." method="_on_settings_button_pressed"]
[connection signal="focus_entered" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/About Button" to="." method="_on_focus_entered"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/About Button" to="." method="_on_about_button_pressed"] [connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/About Button" to="." method="_on_about_button_pressed"]
[connection signal="focus_entered" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Quit Button" to="." method="_on_focus_entered"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Quit Button" to="." method="_on_quit_button_pressed"] [connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Quit Button" to="." method="_on_quit_button_pressed"]
[connection signal="focus_entered" from="MarginContainer/VBoxContainer/Tab Group/Settings/GridSize/GridSize_Slider" to="." method="_on_focus_entered"]
[connection signal="value_changed" from="MarginContainer/VBoxContainer/Tab Group/Settings/GridSize/GridSize_Slider" to="." method="_on_grid_size_slider_value_changed"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/Tab Group/Settings/GridSize/GridSize_Slider" to="." method="_on_grid_size_slider_value_changed"]
[connection signal="focus_entered" from="MarginContainer/VBoxContainer/Tab Group/Settings/Speed/Speed_Slider" to="." method="_on_focus_entered"]
[connection signal="value_changed" from="MarginContainer/VBoxContainer/Tab Group/Settings/Speed/Speed_Slider" to="." method="_on_speed_slider_value_changed"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/Tab Group/Settings/Speed/Speed_Slider" to="." method="_on_speed_slider_value_changed"]
[connection signal="focus_entered" from="MarginContainer/VBoxContainer/Tab Group/Settings/Back Button" to="." method="_on_focus_entered"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Settings/Back Button" to="." method="_on_back_button_pressed"] [connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Settings/Back Button" to="." method="_on_back_button_pressed"]

View file

@ -80,6 +80,7 @@ func process_tiles():
new_snake_head.state = Tile.States.SNAKE new_snake_head.state = Tile.States.SNAKE
last_snake_move_vector = snake_move_vector last_snake_move_vector = snake_move_vector
if was_apple: if was_apple:
$"AudioStreamPlayer Eat Apple".play()
snake_length += 1 snake_length += 1
generate_apple() generate_apple()
pass pass
@ -118,7 +119,9 @@ func game_start():
pass pass
func game_stop(): func game_stop():
$"AudioStreamPlayer Bonk".play()
game_is_running = false game_is_running = false
await $"AudioStreamPlayer Bonk".finished
get_tree().change_scene_to_file("res://Scene/Main Menu.tscn") get_tree().change_scene_to_file("res://Scene/Main Menu.tscn")
pass pass

View file

@ -22,6 +22,8 @@ func _ready():
func _on_start_button_pressed(): func _on_start_button_pressed():
$"AudioStreamPlayer Start".play()
await $"AudioStreamPlayer Start".finished
get_tree().change_scene_to_file("res://Scene/Game.tscn") get_tree().change_scene_to_file("res://Scene/Game.tscn")
func _on_quit_button_pressed(): func _on_quit_button_pressed():
@ -44,12 +46,17 @@ func _on_back_button_pressed():
$"MarginContainer/VBoxContainer/Tab Group/Menu Butons/Start Button".grab_focus() $"MarginContainer/VBoxContainer/Tab Group/Menu Butons/Start Button".grab_focus()
func _on_grid_size_slider_value_changed(value): func _on_grid_size_slider_value_changed(value):
$"AudioStreamPlayer Change Value".play()
$"MarginContainer/VBoxContainer/Tab Group/Settings/GridSize/Value".text = " " + str(int(value)) $"MarginContainer/VBoxContainer/Tab Group/Settings/GridSize/Value".text = " " + str(int(value))
config.set_value("Game Play", "grid_size", int(value)) config.set_value("Game Play", "grid_size", int(value))
config.save("user://config.cfg") config.save("user://config.cfg")
func _on_speed_slider_value_changed(value): func _on_speed_slider_value_changed(value):
$"AudioStreamPlayer Change Value".play()
$"MarginContainer/VBoxContainer/Tab Group/Settings/Speed/Value".text = "%10.2f" % value $"MarginContainer/VBoxContainer/Tab Group/Settings/Speed/Value".text = "%10.2f" % value
config.set_value("Game Play", "speed", value) config.set_value("Game Play", "speed", value)
config.save("user://config.cfg") config.save("user://config.cfg")
func _on_focus_entered():
$"AudioStreamPlayer Change UI".play()