From 074dbb06dcb88f262b9699b9142f031139a2b5cc Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Fri, 22 Nov 2024 12:26:25 -0700 Subject: [PATCH] Added shot SFX --- asset_credits.org | 88 +++++++++++++++++++++++ asset_dev/audio/drive4.wav | 3 + assets/sound/sfx/player/drive1.wav | 3 + assets/sound/sfx/player/drive1.wav.import | 24 +++++++ assets/sound/sfx/player/drive2.wav | 3 + assets/sound/sfx/player/drive2.wav.import | 24 +++++++ assets/sound/sfx/player/drive3.wav | 3 + assets/sound/sfx/player/drive3.wav.import | 24 +++++++ assets/sound/sfx/player/drive4.wav | 3 + assets/sound/sfx/player/drive4.wav.import | 24 +++++++ assets/sound/sfx/player/hole.wav | 3 + assets/sound/sfx/player/hole.wav.import | 24 +++++++ assets/sound/sfx/player/putt1.wav | 3 + assets/sound/sfx/player/putt1.wav.import | 24 +++++++ default_bus_layout.tres | 15 ++++ src/game/game.tscn | 1 + src/player/shot_setup/shot_setup.gd | 10 ++- src/player/shot_setup/shot_setup.tscn | 46 +++++++++++- src/player/shot_setup/shot_sfx.gd | 27 +++++++ 19 files changed, 350 insertions(+), 2 deletions(-) create mode 100644 asset_credits.org create mode 100644 asset_dev/audio/drive4.wav create mode 100644 assets/sound/sfx/player/drive1.wav create mode 100644 assets/sound/sfx/player/drive1.wav.import create mode 100644 assets/sound/sfx/player/drive2.wav create mode 100644 assets/sound/sfx/player/drive2.wav.import create mode 100644 assets/sound/sfx/player/drive3.wav create mode 100644 assets/sound/sfx/player/drive3.wav.import create mode 100644 assets/sound/sfx/player/drive4.wav create mode 100644 assets/sound/sfx/player/drive4.wav.import create mode 100644 assets/sound/sfx/player/hole.wav create mode 100644 assets/sound/sfx/player/hole.wav.import create mode 100644 assets/sound/sfx/player/putt1.wav create mode 100644 assets/sound/sfx/player/putt1.wav.import create mode 100644 default_bus_layout.tres create mode 100644 src/player/shot_setup/shot_sfx.gd diff --git a/asset_credits.org b/asset_credits.org new file mode 100644 index 0000000..fe7aeb5 --- /dev/null +++ b/asset_credits.org @@ -0,0 +1,88 @@ +GFOLF: Combat Golf Action +Asset credits + +* Graphics + +** Clear Sea Water + +*** Retrieved from https://www.the3rdsequence.com/texturedb/texture/44/clear+sea+water/ + +*** Author: the3rdSequence + +*** License: CC BY 4.0 + +* Fonts + +** Dokdo + +*** Retrieved from https://fonts.google.com/specimen/Dokdo + +*** Author: FONTRIX + +*** License: OFL 1.1 + +** Geo + +*** Retrieved from https://fonts.google.com/specimen/Geo + +*** Author: Ben Weiner + +*** License: OFL 1.1 + +** Racing Sans One + +*** Retrieved from https://fonts.google.com/specimen/Racing+Sans+One + +*** Author: Impallari Type + +*** License: OFL 1.1 + +* Sound + +** drive1.wav + +*** Retrieved from https://freesound.org/people/zolopher/sounds/75203/ + +*** Author: zolopher + +*** License: CC0 + +** drive2.wav + +*** Retrieved from https://freesound.org/people/zolopher/sounds/75214/ + +*** Author: zolopher + +*** License: CC0 + +** drive3.wav + +*** Retrieved from https://freesound.org/people/zolopher/sounds/75204/ + +*** Author: zolopher + +*** License: CC0 + +** drive4.wav + +*** Retrieved from https://freesound.org/people/13FPanska_Marval_Lukas/sounds/379328/ + +*** Author: 13FPanska_Marval_Lukas + +*** License: CC0 + +** hole.wav + +*** Retrieved from https://freesound.org/people/inbeeld/sounds/21878/ + +*** Author: inbeeld + +*** License: CC0 + +** putt1.wav + +*** Retrieved from https://freesound.org/people/lmbubec/sounds/119451/ + +*** Author: lmbubec + +*** License: CC0 diff --git a/asset_dev/audio/drive4.wav b/asset_dev/audio/drive4.wav new file mode 100644 index 0000000..85ffff9 --- /dev/null +++ b/asset_dev/audio/drive4.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8db200adf1f09733b9075392bd7712396af1f3283e7a60750135a2508796d689 +size 932872 diff --git a/assets/sound/sfx/player/drive1.wav b/assets/sound/sfx/player/drive1.wav new file mode 100644 index 0000000..8dc0fe6 --- /dev/null +++ b/assets/sound/sfx/player/drive1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:322ad0ce959fce91b3cd3b037d195e40539a4a539e3b3f58c35a60e8d2cf6368 +size 50382 diff --git a/assets/sound/sfx/player/drive1.wav.import b/assets/sound/sfx/player/drive1.wav.import new file mode 100644 index 0000000..0ea6819 --- /dev/null +++ b/assets/sound/sfx/player/drive1.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cllhgumv1fkju" +path="res://.godot/imported/drive1.wav-37a2ebf3422caee7737ed14d066e94ec.sample" + +[deps] + +source_file="res://assets/sound/sfx/player/drive1.wav" +dest_files=["res://.godot/imported/drive1.wav-37a2ebf3422caee7737ed14d066e94ec.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 diff --git a/assets/sound/sfx/player/drive2.wav b/assets/sound/sfx/player/drive2.wav new file mode 100644 index 0000000..59a328a --- /dev/null +++ b/assets/sound/sfx/player/drive2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bca8b00b3fd5da73846c5bc982095dc0c7924f7b13aa4514c551a4732de7f084 +size 26960 diff --git a/assets/sound/sfx/player/drive2.wav.import b/assets/sound/sfx/player/drive2.wav.import new file mode 100644 index 0000000..58a7046 --- /dev/null +++ b/assets/sound/sfx/player/drive2.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c8vouau0488fh" +path="res://.godot/imported/drive2.wav-40bb0e3487bcffb646233c3e9c9465a1.sample" + +[deps] + +source_file="res://assets/sound/sfx/player/drive2.wav" +dest_files=["res://.godot/imported/drive2.wav-40bb0e3487bcffb646233c3e9c9465a1.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 diff --git a/assets/sound/sfx/player/drive3.wav b/assets/sound/sfx/player/drive3.wav new file mode 100644 index 0000000..c10f0c6 --- /dev/null +++ b/assets/sound/sfx/player/drive3.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70de74f42fbba88f8684fe6f5ed9ad7fa360f3891adaf9951bfc94bbf7f26ac1 +size 25268 diff --git a/assets/sound/sfx/player/drive3.wav.import b/assets/sound/sfx/player/drive3.wav.import new file mode 100644 index 0000000..37952d1 --- /dev/null +++ b/assets/sound/sfx/player/drive3.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cskhg5l86yvkw" +path="res://.godot/imported/drive3.wav-cc637d549cbfcb948c40cc777dca0600.sample" + +[deps] + +source_file="res://assets/sound/sfx/player/drive3.wav" +dest_files=["res://.godot/imported/drive3.wav-cc637d549cbfcb948c40cc777dca0600.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 diff --git a/assets/sound/sfx/player/drive4.wav b/assets/sound/sfx/player/drive4.wav new file mode 100644 index 0000000..85ffff9 --- /dev/null +++ b/assets/sound/sfx/player/drive4.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8db200adf1f09733b9075392bd7712396af1f3283e7a60750135a2508796d689 +size 932872 diff --git a/assets/sound/sfx/player/drive4.wav.import b/assets/sound/sfx/player/drive4.wav.import new file mode 100644 index 0000000..932da30 --- /dev/null +++ b/assets/sound/sfx/player/drive4.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bkd8py2e7yfat" +path="res://.godot/imported/drive4.wav-b79415fd0bf467327ac8875e2a0a8c6a.sample" + +[deps] + +source_file="res://assets/sound/sfx/player/drive4.wav" +dest_files=["res://.godot/imported/drive4.wav-b79415fd0bf467327ac8875e2a0a8c6a.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 diff --git a/assets/sound/sfx/player/hole.wav b/assets/sound/sfx/player/hole.wav new file mode 100644 index 0000000..11b42fe --- /dev/null +++ b/assets/sound/sfx/player/hole.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49a3257d27167d59962c7e27719dcee9d9061ae0502aee7ab7a6fa1fb97b0938 +size 384848 diff --git a/assets/sound/sfx/player/hole.wav.import b/assets/sound/sfx/player/hole.wav.import new file mode 100644 index 0000000..e2815be --- /dev/null +++ b/assets/sound/sfx/player/hole.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://b1pnbcsi0jrlf" +path="res://.godot/imported/hole.wav-084f4e3629b5927d5a661d5f59a9d3e7.sample" + +[deps] + +source_file="res://assets/sound/sfx/player/hole.wav" +dest_files=["res://.godot/imported/hole.wav-084f4e3629b5927d5a661d5f59a9d3e7.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 diff --git a/assets/sound/sfx/player/putt1.wav b/assets/sound/sfx/player/putt1.wav new file mode 100644 index 0000000..54b7e96 --- /dev/null +++ b/assets/sound/sfx/player/putt1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88f0b4be20894ab483c653e692b92cfeffc20451b7d18a73ca4ce66e47c970d7 +size 322912 diff --git a/assets/sound/sfx/player/putt1.wav.import b/assets/sound/sfx/player/putt1.wav.import new file mode 100644 index 0000000..a055cb7 --- /dev/null +++ b/assets/sound/sfx/player/putt1.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://j54ssyodqnn3" +path="res://.godot/imported/putt1.wav-f5b4cf94df3968330049619e9410ebd1.sample" + +[deps] + +source_file="res://assets/sound/sfx/player/putt1.wav" +dest_files=["res://.godot/imported/putt1.wav-f5b4cf94df3968330049619e9410ebd1.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 diff --git a/default_bus_layout.tres b/default_bus_layout.tres new file mode 100644 index 0000000..2c4ae19 --- /dev/null +++ b/default_bus_layout.tres @@ -0,0 +1,15 @@ +[gd_resource type="AudioBusLayout" format=3 uid="uid://cwxndi28bii8d"] + +[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" diff --git a/src/game/game.tscn b/src/game/game.tscn index 979f165..50c56f6 100644 --- a/src/game/game.tscn +++ b/src/game/game.tscn @@ -189,6 +189,7 @@ handle_input_locally = false msaa_3d = 3 screen_space_aa = 1 use_taa = true +audio_listener_enable_3d = true size = Vector2i(1920, 1080) render_target_update_mode = 4 diff --git a/src/player/shot_setup/shot_setup.gd b/src/player/shot_setup/shot_setup.gd index 92562d4..a335203 100644 --- a/src/player/shot_setup/shot_setup.gd +++ b/src/player/shot_setup/shot_setup.gd @@ -140,6 +140,7 @@ var _tracking_camera: OrbitalCamera @onready var character: CharacterController = $PlayerPivot/GfolfGirl @onready var shot_animation: AnimationPlayer = %ShotAnimation +@onready var shot_sfx: ShotSFX = %ShotSFX @onready var arrow: Node3D = %Arrow @onready var arrow_pivot: Node3D = %ArrowPivot @@ -230,6 +231,10 @@ func is_active() -> bool: return phase != Phase.FINISHED +func is_shot_good() -> bool: + return abs(shot_curve) <= NICE_THRESHOLD + + func finish_downswing() -> void: phase = Phase.SHOT @@ -270,6 +275,9 @@ func take_shot() -> void: game_ball.freeze = false game_ball.apply_impulse(impulse, offset) + # Play SFX + shot_sfx.play_shot_sfx(club, is_shot_good(), shot_power) + # Use a ball if a limited type is selected if player.get_balls(ball_type) > 0: player.mutate_balls(ball_type, -1) @@ -441,7 +449,7 @@ func _on_phase_change(new_phase: Phase) -> void: if perfect_aim: shot_curve = 0.0 - if abs(shot_curve) <= NICE_THRESHOLD: + if is_shot_good(): hud.play_nice_animation() if not driving_range: diff --git a/src/player/shot_setup/shot_setup.tscn b/src/player/shot_setup/shot_setup.tscn index 424c453..58ecbe7 100644 --- a/src/player/shot_setup/shot_setup.tscn +++ b/src/player/shot_setup/shot_setup.tscn @@ -1,15 +1,38 @@ -[gd_scene load_steps=23 format=3 uid="uid://cy7t2tc4y3b4"] +[gd_scene load_steps=32 format=3 uid="uid://cy7t2tc4y3b4"] [ext_resource type="Script" path="res://src/player/shot_setup/shot_setup.gd" id="1_r6ei4"] [ext_resource type="Script" path="res://src/player/shot_setup/ball_point.gd" id="2_e6i3g"] [ext_resource type="PackedScene" uid="uid://c2k88ns0h5ie1" path="res://src/ui/3d/arrow/arrow.tscn" id="2_s70wl"] +[ext_resource type="Script" path="res://src/player/shot_setup/shot_sfx.gd" id="3_7vs2d"] [ext_resource type="PackedScene" uid="uid://1s3gywmoi20e" path="res://src/characters/player_characters/gfolf_girl/gfolf_girl.tscn" id="3_e4aur"] +[ext_resource type="AudioStream" uid="uid://cllhgumv1fkju" path="res://assets/sound/sfx/player/drive1.wav" id="3_em3cj"] +[ext_resource type="AudioStream" uid="uid://c8vouau0488fh" path="res://assets/sound/sfx/player/drive2.wav" id="4_4cajc"] [ext_resource type="PackedScene" uid="uid://fht6j87o8ecr" path="res://src/ui/3d/projectile_arc/projectile_arc.tscn" id="4_ry2ho"] +[ext_resource type="AudioStream" uid="uid://cskhg5l86yvkw" path="res://assets/sound/sfx/player/drive3.wav" id="5_5lj1j"] +[ext_resource type="AudioStream" uid="uid://bkd8py2e7yfat" path="res://assets/sound/sfx/player/drive4.wav" id="6_1wnu3"] [ext_resource type="PackedScene" uid="uid://dbdul15c4oblg" path="res://src/ui/3d/projected_target.tscn" id="6_mynqj"] +[ext_resource type="AudioStream" uid="uid://j54ssyodqnn3" path="res://assets/sound/sfx/player/putt1.wav" id="7_niyj5"] [ext_resource type="Script" path="res://src/player/shot_setup/hitbox.gd" id="7_uh8kn"] [ext_resource type="Texture2D" uid="uid://2yoipvd107t1" path="res://assets/sprites/dope_explosion/dope_explosion.tres" id="8_5ghmo"] [ext_resource type="FontFile" uid="uid://dsa0oh7c0h4pu" path="res://assets/fonts/Racing_Sans_One/RacingSansOne-Regular.ttf" id="9_y5iv1"] +[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_gh0gi"] +random_pitch = 1.1 +streams_count = 1 +stream_0/stream = ExtResource("3_em3cj") + +[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_7isox"] +random_pitch = 1.1 +streams_count = 3 +stream_0/stream = ExtResource("4_4cajc") +stream_1/stream = ExtResource("5_5lj1j") +stream_2/stream = ExtResource("6_1wnu3") + +[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_wnuop"] +random_pitch = 1.1 +streams_count = 1 +stream_0/stream = ExtResource("7_niyj5") + [sub_resource type="Animation" id="Animation_ug2a7"] length = 0.001 tracks/0/type = "value" @@ -262,6 +285,27 @@ unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.08, 0) script = ExtResource("2_e6i3g") +[node name="ShotSFX" type="Node3D" parent="BallPoint"] +unique_name_in_owner = true +script = ExtResource("3_7vs2d") + +[node name="GoodDriveSFXPlayer" type="AudioStreamPlayer3D" parent="BallPoint/ShotSFX"] +unique_name_in_owner = true +stream = SubResource("AudioStreamRandomizer_gh0gi") +volume_db = -3.0 +bus = &"SFX" + +[node name="BadDriveSFXPlayer" type="AudioStreamPlayer3D" parent="BallPoint/ShotSFX"] +unique_name_in_owner = true +stream = SubResource("AudioStreamRandomizer_7isox") +volume_db = -1.0 +bus = &"SFX" + +[node name="PuttSFXPlayer" type="AudioStreamPlayer3D" parent="BallPoint/ShotSFX"] +unique_name_in_owner = true +stream = SubResource("AudioStreamRandomizer_wnuop") +bus = &"SFX" + [node name="PlayerPivot" type="Node3D" parent="."] unique_name_in_owner = true diff --git a/src/player/shot_setup/shot_sfx.gd b/src/player/shot_setup/shot_sfx.gd new file mode 100644 index 0000000..fa888c0 --- /dev/null +++ b/src/player/shot_setup/shot_sfx.gd @@ -0,0 +1,27 @@ +class_name ShotSFX extends Node3D +## SFX controller for golf shots + +const BASE_VOLUME := -6.0 +const MAX_VOLUME := -1.0 + +@onready var good_drive_sfx_player: AudioStreamPlayer3D = %GoodDriveSFXPlayer +@onready var bad_drive_sfx_player: AudioStreamPlayer3D = %BadDriveSFXPlayer +@onready var putt_sfx_player: AudioStreamPlayer3D = %PuttSFXPlayer + + +func _attenuate_volume(power: float) -> float: + return lerpf(BASE_VOLUME, MAX_VOLUME, power) + + +func play_shot_sfx(club: Club.Type, good: bool, power: float) -> void: + var player: AudioStreamPlayer3D + match club: + Club.Type.PUTTER: + player = putt_sfx_player + _: + # TODO more varied SFX maybe? + player = good_drive_sfx_player if good else bad_drive_sfx_player + + player.volume_db = _attenuate_volume(power) + print_debug("Playing ", player) + player.play()