Skip to content

Commit

Permalink
~56 enemy hit sound
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-cho committed Jun 8, 2024
1 parent 8db6c5f commit 9d68532
Show file tree
Hide file tree
Showing 20 changed files with 198 additions and 18 deletions.
Binary file added assets/audio/footstep_carpet_000.ogg
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/audio/footstep_carpet_000.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://ckjo8r6fns8s1"
path="res://.godot/imported/footstep_carpet_000.ogg-7fc69e178033a1e9e6d523b3ad5d8c64.oggvorbisstr"

[deps]

source_file="res://assets/audio/footstep_carpet_000.ogg"
dest_files=["res://.godot/imported/footstep_carpet_000.ogg-7fc69e178033a1e9e6d523b3ad5d8c64.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file added assets/audio/footstep_carpet_001.ogg
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/audio/footstep_carpet_001.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://bhxo10h1q3e2"
path="res://.godot/imported/footstep_carpet_001.ogg-55367f95ccce42b17c65bfcc70446821.oggvorbisstr"

[deps]

source_file="res://assets/audio/footstep_carpet_001.ogg"
dest_files=["res://.godot/imported/footstep_carpet_001.ogg-55367f95ccce42b17c65bfcc70446821.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file added assets/audio/footstep_carpet_002.ogg
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/audio/footstep_carpet_002.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://dycvhorndvf1c"
path="res://.godot/imported/footstep_carpet_002.ogg-7f50e85f431176a9e6e1f0fee6f5f006.oggvorbisstr"

[deps]

source_file="res://assets/audio/footstep_carpet_002.ogg"
dest_files=["res://.godot/imported/footstep_carpet_002.ogg-7f50e85f431176a9e6e1f0fee6f5f006.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file added assets/audio/footstep_carpet_003.ogg
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/audio/footstep_carpet_003.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://dqqkhujcgssj6"
path="res://.godot/imported/footstep_carpet_003.ogg-225d34540a8b097baaad7e189ede3b9a.oggvorbisstr"

[deps]

source_file="res://assets/audio/footstep_carpet_003.ogg"
dest_files=["res://.godot/imported/footstep_carpet_003.ogg-225d34540a8b097baaad7e189ede3b9a.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file added assets/audio/footstep_carpet_004.ogg
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/audio/footstep_carpet_004.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://bmnew52u2j6r5"
path="res://.godot/imported/footstep_carpet_004.ogg-d01a52dedb8b8b55b92c79ed733fb23f.oggvorbisstr"

[deps]

source_file="res://assets/audio/footstep_carpet_004.ogg"
dest_files=["res://.godot/imported/footstep_carpet_004.ogg-d01a52dedb8b8b55b92c79ed733fb23f.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
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=3 uid="uid://b8tt7dvk5p3il"]

[resource]
bus/1/name = &"sfx"
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 = &"music"
bus/2/solo = false
bus/2/mute = false
bus/2/bypass_fx = false
bus/2/volume_db = 0.0
bus/2/send = &"Master"
1 change: 1 addition & 0 deletions scenes/component/death_component.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ func on_died():

global_position = spawn_position
$AnimationPlayer.play("default")
$HitRandomAudioPlayerComponent.play_random()
42 changes: 26 additions & 16 deletions scenes/component/death_component.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
[gd_scene load_steps=9 format=3 uid="uid://cjxiijis5jocn"]
[gd_scene load_steps=15 format=3 uid="uid://cjxiijis5jocn"]

[ext_resource type="Texture2D" uid="uid://cc6p0wg3ww2jf" path="res://scenes/game_object/basic_enemy/basic_enemy.png" id="1_nxw5s"]
[ext_resource type="Script" path="res://scenes/component/death_component.gd" id="1_yodoj"]
[ext_resource type="PackedScene" uid="uid://bh478361trp2r" path="res://scenes/component/random_audio_stream_player_2d_component.tscn" id="3_3eut6"]
[ext_resource type="AudioStream" uid="uid://ckjo8r6fns8s1" path="res://assets/audio/footstep_carpet_000.ogg" id="4_ub4hc"]
[ext_resource type="AudioStream" uid="uid://bhxo10h1q3e2" path="res://assets/audio/footstep_carpet_001.ogg" id="5_ydvir"]
[ext_resource type="AudioStream" uid="uid://dycvhorndvf1c" path="res://assets/audio/footstep_carpet_002.ogg" id="6_sadcd"]
[ext_resource type="AudioStream" uid="uid://dqqkhujcgssj6" path="res://assets/audio/footstep_carpet_003.ogg" id="7_vapdh"]
[ext_resource type="AudioStream" uid="uid://bmnew52u2j6r5" path="res://assets/audio/footstep_carpet_004.ogg" id="8_6pjh8"]

[sub_resource type="Animation" id="Animation_53x1v"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("GPUParticles2D:emitting")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}

[sub_resource type="Animation" id="Animation_mmhuk"]
resource_name = "default"
Expand Down Expand Up @@ -32,21 +53,6 @@ tracks/1/keys = {
}]
}

[sub_resource type="Animation" id="Animation_53x1v"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("GPUParticles2D:emitting")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}

[sub_resource type="AnimationLibrary" id="AnimationLibrary_j3x6f"]
_data = {
"RESET": SubResource("Animation_53x1v"),
Expand Down Expand Up @@ -88,3 +94,7 @@ lifetime = 0.5
one_shot = true
fixed_fps = 0
interpolate = false

[node name="HitRandomAudioPlayerComponent" parent="." instance=ExtResource("3_3eut6")]
max_distance = 300.0
streams = Array[AudioStream]([ExtResource("4_ub4hc"), ExtResource("5_ydvir"), ExtResource("6_sadcd"), ExtResource("7_vapdh"), ExtResource("8_6pjh8")])
4 changes: 4 additions & 0 deletions scenes/component/hurtbox_component.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
extends Area2D
class_name HurtboxComponent

signal hit

@export var health_component: HealthComponent

var floating_text_scene = preload("res://scenes/ui/floating_text.tscn")
Expand Down Expand Up @@ -30,3 +32,5 @@ func on_area_entered(other_area: Area2D):
if is_equal_approx(hitbox_component.damage, int(hitbox_component.damage)):
fmt_string = "%0.0f"
floating_text.start(fmt_string % hitbox_component.damage)

hit.emit()
12 changes: 12 additions & 0 deletions scenes/component/random_audio_stream_player_2d_component.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
extends AudioStreamPlayer2D
class_name RandomAudioStreamPlayer2DComponent

@export var streams: Array[AudioStream]


func play_random():
if streams == null || streams.is_empty():
return

stream = streams.pick_random()
play()
7 changes: 7 additions & 0 deletions scenes/component/random_audio_stream_player_2d_component.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://bh478361trp2r"]

[ext_resource type="Script" path="res://scenes/component/random_audio_stream_player_2d_component.gd" id="1_bhpwy"]

[node name="RandomAudioStreamPlayer2DComponent" type="AudioStreamPlayer2D"]
bus = &"sfx"
script = ExtResource("1_bhpwy")
8 changes: 8 additions & 0 deletions scenes/game_object/basic_enemy/basic_enemy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ extends CharacterBody2D
@onready var velocity_component: VelocityComponent = $VelocityComponent


func _ready():
$HurtboxComponent.hit.connect(on_hit)


func _process(delta):
velocity_component.accelerate_to_player()
velocity_component.move(self)

var move_sign = sign(velocity.x)
if move_sign != 0:
visuals.scale = Vector2(-move_sign, 1)


func on_hit():
$HitRandomAudioPlayerComponent.play_random()
12 changes: 11 additions & 1 deletion scenes/game_object/basic_enemy/basic_enemy.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=3 uid="uid://bses7vk27cfvt"]
[gd_scene load_steps=22 format=3 uid="uid://bses7vk27cfvt"]

[ext_resource type="Script" path="res://scenes/game_object/basic_enemy/basic_enemy.gd" id="1_gpcli"]
[ext_resource type="Texture2D" uid="uid://cc6p0wg3ww2jf" path="res://scenes/game_object/basic_enemy/basic_enemy.png" id="1_m80w1"]
Expand All @@ -9,6 +9,12 @@
[ext_resource type="PackedScene" uid="uid://cjxiijis5jocn" path="res://scenes/component/death_component.tscn" id="4_j8jii"]
[ext_resource type="Shader" path="res://scenes/component/hit_flash_component.gdshader" id="6_jhg8v"]
[ext_resource type="PackedScene" uid="uid://bkkq5ohgbnkxw" path="res://scenes/component/hit_flash_component.tscn" id="7_4kqgf"]
[ext_resource type="PackedScene" uid="uid://bh478361trp2r" path="res://scenes/component/random_audio_stream_player_2d_component.tscn" id="10_74ju1"]
[ext_resource type="AudioStream" uid="uid://ckjo8r6fns8s1" path="res://assets/audio/footstep_carpet_000.ogg" id="10_d8kjc"]
[ext_resource type="AudioStream" uid="uid://bhxo10h1q3e2" path="res://assets/audio/footstep_carpet_001.ogg" id="12_2b1bb"]
[ext_resource type="AudioStream" uid="uid://dycvhorndvf1c" path="res://assets/audio/footstep_carpet_002.ogg" id="13_oy0ft"]
[ext_resource type="AudioStream" uid="uid://dqqkhujcgssj6" path="res://assets/audio/footstep_carpet_003.ogg" id="14_6oeop"]
[ext_resource type="AudioStream" uid="uid://bmnew52u2j6r5" path="res://assets/audio/footstep_carpet_004.ogg" id="15_yavv3"]

[sub_resource type="Animation" id="Animation_lm0tv"]
length = 0.001
Expand Down Expand Up @@ -112,6 +118,10 @@ hit_flash_material = SubResource("ShaderMaterial_ollop")
health_component = NodePath("../HealthComponent")
sprite = NodePath("../Visuals/Sprite2D")

[node name="HitRandomAudioPlayerComponent" parent="." instance=ExtResource("10_74ju1")]
max_distance = 300.0
streams = Array[AudioStream]([ExtResource("10_d8kjc"), ExtResource("12_2b1bb"), ExtResource("13_oy0ft"), ExtResource("14_6oeop"), ExtResource("15_yavv3")])

[node name="HurtboxComponent" parent="." node_paths=PackedStringArray("health_component") instance=ExtResource("4_e2gan")]
health_component = NodePath("../HealthComponent")

Expand Down
8 changes: 8 additions & 0 deletions scenes/game_object/wizard_enemy/wizard_enemy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ extends CharacterBody2D
@onready var velocity_component: VelocityComponent = $VelocityComponent


func _ready():
$HurtboxComponent.hit.connect(on_hit)


func _process(delta):
velocity_component.accelerate_to_player()
velocity_component.move(self)

var move_sign = sign(velocity.x)
if move_sign != 0:
visuals.scale = Vector2(move_sign, 1)


func on_hit():
$HitRandomAudioPlayerComponent.play_random()
12 changes: 11 additions & 1 deletion scenes/game_object/wizard_enemy/wizard_enemy.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=13 format=3 uid="uid://biw4lngphcynu"]
[gd_scene load_steps=19 format=3 uid="uid://biw4lngphcynu"]

[ext_resource type="PackedScene" uid="uid://d32bhk07dm6w8" path="res://scenes/component/health_component.tscn" id="1_5bkfq"]
[ext_resource type="Texture2D" uid="uid://bj74fspmmt8fp" path="res://scenes/game_object/wizard_enemy/wizard_enemy.png" id="1_beb02"]
Expand All @@ -9,6 +9,12 @@
[ext_resource type="PackedScene" uid="uid://ci3popyfx4vbv" path="res://scenes/component/vial_drop_component.tscn" id="4_blfg5"]
[ext_resource type="PackedScene" uid="uid://bkkq5ohgbnkxw" path="res://scenes/component/hit_flash_component.tscn" id="5_ytbt1"]
[ext_resource type="Shader" path="res://scenes/component/hit_flash_component.gdshader" id="6_qmngi"]
[ext_resource type="PackedScene" uid="uid://bh478361trp2r" path="res://scenes/component/random_audio_stream_player_2d_component.tscn" id="8_xc8j1"]
[ext_resource type="AudioStream" uid="uid://ckjo8r6fns8s1" path="res://assets/audio/footstep_carpet_000.ogg" id="9_c6s0t"]
[ext_resource type="AudioStream" uid="uid://bhxo10h1q3e2" path="res://assets/audio/footstep_carpet_001.ogg" id="10_8bpt1"]
[ext_resource type="AudioStream" uid="uid://dycvhorndvf1c" path="res://assets/audio/footstep_carpet_002.ogg" id="11_ujfiq"]
[ext_resource type="AudioStream" uid="uid://dqqkhujcgssj6" path="res://assets/audio/footstep_carpet_003.ogg" id="12_66386"]
[ext_resource type="AudioStream" uid="uid://bmnew52u2j6r5" path="res://assets/audio/footstep_carpet_004.ogg" id="13_ixqs1"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_4r80n"]
resource_local_to_scene = true
Expand Down Expand Up @@ -46,6 +52,10 @@ hit_flash_material = SubResource("ShaderMaterial_4r80n")
health_component = NodePath("../HealthComponent")
sprite = NodePath("../Visuals/Sprite2D")

[node name="HitRandomAudioPlayerComponent" parent="." instance=ExtResource("8_xc8j1")]
max_distance = 300.0
streams = Array[AudioStream]([ExtResource("9_c6s0t"), ExtResource("10_8bpt1"), ExtResource("11_ujfiq"), ExtResource("12_66386"), ExtResource("13_ixqs1")])

[node name="HurtboxComponent" parent="." node_paths=PackedStringArray("health_component") instance=ExtResource("3_2ak7l")]
health_component = NodePath("../HealthComponent")

Expand Down

0 comments on commit 9d68532

Please sign in to comment.