Adds sounds

main
Ervan Lefevre 2 years ago
parent 89d28c7b38
commit 8e2806cb51
  1. BIN
      assets/sounds/ant_collide.wav
  2. 24
      assets/sounds/ant_collide.wav.import
  3. BIN
      assets/sounds/ant_death.wav
  4. 24
      assets/sounds/ant_death.wav.import
  5. BIN
      assets/sounds/ant_spawn.wav
  6. 24
      assets/sounds/ant_spawn.wav.import
  7. BIN
      assets/sounds/gliding.wav
  8. 24
      assets/sounds/gliding.wav.import
  9. BIN
      assets/sounds/grab.wav
  10. 24
      assets/sounds/grab.wav.import
  11. BIN
      assets/sounds/jump.wav
  12. 24
      assets/sounds/jump.wav.import
  13. BIN
      assets/sounds/player_death.wav
  14. 24
      assets/sounds/player_death.wav.import
  15. BIN
      assets/sounds/save.wav
  16. 24
      assets/sounds/save.wav.import
  17. BIN
      assets/sounds/water.ogg
  18. 19
      assets/sounds/water.ogg.import
  19. 9
      nodes/npc/npc.gd
  20. 6
      nodes/npc/npc.tscn
  21. 32
      nodes/player/player.gd
  22. 9
      nodes/player/player.tscn
  23. 7
      nodes/triggers/checkpoint.gd
  24. 6
      nodes/triggers/checkpoint.tscn
  25. 3
      scenes/poc.tscn
  26. 7
      scripts/gameplay/rising_level.gd
  27. 10
      scripts/sounds/sound_player.gd

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://crpbhfs3tf868"
path="res://.godot/imported/ant_collide.wav-8fe04ea99cababa8568c2ee94f576ea3.sample"
[deps]
source_file="res://assets/sounds/ant_collide.wav"
dest_files=["res://.godot/imported/ant_collide.wav-8fe04ea99cababa8568c2ee94f576ea3.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://62433r23d6jj"
path="res://.godot/imported/ant_death.wav-9e5cdb8c16bd9ac0297aa773c14d7ec8.sample"
[deps]
source_file="res://assets/sounds/ant_death.wav"
dest_files=["res://.godot/imported/ant_death.wav-9e5cdb8c16bd9ac0297aa773c14d7ec8.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://b3pm1i35sh2g6"
path="res://.godot/imported/ant_spawn.wav-57e4ae21bf802ea156b0184bfd48c33a.sample"
[deps]
source_file="res://assets/sounds/ant_spawn.wav"
dest_files=["res://.godot/imported/ant_spawn.wav-57e4ae21bf802ea156b0184bfd48c33a.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://caiuaqa78f4vq"
path="res://.godot/imported/gliding.wav-aaf969b5a1d3e289a4f34d6fb52d879e.sample"
[deps]
source_file="res://assets/sounds/gliding.wav"
dest_files=["res://.godot/imported/gliding.wav-aaf969b5a1d3e289a4f34d6fb52d879e.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://r7b41q83bkj7"
path="res://.godot/imported/grab.wav-babf53f0023c9a9340b5bf6dc934795d.sample"
[deps]
source_file="res://assets/sounds/grab.wav"
dest_files=["res://.godot/imported/grab.wav-babf53f0023c9a9340b5bf6dc934795d.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://c4kxl7echq278"
path="res://.godot/imported/jump.wav-395b727cde98999423d5c020c9c3492f.sample"
[deps]
source_file="res://assets/sounds/jump.wav"
dest_files=["res://.godot/imported/jump.wav-395b727cde98999423d5c020c9c3492f.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://djrv1ebrjl4av"
path="res://.godot/imported/player_death.wav-679939ff88887eb6c51646b2e7678a35.sample"
[deps]
source_file="res://assets/sounds/player_death.wav"
dest_files=["res://.godot/imported/player_death.wav-679939ff88887eb6c51646b2e7678a35.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://crt205xmd8i21"
path="res://.godot/imported/save.wav-712918628ea8abdab428c4a136de763b.sample"
[deps]
source_file="res://assets/sounds/save.wav"
dest_files=["res://.godot/imported/save.wav-712918628ea8abdab428c4a136de763b.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://budru6bclfbqg"
path="res://.godot/imported/water.ogg-27db054bef631a0bb5153860fb1c9f15.oggvorbisstr"
[deps]
source_file="res://assets/sounds/water.ogg"
dest_files=["res://.godot/imported/water.ogg-27db054bef631a0bb5153860fb1c9f15.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

@ -8,6 +8,13 @@ const MINIMUM_STATE_DURATION = 3
const STATES = ['panic', 'dead']
const QUEUE_FREE_DELAY = 10
const SOUNDS = {
"spawn": {"asset": preload("res://assets/sounds/ant_spawn.wav"), "volume": -20},
"die": {"asset": preload("res://assets/sounds/ant_death.wav"), "volume": 0.5},
}
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var direction = 0
var rising_speed = 0
@ -16,6 +23,7 @@ var rising_speed = 0
func _ready():
pick_new_direction()
$fsm.set_states(STATES)
$sound_player.play_sound(SOUNDS["spawn"])
func panic_state(delta):
if is_on_wall():
@ -47,6 +55,7 @@ func dead_state(_delta):
func die(level_speed):
$fsm.set_next_state('dead')
$sound_player.play_sound(SOUNDS["die"])
rising_speed = level_speed

@ -1,8 +1,9 @@
[gd_scene load_steps=5 format=3 uid="uid://dvx48q5ecyxjs"]
[gd_scene load_steps=6 format=3 uid="uid://dvx48q5ecyxjs"]
[ext_resource type="Script" path="res://nodes/npc/npc.gd" id="1_38jh5"]
[ext_resource type="Texture2D" uid="uid://bm258xfujps7e" path="res://nodes/npc/npc.png" id="1_hgsqd"]
[ext_resource type="Script" path="res://scripts/ia/fsm.gd" id="3_vhp64"]
[ext_resource type="Script" path="res://scripts/sounds/sound_player.gd" id="4_jgt57"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_f223n"]
radius = 6.0
@ -22,3 +23,6 @@ texture = ExtResource("1_hgsqd")
[node name="fsm" type="Node2D" parent="." node_paths=PackedStringArray("root")]
script = ExtResource("3_vhp64")
root = NodePath("..")
[node name="sound_player" type="AudioStreamPlayer2D" parent="."]
script = ExtResource("4_jgt57")

@ -4,6 +4,9 @@ class_name Player
@export_file('*.tscn') var LOSE_SCREEN;
@onready var sound_player = $sound_player
@onready var gliding_player = $gliding_player
const SPEED = 100.0
const JUMP_VELOCITY = 200.0
const APNEA_DURATION = 10
@ -41,6 +44,13 @@ var can_grab_obstacles = {
"swim": true
}
const SOUNDS = {
"death": {"asset": preload("res://assets/sounds/player_death.wav"), "volume": 0.5},
"jump": {"asset": preload("res://assets/sounds/jump.wav"), "volume": 0.5},
"grab": {"asset": preload("res://assets/sounds/grab.wav"), "volume": 0.5},
"gliding": {"asset": preload("res://assets/sounds/gliding.wav"), "volume": -40},
}
@onready var grab_ray = get_node('oriented_container/grab_ray')
@onready var sprite = get_node('oriented_container/sprite')
@ -55,6 +65,7 @@ func _ready():
$fsm.set_states(STATES)
add_to_group("player")
g_game_state.restore_checkpoint.connect(on_restore_checkpoint)
gliding_player.finished.connect(on_gliding_sound_finished)
func _exit_tree():
g_game_state.restore_checkpoint.disconnect(on_restore_checkpoint)
@ -95,6 +106,7 @@ func walk_state(_delta):
func on_enter_jump_state():
if is_on_floor():
velocity.y = -JUMP_VELOCITY
sound_player.play_sound(SOUNDS["jump"])
func jump_state(_delta):
var direction = Input.get_axis("player_left", "player_right")
@ -103,7 +115,7 @@ func jump_state(_delta):
velocity.x = move_toward(velocity.x, direction * SPEED, SPEED)
if is_on_floor():
if is_on_floor() and velocity.y > 0:
if direction:
$fsm.set_next_state("walk")
else:
@ -113,6 +125,9 @@ func jump_state(_delta):
if is_on_wall() || (is_on_ceiling() ):
$fsm.set_next_state("climb")
func on_exit_jump_state():
sound_player.stop_sound()
func on_enter_climb_state():
velocity = Vector2(0, 0)
@ -150,10 +165,19 @@ func after_state(delta):
if can_grab_obstacles[$fsm.current_state] == true:
handle_grab()
handle_glide()
handle_sprite_orientation()
func handle_glide():
if Input.is_action_just_pressed('player_jump'):
gliding_player.play_sound(SOUNDS["gliding"])
if Input.is_action_just_released('player_jump'):
gliding_player.stop_sound()
func handle_gravity(delta):
var gravity_delta = gravity
if velocity.y > 0:
if Input.is_action_pressed('player_jump'):
gravity_delta = WORLD_GRAVITY / 10
@ -182,6 +206,7 @@ func do_grab(obstacle):
grabbed_obstacle = obstacle
obstacle.grabbed($oriented_container)
sound_player.play_sound(SOUNDS["grab"])
func drop_obstacle():
@ -245,6 +270,7 @@ func unswim():
func die():
$fsm.set_next_state("die")
sound_player.play_sound(SOUNDS["death"])
func is_dead():
return $fsm.current_state == "die"
@ -262,3 +288,7 @@ func die_state(_delta):
func on_restore_checkpoint(_level_rising):
global_position = g_game_state.player_position_at_checkpoint
func on_gliding_sound_finished():
if Input.is_action_pressed('player_jump'):
gliding_player.play_sound(SOUNDS["gliding"])

@ -1,8 +1,9 @@
[gd_scene load_steps=8 format=3 uid="uid://c5rmt3jeffjx7"]
[gd_scene load_steps=9 format=3 uid="uid://c5rmt3jeffjx7"]
[ext_resource type="Script" path="res://nodes/player/player.gd" id="1_exx2i"]
[ext_resource type="Texture2D" uid="uid://cm4rn4vgyjd1b" path="res://nodes/player/temp.png" id="1_s33dc"]
[ext_resource type="Script" path="res://scripts/ia/fsm.gd" id="2_ix1o4"]
[ext_resource type="Script" path="res://scripts/sounds/sound_player.gd" id="4_jraxp"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_w17ly"]
radius = 9.0
@ -74,3 +75,9 @@ autoplay = "zoom_in"
libraries = {
"": SubResource("AnimationLibrary_t0d07")
}
[node name="sound_player" type="AudioStreamPlayer2D" parent="."]
script = ExtResource("4_jraxp")
[node name="gliding_player" type="AudioStreamPlayer2D" parent="."]
script = ExtResource("4_jraxp")

@ -1,11 +1,16 @@
extends Area2D
const sound = preload('res://assets/sounds/save.wav')
# Called when the node enters the scene tree for the first time.
func _ready():
body_entered.connect(on_body_entered)
$sound_player.finished.connect(on_sound_finished)
func on_body_entered(body):
if body.is_in_group('player'):
g_game_state.checkpoint(body.global_position)
queue_free()
$sound_player.play_sound({"asset": sound, "volume": 0})
func on_sound_finished():
queue_free()

@ -1,6 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://cjuqvtp3lhsuc"]
[gd_scene load_steps=3 format=3 uid="uid://cjuqvtp3lhsuc"]
[ext_resource type="Script" path="res://nodes/triggers/checkpoint.gd" id="1_v47vq"]
[ext_resource type="Script" path="res://scripts/sounds/sound_player.gd" id="2_o0bri"]
[node name="checkpoint" type="Area2D"]
script = ExtResource("1_v47vq")
[node name="sound_player" type="AudioStreamPlayer2D" parent="."]
script = ExtResource("2_o0bri")

@ -271,6 +271,9 @@ position = Vector2(72, -424)
scale = Vector2(2, 2)
texture = ExtResource("5_8geoi")
[node name="audio" type="AudioStreamPlayer2D" parent="water_level"]
position = Vector2(376, -928)
[node name="triggers" type="Node2D" parent="."]
[node name="level_1" parent="triggers" node_paths=PackedStringArray("ENABLED_NODES", "UI") instance=ExtResource("5_7efj6")]

@ -4,6 +4,8 @@ class_name RisingLevel
@export var RISING_SPEED = 30
const FORCE_CHECK_FREQUENCY = 5
const sound = preload('res://assets/sounds/water.ogg')
var duration = 0
func _enter_tree():
@ -13,11 +15,16 @@ func _ready():
body_entered.connect(_body_entered)
area_entered.connect(_area_entered)
body_exited.connect(_body_exited)
$audio.stream = sound
$audio.play()
func _exit_tree():
g_game_state.restore_checkpoint.disconnect(on_restore_checkpoint)
func _physics_process(delta):
if $sound.is_playing() == false:
$audio.play()
$shape.position.y -= RISING_SPEED * delta
self.position = self.position
g_game_state.save_level_rising_height($shape.position.y)

@ -0,0 +1,10 @@
extends AudioStreamPlayer2D
func play_sound(asset_config):
stream = asset_config['asset']
volume_db = asset_config['volume']
play()
func stop_sound():
stop()
Loading…
Cancel
Save