1
0
Fork 0

Sound effects

This commit is contained in:
Felipe M 2021-05-23 00:38:30 +02:00
parent 6ea21b3181
commit 6671b455c4
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
17 changed files with 94 additions and 6 deletions

BIN
metroidvania/Assets/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Music and Sounds/Music.gd" type="Script" id=1]
[ext_resource path="res://Music and Sounds/Music.ogg" type="AudioStream" id=2]
[ext_resource path="res://Assets/Music and Sounds/Music.ogg" type="AudioStream" id=2]
[node name="Music" type="Node"]
script = ExtResource( 1 )

View File

@ -1,9 +1,10 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=2]
[ext_resource path="res://Levels/Level.tscn" type="PackedScene" id=1]
[ext_resource path="res://Levels/Door.tscn" type="PackedScene" id=2]
[ext_resource path="res://Levels/DoorConnections/00_link_01.tres" type="Resource" id=3]
[ext_resource path="res://Scenes/Objects/SaveStation.tscn" type="PackedScene" id=4]
[ext_resource path="res://Scenes/Enemies/WalkingEnemy.tscn" type="PackedScene" id=5]
[node name="Level_00" instance=ExtResource( 1 )]
@ -18,3 +19,6 @@ new_level_path = "res://Levels/Level_01.tscn"
[node name="SaveStation" parent="." index="2" instance=ExtResource( 4 )]
position = Vector2( 215, 160 )
scale = Vector2( 0.998604, 1 )
[node name="WalkingEnemy" parent="SaveStation" index="5" instance=ExtResource( 5 )]
position = Vector2( -182.254, -1.52588e-05 )

View File

@ -0,0 +1,5 @@
extends Node2D
func _ready():
SoundFx.play_fx("Explosion", rand_range(0.6, 1.4), -20)

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Scenes/Effects/Effect.tscn" type="PackedScene" id=1]
[ext_resource path="res://Assets/Effects/ExplosionEffect.png" type="Texture" id=2]
[ext_resource path="res://Scenes/Effects/ExplosionEffect.gd" type="Script" id=3]
[sub_resource type="Animation" id=1]
resource_name = "Animate"
@ -34,6 +35,7 @@ tracks/1/keys = {
}
[node name="ExplosionEffect" instance=ExtResource( 1 )]
script = ExtResource( 3 )
[node name="Sprite" parent="." index="0"]
texture = ExtResource( 2 )

View File

@ -14,6 +14,7 @@ func _on_Hurtbox_hit(damage):
stats.health -= damage
func _on_EnemyStats_enemy_died():
SoundFx.play_fx("EnemyDie", 1, -20)
Utils.instance_scene_on_main(EnemyDeathEffect, global_position)
queue_free()
emit_signal("died")

View File

@ -6,11 +6,16 @@ func set_paused(value):
paused = value
get_tree().paused = paused
visible = paused
if value:
SoundFx.play_fx("Pause")
else:
SoundFx.play_fx("Unpause", 1, -30)
func _on_ResumeButton_pressed():
self.paused = false
func _on_QuitButton_pressed():
SoundFx.play_fx("Click")
get_tree().quit()
func _process(_delta):

View File

