Sound effects
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://ctbmgsp8dfel3"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://ctbmgsp8dfel3"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://3gn70ilm20tw" path="res://Game/Traps/traps.gd" id="1_6fgim"]
|
||||
[ext_resource type="Texture2D" uid="uid://dn22pudsmyrrg" path="res://Assets/Traps/Mine/49.png" id="2_6m2fs"]
|
||||
[ext_resource type="Texture2D" uid="uid://sb3dotm5napj" path="res://Assets/Traps/Mine/54.png" id="3_57sxm"]
|
||||
[ext_resource type="Texture2D" uid="uid://by0c26bla5hce" path="res://Assets/Traps/Mine/55.png" id="4_a3dnl"]
|
||||
[ext_resource type="Texture2D" uid="uid://cspjuelhbbavu" path="res://Assets/Traps/Mine/56.png" id="5_a1ih2"]
|
||||
[ext_resource type="AudioStream" uid="uid://ccgorfnbo7tus" path="res://Assets/Sounds/mine impact.mp3" id="6_a3dnl"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_m1bdk"]
|
||||
radius = 32.0
|
||||
@ -64,3 +65,6 @@ shape = SubResource("CircleShape2D_uiyu1")
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("CircleShape2D_57sxm")
|
||||
debug_color = Color(0.811824, 0.00210331, 0.983083, 0.42)
|
||||
|
||||
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
||||
stream = ExtResource("6_a3dnl")
|
||||
|
@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://pqy8rrvjthgl"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://pqy8rrvjthgl"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://4bah0c8unbl8" path="res://Assets/Traps/Sticks/Tile2_59.png" id="1_dnq4b"]
|
||||
[ext_resource type="Script" uid="uid://3gn70ilm20tw" path="res://Game/Traps/traps.gd" id="1_metvu"]
|
||||
[ext_resource type="Texture2D" uid="uid://l58s5yxh4f8n" path="res://Assets/Traps/Sticks/Tile2_60.png" id="2_metvu"]
|
||||
[ext_resource type="AudioStream" uid="uid://b00qix6a3do53" path="res://Assets/Sounds/stick trap impact.mp3" id="4_m1bdk"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_m1bdk"]
|
||||
radius = 32.0
|
||||
@ -38,3 +39,6 @@ shape = SubResource("CircleShape2D_m1bdk")
|
||||
position = Vector2(4.25, 11)
|
||||
shape = SubResource("RectangleShape2D_metvu")
|
||||
debug_color = Color(0.811824, 0.00210331, 0.983083, 0.42)
|
||||
|
||||
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
||||
stream = ExtResource("4_m1bdk")
|
||||
|
@ -4,14 +4,28 @@ var follower = false
|
||||
var health = 100
|
||||
static var NAMES = ["Forkman", "Cobold", "Ork"]
|
||||
|
||||
var SFX_loudness = 1.0
|
||||
var master_volume = 1.0
|
||||
|
||||
func _ready() -> void:
|
||||
follower = true
|
||||
if name.contains("Mine"):
|
||||
get_node("CharacterBody2D/AnimatedSprite2D").connect("animation_finished", Callable(self, "Remove_Mine"))
|
||||
#get_node("CharacterBody2D/AnimatedSprite2D").connect("animation_finished", Callable(self, "Remove_Mine"))
|
||||
get_node("AudioStreamPlayer2D").connect("finished", Callable(self, "explode_ended"))
|
||||
set_process_input(true)
|
||||
|
||||
if name.contains("Wall"):
|
||||
get_node("CharacterBody2D/ProgressBar").hide()
|
||||
var config = ConfigFile.new()
|
||||
var err = config.load("user://settings.cfg")
|
||||
|
||||
if err == OK:
|
||||
var master_volume_raw = config.get_value("audio", "master_volume", 100.0)
|
||||
master_volume = clamp(master_volume_raw / 100.0, 0.0, 1.0)
|
||||
var sfx_volume_raw = config.get_value("audio", "sfx_volume", 100.0)
|
||||
SFX_loudness = clamp(sfx_volume_raw / 100.0, 0.0, 1.0)
|
||||
self.get_node("AudioStreamPlayer2D").volume_db = linear_to_db(master_volume * SFX_loudness)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if follower:
|
||||
@ -42,6 +56,9 @@ func Explode_Mine() -> void:
|
||||
get_node("CharacterBody2D/AnimatedSprite2D").scale = Vector2(1,1)
|
||||
get_node("CharacterBody2D/AnimatedSprite2D").play("Explode")
|
||||
|
||||
func explode_ended() -> void:
|
||||
Remove_Mine()
|
||||
|
||||
func Remove_Mine() -> void:
|
||||
queue_free()
|
||||
|
||||
@ -58,7 +75,9 @@ func _on_area_2d_body_shape_entered(body_rid: RID, body: Node2D, body_shape_inde
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
var minus = 0
|
||||
|
||||
if self.get_node("AudioStreamPlayer2D").playing == false:
|
||||
self.get_node("AudioStreamPlayer2D").playing = true
|
||||
|
||||
for i in get_node("CharacterBody2D/Area2D").get_overlapping_bodies():
|
||||
for j in NAMES:
|
||||
if i.get_parent().name.contains(j):
|
||||
|
@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://cc5j50rtwlfld"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://cc5j50rtwlfld"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://3gn70ilm20tw" path="res://Game/Traps/traps.gd" id="1_3ht3o"]
|
||||
[ext_resource type="Texture2D" uid="uid://ri5c5u8gbjde" path="res://Assets/Traps/Wall/Tile2_49.png" id="1_y07rg"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5wu41w5yjr25" path="res://Assets/Traps/Wall/Tile2_57.png" id="2_3ht3o"]
|
||||
[ext_resource type="AudioStream" uid="uid://b7dapvstdrckw" path="res://Assets/Sounds/wall impact.mp3" id="4_bxxpj"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bxxpj"]
|
||||
size = Vector2(22.5, 75)
|
||||
@ -75,6 +76,9 @@ position = Vector2(0, 2)
|
||||
shape = SubResource("RectangleShape2D_xk2lx")
|
||||
debug_color = Color(0.811824, 0.00210331, 0.983083, 0.42)
|
||||
|
||||
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
||||
stream = ExtResource("4_bxxpj")
|
||||
|
||||
[connection signal="body_shape_entered" from="CharacterBody2D/Area2D" to="." method="_on_area_2d_body_shape_entered"]
|
||||
[connection signal="body_shape_exited" from="CharacterBody2D/Area2D" to="." method="_on_area_2d_body_shape_exited"]
|
||||
[connection signal="timeout" from="CharacterBody2D/Timer" to="." method="_on_timer_timeout"]
|
||||
|
Reference in New Issue
Block a user