Sound effects
This commit is contained in:
@ -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):
|
||||
|
Reference in New Issue
Block a user