From 08349d4f437e54b912a3a0b60b9ce2f7605b4701 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 7 Jan 2023 19:23:07 +0100 Subject: [PATCH] Add splash sound and respawn --- assets/splash.ogg | 3 +++ assets/splash.ogg.import | 19 +++++++++++++++++++ island/Island.tscn | 2 +- player/Player.tscn | 10 +++++++++- player/SplashController.gd | 12 ++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 assets/splash.ogg create mode 100644 assets/splash.ogg.import create mode 100644 player/SplashController.gd diff --git a/assets/splash.ogg b/assets/splash.ogg new file mode 100644 index 0000000..cd85ba8 --- /dev/null +++ b/assets/splash.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d419c12212aa957b9dd9c1c9ed0a03cf676c3badc0f47dce6e8df5ad29da8b1 +size 54365 diff --git a/assets/splash.ogg.import b/assets/splash.ogg.import new file mode 100644 index 0000000..42c7c72 --- /dev/null +++ b/assets/splash.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://xretxahxbqdr" +path="res://.godot/imported/splash.ogg-531703e6bdcbdfaa68fabbaa897f2b6c.oggvorbisstr" + +[deps] + +source_file="res://assets/splash.ogg" +dest_files=["res://.godot/imported/splash.ogg-531703e6bdcbdfaa68fabbaa897f2b6c.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0.0 +bpm=0.0 +beat_count=0 +bar_beats=4 diff --git a/island/Island.tscn b/island/Island.tscn index 6395ee7..d43fc50 100644 --- a/island/Island.tscn +++ b/island/Island.tscn @@ -3,7 +3,7 @@ [ext_resource type="Shader" path="res://island/Sea.gdshader" id="1_agjfy"] [ext_resource type="Texture2D" uid="uid://bdoifsf6k0qb8" path="res://assets/water_tile.png" id="1_w6ara"] [ext_resource type="ArrayMesh" uid="uid://c8knvy5ras8jo" path="res://assets/island_model/island.obj" id="2_r00hx"] -[ext_resource type="PackedScene" path="res://player/Player.tscn" id="3_5378m"] +[ext_resource type="PackedScene" uid="uid://b5i1sqd88wlle" path="res://player/Player.tscn" id="3_5378m"] [ext_resource type="ArrayMesh" uid="uid://b7jov7hxhbq6j" path="res://assets/island_model/hill.obj" id="5_wot4t"] [sub_resource type="GDScript" id="GDScript_78lo3"] diff --git a/player/Player.tscn b/player/Player.tscn index ea0eca8..a3105d3 100644 --- a/player/Player.tscn +++ b/player/Player.tscn @@ -1,9 +1,11 @@ -[gd_scene load_steps=16 format=3] +[gd_scene load_steps=18 format=3 uid="uid://b5i1sqd88wlle"] [ext_resource type="Script" path="res://player/Player.gd" id="1_rujcr"] [ext_resource type="Script" path="res://player/Head.gd" id="2_ohlgu"] [ext_resource type="Script" path="res://player/OnHand.gd" id="3_3rcjl"] [ext_resource type="Shader" path="res://player/crosshair.gdshader" id="4_dut1p"] +[ext_resource type="Script" path="res://player/SplashController.gd" id="5_wnbq8"] +[ext_resource type="AudioStream" uid="uid://xretxahxbqdr" path="res://assets/splash.ogg" id="6_xi537"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_berhm"] @@ -270,3 +272,9 @@ position = Vector2(140, 79) scale = Vector2(1.65, 1) [node name="RigidDynamicBody3D" type="RigidBody3D" parent="."] + +[node name="SplashController" type="Node" parent="."] +script = ExtResource("5_wnbq8") + +[node name="SplashSound" type="AudioStreamPlayer" parent="SplashController"] +stream = ExtResource("6_xi537") diff --git a/player/SplashController.gd b/player/SplashController.gd new file mode 100644 index 0000000..4b1cdc4 --- /dev/null +++ b/player/SplashController.gd @@ -0,0 +1,12 @@ +extends Node + + +@onready var player: Node3D = $".." +@onready var spawn_point: Vector3 = player.position +@onready var splash_sound: AudioStreamPlayer = $SplashSound + + +func _process(_delta): + if player.position.y < 0: + splash_sound.play() + player.position = spawn_point