Skip to content

Commit

Permalink
Added simple sound effects
Browse files Browse the repository at this point in the history
  • Loading branch information
uheartbeast committed Aug 2, 2022
1 parent 6de04c3 commit abdc7a6
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .import/Hurt.wav-ea3cd1f4037263320fa6dc34457aaf41.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="c96487682612a265491b3d223a9a3fee"
dest_md5="96fe73b02333990e72ef3c10a64c0e7b"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/Jump.wav-cc511575d106a169010147884f828c00.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="d557b22ed97d32612730e847d9baf9f3"
dest_md5="ec18d108d4af8cb251e51523c0ccf403"

Binary file not shown.
2 changes: 1 addition & 1 deletion Hitbox.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ extends Area2D

func _on_Hitbox_body_entered(body):
if body is Player:
get_tree().reload_current_scene()
body.player_die()
6 changes: 6 additions & 0 deletions Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ func climb_state(input):
velocity = input * moveData.CLIMB_SPEED
velocity = move_and_slide(velocity, Vector2.UP)

func player_die():
SoundPlayer.play_sound(SoundPlayer.HURT)
get_tree().reload_current_scene()

func input_jump_release():
if Input.is_action_just_released("ui_up") and velocity.y < moveData.JUMP_RELEASE_FORCE:
velocity.y = moveData.JUMP_RELEASE_FORCE

func input_double_jump():
if Input.is_action_just_pressed("ui_up") and double_jump > 0:
SoundPlayer.play_sound(SoundPlayer.JUMP)
velocity.y = moveData.JUMP_FORCE
double_jump -= 1

Expand All @@ -105,6 +110,7 @@ func reset_double_jump():

func input_jump():
if Input.is_action_just_pressed("ui_up") or buffered_jump:
SoundPlayer.play_sound(SoundPlayer.JUMP)
velocity.y = moveData.JUMP_FORCE
buffered_jump = false

Expand Down
18 changes: 9 additions & 9 deletions PlayerBlueSkin.tres
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

[ext_resource path="res://characters_packed.png" type="Texture" id=1]

[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 48, 0, 24, 24 )

[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 72, 0, 24, 24 )
Expand All @@ -14,12 +18,13 @@ region = Rect2( 48, 0, 24, 24 )
atlas = ExtResource( 1 )
region = Rect2( 72, 0, 24, 24 )

[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 48, 0, 24, 24 )

[resource]
animations = [ {
"frames": [ SubResource( 1 ) ],
"loop": true,
"name": "Idle",
"speed": 5.0
}, {
"frames": [ SubResource( 3 ), SubResource( 4 ) ],
"loop": true,
"name": "Run",
Expand All @@ -29,9 +34,4 @@ animations = [ {
"loop": false,
"name": "Jump",
"speed": 5.0
}, {
"frames": [ SubResource( 1 ) ],
"loop": true,
"name": "Idle",
"speed": 5.0
} ]
Binary file added Sounds/Hurt.wav
Binary file not shown.
21 changes: 21 additions & 0 deletions Sounds/Hurt.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Hurt.wav-ea3cd1f4037263320fa6dc34457aaf41.sample"

[deps]

source_file="res://Sounds/Hurt.wav"
dest_files=[ "res://.import/Hurt.wav-ea3cd1f4037263320fa6dc34457aaf41.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=false
compress/mode=0
Binary file added Sounds/Jump.wav
Binary file not shown.
21 changes: 21 additions & 0 deletions Sounds/Jump.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Jump.wav-cc511575d106a169010147884f828c00.sample"

[deps]

source_file="res://Sounds/Jump.wav"
dest_files=[ "res://.import/Jump.wav-cc511575d106a169010147884f828c00.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=false
compress/mode=0
13 changes: 13 additions & 0 deletions Sounds/SoundPlayer.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extends Node

const HURT = preload("res://Sounds/Hurt.wav")
const JUMP = preload("res://Sounds/Jump.wav")

onready var audioPlayers = $AudioPlayers

func play_sound(sound):
for audioStreamPlayer in audioPlayers.get_children():
if not audioStreamPlayer.playing:
audioStreamPlayer.stream = sound
audioStreamPlayer.play()
break
32 changes: 32 additions & 0 deletions Sounds/SoundPlayer.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://Sounds/SoundPlayer.gd" type="Script" id=1]

[node name="SoundPlayer" type="Node"]
script = ExtResource( 1 )

[node name="AudioPlayers" type="Node" parent="."]

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="AudioPlayers"]
bus = "Sound"

[node name="AudioStreamPlayer2" type="AudioStreamPlayer" parent="AudioPlayers"]
bus = "Sound"

[node name="AudioStreamPlayer3" type="AudioStreamPlayer" parent="AudioPlayers"]
bus = "Sound"

[node name="AudioStreamPlayer4" type="AudioStreamPlayer" parent="AudioPlayers"]
bus = "Sound"

[node name="AudioStreamPlayer5" type="AudioStreamPlayer" parent="AudioPlayers"]
bus = "Sound"

[node name="AudioStreamPlayer6" type="AudioStreamPlayer" parent="AudioPlayers"]
bus = "Sound"

[node name="AudioStreamPlayer7" type="AudioStreamPlayer" parent="AudioPlayers"]
bus = "Sound"

[node name="AudioStreamPlayer8" type="AudioStreamPlayer" parent="AudioPlayers"]
bus = "Sound"
15 changes: 15 additions & 0 deletions default_bus_layout.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[gd_resource type="AudioBusLayout" format=2]

[resource]
bus/1/name = "Music"
bus/1/solo = false
bus/1/mute = false
bus/1/bypass_fx = false
bus/1/volume_db = 0.0
bus/1/send = "Master"
bus/2/name = "Sound"
bus/2/solo = false
bus/2/mute = false
bus/2/bypass_fx = false
bus/2/volume_db = -80.0
bus/2/send = "Master"
4 changes: 4 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ run/main_scene="res://World.tscn"
run/delta_sync_after_draw=true
config/icon="res://icon.png"

[autoload]

SoundPlayer="*res://Sounds/SoundPlayer.tscn"

[display]

window/size/width=320
Expand Down

0 comments on commit abdc7a6

Please sign in to comment.