From 8218cfeab8de656253f254bf2b39d1fa82ff7095 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 14 Apr 2024 22:03:59 +0200 Subject: [PATCH] Add drag and drop sounds to `Sheep` --- NOTICE.md | 4 ++-- temp/place.wav => entities/drop.wav | 0 temp/place.wav.import => entities/drop.wav.import | 6 +++--- entities/sheep.gd | 9 ++++++++- entities/sheep.tscn | 14 +++++++++++++- temp/sheep.wav => entities/sheep_drag.wav | 0 .../sheep_drag.wav.import | 6 +++--- 7 files changed, 29 insertions(+), 10 deletions(-) rename temp/place.wav => entities/drop.wav (100%) rename temp/place.wav.import => entities/drop.wav.import (57%) rename temp/sheep.wav => entities/sheep_drag.wav (100%) rename temp/sheep.wav.import => entities/sheep_drag.wav.import (55%) diff --git a/NOTICE.md b/NOTICE.md index 190839d..7287901 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -6,11 +6,11 @@ This project uses the following external assets: |------|-------|-----| | `./icon.svg` | Godot icon | MIT license | | `./temp/tollbell.mp3`| sdroliasnick freesound.org| CC0 | -| `./temp/sheep.wav`| michaelperfect freesound.org | CC0 | +| `./entities/sheep_drag.wav`| michaelperfect freesound.org | CC0 | | `./temp/click&pop.wav`| GammaGoot freesound.org | CC0 | | `./temp/pop.wav`| NovaSoundTechnology freesound.org | CC0 | | `./temp/mouth_pop.wav`| igaopuromalte freesound.org | Attribution 4 | | `./temp/puff.wav`| JustInvoke freesound.org | Attribution 4 | -| `./temp/place.wav`| Planman freesound.org | CC0 | +| `./entities/drop.wav`| Planman freesound.org | CC0 | | `./temp/gore.wav`| MinecraftGamerLR freesound.org | Attribution 4 | | `./temp/bones.wav`| cliftonmcarlson freesound.org | CC0 | \ No newline at end of file diff --git a/temp/place.wav b/entities/drop.wav similarity index 100% rename from temp/place.wav rename to entities/drop.wav diff --git a/temp/place.wav.import b/entities/drop.wav.import similarity index 57% rename from temp/place.wav.import rename to entities/drop.wav.import index b94a9be..08d956e 100644 --- a/temp/place.wav.import +++ b/entities/drop.wav.import @@ -3,12 +3,12 @@ importer="wav" type="AudioStreamWAV" uid="uid://buxgivpkh8dyl" -path="res://.godot/imported/place.wav-6f3a5aef81053f3b0b94fbbb722a0c32.sample" +path="res://.godot/imported/drop.wav-e321e3ff0b5883beef3e60642ca137ca.sample" [deps] -source_file="res://temp/place.wav" -dest_files=["res://.godot/imported/place.wav-6f3a5aef81053f3b0b94fbbb722a0c32.sample"] +source_file="res://entities/drop.wav" +dest_files=["res://.godot/imported/drop.wav-e321e3ff0b5883beef3e60642ca137ca.sample"] [params] diff --git a/entities/sheep.gd b/entities/sheep.gd index 142d08d..83a37a0 100644 --- a/entities/sheep.gd +++ b/entities/sheep.gd @@ -3,13 +3,20 @@ class_name Sheep @onready var draggable: Draggable = $"Draggable" +@onready var drag_sound: AudioStreamPlayer2D = $"Draggable/DragSound" +@onready var drop_sound: AudioStreamPlayer2D = $"Draggable/DropSound" func _on_move(movement: Vector2) -> void: if not draggable.being_dragged: move_and_collide(movement) - func _on_drag_move(movement: Vector2) -> void: if draggable.being_dragged: move_and_collide(movement) + +func _on_draggable_dragged() -> void: + drag_sound.play() + +func _on_draggable_dropped() -> void: + drop_sound.play() diff --git a/entities/sheep.tscn b/entities/sheep.tscn index 56d1ffe..4af175a 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=6 format=3 uid="uid://bc2bm8lbol18w"] +[gd_scene load_steps=8 format=3 uid="uid://bc2bm8lbol18w"] [ext_resource type="Script" path="res://entities/sheep.gd" id="1_4dmll"] [ext_resource type="PackedScene" uid="uid://bvrxvrjlo5130" path="res://behaviours/move_towards_mouse.tscn" id="2_tfd2i"] [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_8ku7r"] +[ext_resource type="AudioStream" uid="uid://buxgivpkh8dyl" path="res://entities/drop.wav" id="4_nxjnl"] +[ext_resource type="AudioStream" uid="uid://bmfscpnugaejk" path="res://entities/sheep_drag.wav" id="4_oalqu"] [sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"] radius = 16.0 @@ -29,5 +31,15 @@ can_detach = true [node name="Draggable" parent="." instance=ExtResource("3_8ku7r")] scale = Vector2(2, 2) +[node name="DragSound" type="AudioStreamPlayer2D" parent="Draggable"] +scale = Vector2(0.5, 0.5) +stream = ExtResource("4_oalqu") + +[node name="DropSound" type="AudioStreamPlayer2D" parent="Draggable"] +scale = Vector2(0.5, 0.5) +stream = ExtResource("4_nxjnl") + [connection signal="move" from="MoveTowardsMouse" to="." method="_on_move"] +[connection signal="dragged" from="Draggable" to="." method="_on_draggable_dragged"] +[connection signal="dropped" from="Draggable" to="." method="_on_draggable_dropped"] [connection signal="move" from="Draggable" to="." method="_on_drag_move"] diff --git a/temp/sheep.wav b/entities/sheep_drag.wav similarity index 100% rename from temp/sheep.wav rename to entities/sheep_drag.wav diff --git a/temp/sheep.wav.import b/entities/sheep_drag.wav.import similarity index 55% rename from temp/sheep.wav.import rename to entities/sheep_drag.wav.import index 140fa34..9f4d3b9 100644 --- a/temp/sheep.wav.import +++ b/entities/sheep_drag.wav.import @@ -3,12 +3,12 @@ importer="wav" type="AudioStreamWAV" uid="uid://bmfscpnugaejk" -path="res://.godot/imported/sheep.wav-5e192fa241f3aae906a657036a0b94de.sample" +path="res://.godot/imported/sheep_drag.wav-43fcf0f822dd8bb239b2bd20f832762a.sample" [deps] -source_file="res://temp/sheep.wav" -dest_files=["res://.godot/imported/sheep.wav-5e192fa241f3aae906a657036a0b94de.sample"] +source_file="res://entities/sheep_drag.wav" +dest_files=["res://.godot/imported/sheep_drag.wav-43fcf0f822dd8bb239b2bd20f832762a.sample"] [params]