@ -53,5 +53,6 @@ margin_right = 64.0
margin_bottom = 71.0
rect_min_size = Vector2( 64, 16 )
text = "Quit"
[connection signal="pressed" from="CenterContainer/VBoxContainer/ResumeButton" to="." method="_on_ResumeButton_pressed"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/QuitButton" to="." method="_on_QuitButton_pressed"]

View File

@ -0,0 +1,33 @@
extends Node
onready var soundPlayers = get_children()
const SOUNDS_PATH = "res://Assets/Music and Sounds/"
const DEFAULT_VOLUME_DB = -20
const DEFAULT_PITCH_SCALE = 1
var cache = {}
func load_sound(filename):
var path = SOUNDS_PATH + filename
if not (filename in cache):
cache[filename] = load(path)
return cache[filename]
func play_fx(sound, pitch_scale = DEFAULT_PITCH_SCALE, volume_db = DEFAULT_VOLUME_DB):
filename = sound + ".wav"
play(load_sound(filename), pitch_scale, volume_db)
func play_music(sound, pitch_scale = DEFAULT_PITCH_SCALE, volume_db = DEFAULT_VOLUME_DB):
filename = sound + ".ogg"
play(load_sound(filename), pitch_scale, volume_db)
func play(sound_res, pitch_scale, volume_db):
for soundPlayer in soundPlayers:
if not soundPlayer.playing:
soundPlayer.pitch_scale = pitch_scale
soundPlayer.volume_db = volume_db
soundPlayer.stream = sound_res
soundPlayer.play()
return
print("Too many sounds")

View File

@ -0,0 +1,27 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Scenes/Music/SoundFX.gd" type="Script" id=1]
[node name="SoundFX" type="Node"]
pause_mode = 2
script = ExtResource( 1 )
[node name="AudioStreamPlayer1" type="AudioStreamPlayer" parent="."]
[node name="AudioStreamPlayer2" type="AudioStreamPlayer" parent="."]
[node name="AudioStreamPlayer3" type="AudioStreamPlayer" parent="."]
[node name="AudioStreamPlayer4" type="AudioStreamPlayer" parent="."]
[node name="AudioStreamPlayer5" type="AudioStreamPlayer" parent="."]
[node name="AudioStreamPlayer6" type="AudioStreamPlayer" parent="."]
[node name="AudioStreamPlayer7" type="AudioStreamPlayer" parent="."]
[node name="AudioStreamPlayer8" type="AudioStreamPlayer" parent="."]
[node name="AudioStreamPlayer9" type="AudioStreamPlayer" parent="."]
[node name="AudioStreamPlayer10" type="AudioStreamPlayer" parent="."]

View File

@ -5,7 +5,6 @@ var PlayerStats = ResourceLoader.PlayerStats
onready var animation = $Animation
func _on_SaveArea_body_entered(_body):
print(_body)
# PlayerStats.set_max_health()
SoundFx.play_fx("Powerup", 0.3)
animation.play("Save")
SaverLoader.save_game()

View File

@ -1,6 +1,7 @@
extends Powerup
func _pickup():
SoundFx.play_fx("Powerup", 1, -30)
PlayerStats.missiles_unlocked = true
PlayerStats.missiles += 1
queue_free()

View File

@ -123,6 +123,7 @@ func fire_missile():
PlayerStats.missiles -= 1
func create_dust_effect():
SoundFx.play_fx("Step", rand_range(0.6, 1.2), -30)
var dust_position = global_position
dust_position.x += rand_range(-4, 4)
Utils.instance_scene_on_main(DustEffect, dust_position)
@ -146,6 +147,7 @@ func update_snap_vector():
snap_vector = Vector2.DOWN
func jump(force):
SoundFx.play_fx("Jump", rand_range(0.6, 1.4), -20)
Utils.instance_scene_on_main(JumpEffect, global_position)
motion.y = -force
snap_vector = Vector2.ZERO
@ -225,6 +227,7 @@ func get_wall_axis():
func wall_slide_jump_check(wall_axis):
if Input.is_action_just_pressed("ui_select"):
SoundFx.play_fx("Jump", rand_range(0.8, 1.2), -20)
motion.x = wall_axis * max_speed
motion.y = -jump_force/1.25
state = MOVE
@ -262,6 +265,7 @@ func save():
func _on_Hurtbox_hit(damage):
if not invincible:
SoundFx.play_fx("Hurt", 1, -20)
PlayerStats.health -= damage
blinkAnimator.play("Blink")
SaverLoader.custom_data.health = PlayerStats.health

View File

@ -2,4 +2,5 @@ extends "res://Scenes/Objects/Proyectile.gd"
func _ready():
# Do not run _process()
SoundFx.play_fx("Bullet", rand_range(0.6, 1.4), -20)
set_process(false)

View File

@ -6,7 +6,8 @@ const BRICK_LAYER_BIT = 4
func _ready():
pass # Replace with function body.
SoundFx.play_fx("Explosion", 1.5)
pass
func _on_Hitbox_body_entered(body):
if body.get_collision_layer_bit(BRICK_LAYER_BIT):

View File

@ -5,11 +5,14 @@ func _ready():
func _on_StartButton_pressed():
# warning-ignore:return_value_discarded
SoundFx.play_fx("Click", 1, -30)
get_tree().change_scene("res://Scenes/World/World.tscn")
func _on_LoadButton_pressed():
SaverLoader.is_loading = true
SoundFx.play_fx("Click", 1, -30)
get_tree().change_scene("res://Scenes/World/World.tscn")
func _on_QuitButton_pressed():
SoundFx.play_fx("Click", 1, -30)
get_tree().quit()

View File

@ -42,6 +42,7 @@ Utils="*res://Utils.gd"
ResourceLoader="*res://ResourceLoader.gd"
Events="*res://Events.gd"
SaverLoader="*res://SaverLoader.gd"
SoundFx="*res://Scenes/Music/SoundFX.tscn"
[display]