Sound effects

This commit is contained in:
2025-07-30 11:45:33 +02:00
parent 580b5597e2
commit 9e72211a49
37 changed files with 375 additions and 51 deletions

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://cirkmv7ybqqay"
path="res://.godot/imported/Arrow impact.mp3-f1fb165263ed82e00c3ea297553130aa.mp3str"
[deps]
source_file="res://Assets/Sounds/Arrow impact.mp3"
dest_files=["res://.godot/imported/Arrow impact.mp3-f1fb165263ed82e00c3ea297553130aa.mp3str"]
[params]
loop=false
loop_offset=0.0
bpm=0.0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://c4f4xbghas1qn"
path="res://.godot/imported/Arrow shoot.mp3-c3bccd860a0ae9bba7bf87f5748668cd.mp3str"
[deps]
source_file="res://Assets/Sounds/Arrow shoot.mp3"
dest_files=["res://.godot/imported/Arrow shoot.mp3-c3bccd860a0ae9bba7bf87f5748668cd.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://dryh5abntw5yh"
path="res://.godot/imported/Some hitting effect not used yet.mp3-bde98e53c2512e971d34737d2d9a2561.mp3str"
[deps]
source_file="res://Assets/Sounds/Some hitting effect not used yet.mp3"
dest_files=["res://.godot/imported/Some hitting effect not used yet.mp3-bde98e53c2512e971d34737d2d9a2561.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

BIN
Assets/Sounds/allert.mp3 Normal file

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://ca6fgsgi1nqx1"
path="res://.godot/imported/allert.mp3-808908042408cc367738ecc1602183d5.mp3str"
[deps]
source_file="res://Assets/Sounds/allert.mp3"
dest_files=["res://.godot/imported/allert.mp3-808908042408cc367738ecc1602183d5.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://b3wegvn362lm7"
path="res://.godot/imported/health lost.mp3-b3a2cb476c8c825ef203bae0d55461f1.mp3str"
[deps]
source_file="res://Assets/Sounds/health lost.mp3"
dest_files=["res://.godot/imported/health lost.mp3-b3a2cb476c8c825ef203bae0d55461f1.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://ccgorfnbo7tus"
path="res://.godot/imported/mine impact.mp3-7b9e94ea69f7f6f54ec0e92e51e13bfa.mp3str"
[deps]
source_file="res://Assets/Sounds/mine impact.mp3"
dest_files=["res://.godot/imported/mine impact.mp3-7b9e94ea69f7f6f54ec0e92e51e13bfa.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://we1hnps5j60u"
path="res://.godot/imported/mortar impact.mp3-6d389a312acba33186b4a7cf25985173.mp3str"
[deps]
source_file="res://Assets/Sounds/mortar impact.mp3"
dest_files=["res://.godot/imported/mortar impact.mp3-6d389a312acba33186b4a7cf25985173.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://ml4th2ybf7dg"
path="res://.godot/imported/mortar shoot.mp3-a104287da99657fa6839ac32b8000d61.mp3str"
[deps]
source_file="res://Assets/Sounds/mortar shoot.mp3"
dest_files=["res://.godot/imported/mortar shoot.mp3-a104287da99657fa6839ac32b8000d61.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://b00qix6a3do53"
path="res://.godot/imported/stick trap impact.mp3-ff36732a40034d130bdcf4d2523c3d56.mp3str"
[deps]
source_file="res://Assets/Sounds/stick trap impact.mp3"
dest_files=["res://.godot/imported/stick trap impact.mp3-ff36732a40034d130bdcf4d2523c3d56.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://b7dapvstdrckw"
path="res://.godot/imported/wall impact.mp3-e7bef306abdb437ddf238c2589925e25.mp3str"
[deps]
source_file="res://Assets/Sounds/wall impact.mp3"
dest_files=["res://.godot/imported/wall impact.mp3-e7bef306abdb437ddf238c2589925e25.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://cw3jeq08o7cb1"
path="res://.godot/imported/wizard impact.mp3-afa0c59bee4dbe962146cb2fd17bdc53.mp3str"
[deps]
source_file="res://Assets/Sounds/wizard impact.mp3"
dest_files=["res://.godot/imported/wizard impact.mp3-afa0c59bee4dbe962146cb2fd17bdc53.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://1kv8ioeghh5u"
path="res://.godot/imported/wizard shoot.mp3-c5a7a357a509844b3f71f19c3668044d.mp3str"
[deps]
source_file="res://Assets/Sounds/wizard shoot.mp3"
dest_files=["res://.godot/imported/wizard shoot.mp3-c5a7a357a509844b3f71f19c3668044d.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://bjihbmnkq0n3b"]
[gd_scene load_steps=5 format=3 uid="uid://bjihbmnkq0n3b"]
[ext_resource type="Texture2D" uid="uid://bqdblby54pv2s" path="res://Assets/Bullets/arrow.png" id="1_v0wue"]
[ext_resource type="Script" uid="uid://dqvdgdobuo2rf" path="res://Game/Bullets/bullet.gd" id="1_wft0c"]
[ext_resource type="AudioStream" uid="uid://cirkmv7ybqqay" path="res://Assets/Sounds/Arrow impact.mp3" id="3_eecms"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wft0c"]
size = Vector2(3, 16)
@ -28,3 +29,6 @@ shape = SubResource("RectangleShape2D_wft0c")
[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"]
texture = ExtResource("1_v0wue")
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_eecms")

View File

@ -12,13 +12,26 @@ var midpoint = 0
var t = 0.0
var duration = 0.5
var SFX_loudness = 1.0
var master_volume = 1.0
var reached_once = false
static var NAMES = ["Forkman", "Cobold", "Ork"]
func _ready() -> void:
starterpos = global_position
targetpos = target.global_position
midpoint = (targetpos + starterpos) / 2
midpoint.y -= 200 #height of the curve!
midpoint.y -= 200 #height of the curve!
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)
get_node("AudioStreamPlayer2D").finished.connect(finished_end_sound)
func set_targe(_target : Node2D) -> void:
target = _target
@ -31,52 +44,63 @@ func set_hitpoint(_hitpoint: int) -> void:
func _process(delta: float) -> void:
if name.contains("Rock"):
t += delta / duration
position = bezier(t)
if t >= 1.0:
get_node("CharacterBody2D/AnimatedSprite2D").play("hit")
var killalll = get_node("Area2D").get_overlapping_bodies()
for i in killalll:
for j in NAMES:
if i.get_parent().name.contains(j):
i.get_parent().enemy_hurt(hitpoint)
set_process(false)
elif target and speed > 0:
# Get the direction vector from the bullet to the target
var direction = (target.get_parent().get_parent().get_position() - position).normalized()
if not reached_once:
if name.contains("Rock"):
t += delta / duration
position = bezier(t)
if t >= 1.0:
get_node("CharacterBody2D/AnimatedSprite2D").play("hit")
var killalll = get_node("Area2D").get_overlapping_bodies()
for i in killalll:
for j in NAMES:
if i.get_parent().name.contains(j):
i.get_parent().enemy_hurt(hitpoint)
target_reached()
set_process(false)
elif target and speed > 0:
# Get the direction vector from the bullet to the target
var direction = (target.get_parent().get_parent().get_position() - position).normalized()
# Rotate the bullet to face the target
if name.contains("Arrow"):
rotation = direction.angle() + deg_to_rad(90)
# Rotate the bullet to face the target
if name.contains("Arrow"):
rotation = direction.angle() + deg_to_rad(90)
# Move the bullet towards the target
position += direction * speed * delta
distancetaken += (direction * speed * delta).length()
if position.distance_to(target.get_parent().get_parent().position) <= 5:
target_reached()
if distancetaken > 250:
# Move the bullet towards the target
position += direction * speed * delta
distancetaken += (direction * speed * delta).length()
if position.distance_to(target.get_parent().get_parent().position) <= 5:
target_reached()
if distancetaken > 250:
queue_free()
else:
queue_free()
else:
queue_free()
func target_reached() -> void:
if name.contains("Arrow"): #special effects here!
if randf() < 0.1:
target.get_parent().set_speed(target.get_parent().get_speed() / 2)
target.get_parent().adjust_speed_of_animation()
pass
if name.contains("Magic"):
if randf() < 0.1:
target.get_parent().set_progress(max(target.get_parent().get_progress() - 60, 0))
if not reached_once:
reached_once = true
if name.contains("Arrow"): #special effects here!
self.get_node("CharacterBody2D").get_node("Sprite2D").hide()
if randf() < 0.1:
target.get_parent().set_speed(target.get_parent().get_speed() / 2)
target.get_parent().adjust_speed_of_animation()
pass
if name.contains("Magic"):
self.get_node("CharacterBody2D").get_node("Sprite2D").hide()
if randf() < 0.1:
target.get_parent().set_progress(max(target.get_parent().get_progress() - 60, 0))
target.get_parent().enemy_hurt(hitpoint)
queue_free()
if target:
target.get_parent().enemy_hurt(hitpoint)
self.get_node("AudioStreamPlayer2D").volume_db = linear_to_db(master_volume * SFX_loudness)
self.get_node("AudioStreamPlayer2D").playing = true
func finished_end_sound() -> void:
queue_free()
func bezier(t: float):
var q0 = starterpos.lerp(midpoint, t)
var q1 = midpoint.lerp(targetpos, t)

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=7 format=3 uid="uid://caynrq7jnjlnx"]
[gd_scene load_steps=8 format=3 uid="uid://caynrq7jnjlnx"]
[ext_resource type="Texture2D" uid="uid://mmrsjrjxv168" path="res://Assets/Bullets/magic.png" id="1_jjep1"]
[ext_resource type="Script" uid="uid://dqvdgdobuo2rf" path="res://Game/Bullets/bullet.gd" id="1_lj5pp"]
[ext_resource type="AudioStream" uid="uid://cw3jeq08o7cb1" path="res://Assets/Sounds/wizard impact.mp3" id="3_0itbo"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_lj5pp"]
size = Vector2(18, 16)
@ -66,3 +67,6 @@ autoplay = "rotation"
[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"]
scale = Vector2(3, 3)
texture = ExtResource("1_jjep1")
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_0itbo")

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://cwcgq1vk643ha"]
[gd_scene load_steps=12 format=3 uid="uid://cwcgq1vk643ha"]
[ext_resource type="Script" uid="uid://dqvdgdobuo2rf" path="res://Game/Bullets/bullet.gd" id="1_yml18"]
[ext_resource type="Texture2D" uid="uid://t8y1d33eiffp" path="res://Assets/Bullets/mortarbullet (1).png" id="2_yml18"]
@ -7,6 +7,7 @@
[ext_resource type="Texture2D" uid="uid://crf32to6tlkux" path="res://Assets/Bullets/mortarbullet (4).png" id="5_c612l"]
[ext_resource type="Texture2D" uid="uid://bbu8u4h7vpqwa" path="res://Assets/Bullets/mortarbullet (5).png" id="6_m5188"]
[ext_resource type="Texture2D" uid="uid://uc2ib201l7kd" path="res://Assets/Bullets/mortarbullet (6).png" id="7_lr72h"]
[ext_resource type="AudioStream" uid="uid://we1hnps5j60u" path="res://Assets/Sounds/mortar impact.mp3" id="8_av0br"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_yml18"]
size = Vector2(18, 16)
@ -64,4 +65,7 @@ autoplay = "default"
scale = Vector2(3, 3)
shape = SubResource("CircleShape2D_tjven")
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("8_av0br")
[connection signal="animation_finished" from="CharacterBody2D/AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]

View File

@ -138,6 +138,8 @@ func AnimatedSprite2D_animation_finished() -> void:
func Collision_Handler(body: Node2D):
if body.get_parent().name.contains("StickTrap"):
if not body.get_parent().get_if_moving_state():
if body.get_parent().get_node("AudioStreamPlayer2D").playing == false:
body.get_parent().get_node("AudioStreamPlayer2D").playing = true
enemy_hurt(25)
if body.get_parent().name.contains("Mine"):
if not body.get_parent().get_if_moving_state():
@ -146,6 +148,8 @@ func Collision_Handler(body: Node2D):
for j in NAMES:
if i.get_parent().name.contains(j):
enemy_hurt(100)
if body.get_parent().get_node("AudioStreamPlayer2D").playing == false:
body.get_parent().get_node("AudioStreamPlayer2D").playing = true
body.get_parent().Explode_Mine()

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=12 format=3 uid="uid://brugqnquwjrkt"]
[gd_scene load_steps=13 format=3 uid="uid://brugqnquwjrkt"]
[ext_resource type="Texture2D" uid="uid://fxf6wd4317fb" path="res://Assets/Towers/4.png" id="1_1544k"]
[ext_resource type="Script" uid="uid://dil41a1ymo0ua" path="res://Game/Towers/towers.gd" id="1_ssiuv"]
[ext_resource type="AudioStream" uid="uid://c4f4xbghas1qn" path="res://Assets/Sounds/Arrow shoot.mp3" id="3_be2t6"]
[sub_resource type="AtlasTexture" id="AtlasTexture_ssiuv"]
atlas = ExtResource("1_1544k")
@ -90,3 +91,6 @@ autostart = true
position = Vector2(0, 17)
shape = SubResource("CapsuleShape2D_ssiuv")
debug_color = Color(0.862152, 0.144907, 0.800391, 0.42)
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_be2t6")

View File

@ -1,9 +1,10 @@
[gd_scene load_steps=8 format=3 uid="uid://uqxd2lii1xba"]
[gd_scene load_steps=9 format=3 uid="uid://uqxd2lii1xba"]
[ext_resource type="Script" uid="uid://dil41a1ymo0ua" path="res://Game/Towers/towers.gd" id="1_bhlym"]
[ext_resource type="Texture2D" uid="uid://dkgih7tl654v1" path="res://Assets/Towers/Mortar part (3).png" id="1_sq58r"]
[ext_resource type="Texture2D" uid="uid://cm33n3xc81rpj" path="res://Assets/Towers/Mortar part (2).png" id="2_bhlym"]
[ext_resource type="Texture2D" uid="uid://cxtluaplpd8hg" path="res://Assets/Towers/Mortar part (1).png" id="3_82ftk"]
[ext_resource type="AudioStream" uid="uid://ml4th2ybf7dg" path="res://Assets/Sounds/mortar shoot.mp3" id="5_82ftk"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_cfdf4"]
radius = 29.0
@ -57,3 +58,6 @@ autostart = true
position = Vector2(0, 17)
shape = SubResource("CapsuleShape2D_bhlym")
debug_color = Color(0.862152, 0.144907, 0.800391, 0.42)
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("5_82ftk")

View File

@ -7,6 +7,9 @@ var hitpoint = 0
var follower = false
var target = null
var SFX_loudness = 1.0
var master_volume = 1.0
const ARROW = preload("res://Game/Bullets/arrow.tscn")
const MAGIC = preload("res://Game/Bullets/magic.tscn")
const ROCK = preload("res://Game/Bullets/rock.tscn")
@ -20,6 +23,13 @@ func _ready() -> void:
get_node("Timer").timeout.connect(shoot)
set_process_input(true)
set_properties()
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)
func _process(delta: float) -> void:
if follower:
@ -120,4 +130,7 @@ func shoot() -> void:
rock.set_hitpoint(hitpoint)
get_parent().add_child(rock)
lifter = true
pass
self.get_node("AudioStreamPlayer2D").volume_db = linear_to_db(master_volume * SFX_loudness)
self.get_node("AudioStreamPlayer2D").playing = true

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=13 format=3 uid="uid://b4e605q60lde4"]
[gd_scene load_steps=14 format=3 uid="uid://b4e605q60lde4"]
[ext_resource type="Script" uid="uid://dil41a1ymo0ua" path="res://Game/Towers/towers.gd" id="1_grwc8"]
[ext_resource type="Texture2D" uid="uid://dngrpwmj4oedg" path="res://Assets/Towers/S_Fly.png" id="2_grwc8"]
[ext_resource type="AudioStream" uid="uid://1kv8ioeghh5u" path="res://Assets/Sounds/wizard shoot.mp3" id="3_35u2c"]
[sub_resource type="AtlasTexture" id="AtlasTexture_35u2c"]
atlas = ExtResource("2_grwc8")
@ -98,3 +99,6 @@ autostart = true
position = Vector2(0, 17)
shape = SubResource("CapsuleShape2D_grwc8")
debug_color = Color(0.862152, 0.144907, 0.800391, 0.42)
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_35u2c")

View File

@ -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")

View File

@ -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")

View File

@ -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):

View File

@ -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"]