mirror of
https://github.com/Steffo99/pineapple-surf.git
synced 2024-11-25 09:14:18 +00:00
Add "pop" sound when a crop is ready
This commit is contained in:
parent
b07ba1f25e
commit
e8f757fb3c
7 changed files with 67 additions and 3 deletions
BIN
assets/pop.wav
(Stored with Git LFS)
Normal file
BIN
assets/pop.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
24
assets/pop.wav.import
Normal file
24
assets/pop.wav.import
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://lkftwgdun745"
|
||||||
|
path="res://.godot/imported/pop.wav-6c96098d372cbccab3a694ff4f0bb6a9.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/pop.wav"
|
||||||
|
dest_files=["res://.godot/imported/pop.wav-6c96098d372cbccab3a694ff4f0bb6a9.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
|
|
@ -7,7 +7,9 @@ signal on_complete()
|
||||||
|
|
||||||
@onready var growth_timer: Timer = $GrowthTimer
|
@onready var growth_timer: Timer = $GrowthTimer
|
||||||
@onready var sprout_mesh: MeshInstance3D = $Plant/Sprout
|
@onready var sprout_mesh: MeshInstance3D = $Plant/Sprout
|
||||||
|
@onready var pop_sound: AudioStreamPlayer3D = $Pop
|
||||||
@export var debug_growth: bool = false
|
@export var debug_growth: bool = false
|
||||||
|
@export var debug_growth_offset: float = 0.0;
|
||||||
|
|
||||||
|
|
||||||
func plant():
|
func plant():
|
||||||
|
@ -19,6 +21,8 @@ func plant():
|
||||||
func complete():
|
func complete():
|
||||||
if not growth_timer.is_stopped():
|
if not growth_timer.is_stopped():
|
||||||
growth_timer.stop()
|
growth_timer.stop()
|
||||||
|
print("Playing completition sound...")
|
||||||
|
pop_sound.play_with_random_pitch()
|
||||||
emit_signal("on_complete")
|
emit_signal("on_complete")
|
||||||
if debug_growth:
|
if debug_growth:
|
||||||
plant()
|
plant()
|
||||||
|
@ -31,4 +35,4 @@ func _process(_delta):
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
if debug_growth:
|
if debug_growth:
|
||||||
plant()
|
growth_timer.start(growth_timer.wait_time - debug_growth_offset)
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://cf35yl04qtru3"]
|
[gd_scene load_steps=7 format=3 uid="uid://cf35yl04qtru3"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://island/CropTile.gd" id="1_7lls2"]
|
[ext_resource type="Script" path="res://island/CropTile.gd" id="1_7lls2"]
|
||||||
[ext_resource type="Material" uid="uid://w0ipvdnh4l8s" path="res://island/CropMaterial.tres" id="2_1oajr"]
|
[ext_resource type="Material" uid="uid://w0ipvdnh4l8s" path="res://island/CropMaterial.tres" id="2_1oajr"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://lkftwgdun745" path="res://assets/pop.wav" id="3_gur2a"]
|
||||||
|
[ext_resource type="Script" path="res://island/Pop.gd" id="4_5e7wk"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_6ja5h"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_6ja5h"]
|
||||||
size = Vector3(1, 0.1, 1)
|
size = Vector3(1, 0.1, 1)
|
||||||
|
@ -36,6 +38,12 @@ mesh = SubResource("ArrayMesh_28cd1")
|
||||||
skeleton = NodePath("../../..")
|
skeleton = NodePath("../../..")
|
||||||
|
|
||||||
[node name="GrowthTimer" type="Timer" parent="."]
|
[node name="GrowthTimer" type="Timer" parent="."]
|
||||||
wait_time = 5.0
|
wait_time = 2.0
|
||||||
|
|
||||||
|
[node name="Pop" type="AudioStreamPlayer3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.1, 0.5)
|
||||||
|
stream = ExtResource("3_gur2a")
|
||||||
|
attenuation_filter_cutoff_hz = 20500.0
|
||||||
|
script = ExtResource("4_5e7wk")
|
||||||
|
|
||||||
[connection signal="timeout" from="GrowthTimer" to="." method="complete"]
|
[connection signal="timeout" from="GrowthTimer" to="." method="complete"]
|
||||||
|
|
|
@ -83,5 +83,15 @@ transform = Transform3D(1, 0, 0, 0, -0.337161, 0.941447, 0, -0.941447, -0.337161
|
||||||
transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 0, 4.89631, 0)
|
transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 0, 4.89631, 0)
|
||||||
|
|
||||||
[node name="CropTile" parent="." instance=ExtResource("8_4ooup")]
|
[node name="CropTile" parent="." instance=ExtResource("8_4ooup")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 2, 8)
|
||||||
|
debug_growth = true
|
||||||
|
|
||||||
|
[node name="CropTile2" parent="." instance=ExtResource("8_4ooup")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 8)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 8)
|
||||||
debug_growth = true
|
debug_growth = true
|
||||||
|
debug_growth_offset = 0.5
|
||||||
|
|
||||||
|
[node name="CropTile3" parent="." instance=ExtResource("8_4ooup")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 8)
|
||||||
|
debug_growth = true
|
||||||
|
debug_growth_offset = 0.6
|
||||||
|
|
14
island/Pop.gd
Normal file
14
island/Pop.gd
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
extends AudioStreamPlayer3D
|
||||||
|
|
||||||
|
|
||||||
|
var rng: RandomNumberGenerator
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
rng = RandomNumberGenerator.new()
|
||||||
|
rng.randomize()
|
||||||
|
|
||||||
|
|
||||||
|
func play_with_random_pitch():
|
||||||
|
pitch_scale = rng.randf_range(0.3, 1.0)
|
||||||
|
play()
|
|
@ -147,6 +147,7 @@ stretch = true
|
||||||
|
|
||||||
[node name="GameViewport" type="SubViewport" parent="Head/Viewport/CameraViewportContainer"]
|
[node name="GameViewport" type="SubViewport" parent="Head/Viewport/CameraViewportContainer"]
|
||||||
handle_input_locally = false
|
handle_input_locally = false
|
||||||
|
audio_listener_enable_3d = true
|
||||||
size = Vector2i(284, 160)
|
size = Vector2i(284, 160)
|
||||||
render_target_update_mode = 4
|
render_target_update_mode = 4
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue