From 5cf82612fa8a3b1817e14d8410e4292f41392477 Mon Sep 17 00:00:00 2001 From: "alexey.grishchenko" Date: Sat, 20 Apr 2024 18:36:41 +0200 Subject: [PATCH 1/2] new enviroment and platform start --- 3d_platforma/Level.tscn | 161 ++++++++++++++++++++++-- 3d_platforma/Level1_platforms_slow.tscn | 105 +++++++--------- 3d_platforma/PanoSky.tres | 6 + project.godot | 6 + 4 files changed, 210 insertions(+), 68 deletions(-) create mode 100644 3d_platforma/PanoSky.tres diff --git a/3d_platforma/Level.tscn b/3d_platforma/Level.tscn index cdd3b7c..9d1f3d4 100644 --- a/3d_platforma/Level.tscn +++ b/3d_platforma/Level.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=16 format=2] [ext_resource path="res://3d_platforma/Player.tscn" type="PackedScene" id=1] -[ext_resource path="res://3d_platforma/golden_bay_512.hdr" type="Texture" id=2] [ext_resource path="res://scripts/Library/Actions/Snare Admiral 2.wav" type="AudioStream" id=3] -[ext_resource path="res://3d_platforma/Level1_platforms_slow.tscn" type="PackedScene" id=4] +[ext_resource path="res://3d_platforma/sqare_norm.png" type="Texture" id=4] [ext_resource path="res://3d_platforma/texture_08.png" type="Texture" id=5] [ext_resource path="res://scripts/Library/Actions/TriggerOnReady.gd" type="Script" id=6] [ext_resource path="res://scripts/Library/Actions/ActionList.gd" type="Script" id=7] @@ -16,13 +15,66 @@ albedo_texture = ExtResource( 5 ) roughness = 0.85 uv1_triplanar = true -[sub_resource type="PanoramaSky" id=23] -panorama = ExtResource( 2 ) +[sub_resource type="SpatialMaterial" id=38] +resource_name = "CheckerGrid" +albedo_color = Color( 0.85, 0.85, 0.85, 1 ) +albedo_texture = ExtResource( 5 ) +roughness = 0.85 +uv1_triplanar = true + +[sub_resource type="OpenSimplexNoise" id=28] +octaves = 2 +period = 0.8 + +[sub_resource type="NoiseTexture" id=29] +flags = 3 +width = 32 +height = 32 +noise = SubResource( 28 ) + +[sub_resource type="SpatialMaterial" id=22] +albedo_color = Color( 0.478431, 0.235294, 0.486275, 1 ) +roughness = 0.5 +roughness_texture = SubResource( 29 ) +normal_enabled = true +normal_scale = 1.0 +normal_texture = ExtResource( 4 ) +uv1_scale = Vector3( 3, 3, 3 ) +uv1_triplanar = true + +[sub_resource type="Animation" id=37] +resource_name = "move" +length = 30.0 +loop = true +tracks/0/type = "value" +tracks/0/path = NodePath(".:translation:y") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 10, 30 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ 0.0, 10.0, 0.0 ] +} + +[sub_resource type="ProceduralSky" id=39] +sky_top_color = Color( 0.0901961, 0.121569, 0.141176, 1 ) +sky_horizon_color = Color( 0.266667, 0.301961, 0.333333, 1 ) +sky_energy = 0.1 +ground_bottom_color = Color( 0.160784, 0.0666667, 0.0352941, 1 ) +ground_horizon_color = Color( 0.266667, 0.301961, 0.333333, 1 ) +ground_energy = 0.1 +sun_color = Color( 0.972549, 0.976471, 0.345098, 1 ) +sun_latitude = 15.0 +sun_longitude = -3.96 +sun_curve = 0.0170755 [sub_resource type="Environment" id=24] resource_name = "black_env" background_mode = 2 -background_sky = SubResource( 23 ) +background_sky = SubResource( 39 ) background_sky_custom_fov = 50.0 background_color = Color( 0.137255, 0.137255, 0.137255, 1 ) background_energy = 2.0 @@ -45,16 +97,103 @@ glow_hdr_scale = 4.0 [node name="Game" type="Spatial"] [node name="start" type="CSGBox" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.1, 0 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -24.1, 0 ) use_collision = true -width = 6.05148 -height = 0.2 -depth = 6.62613 +width = 4.0 +height = 48.0 +depth = 6.0 material = SubResource( 36 ) [node name="Player" parent="." instance=ExtResource( 1 )] -[node name="platforms_slow" parent="." instance=ExtResource( 4 )] +[node name="enviroment" type="Spatial" parent="."] + +[node name="Ring2" type="CSGPolygon" parent="enviroment"] +transform = Transform( 0.866025, 0.5, -2.18557e-08, 0, -4.37114e-08, -1, -0.5, 0.866025, -3.78552e-08, 0, -0.4, -21.4713 ) +polygon = PoolVector2Array( 9, -2, 9.4, -1, 10, -1, 10, -2 ) +mode = 1 +spin_degrees = 360.0 +spin_sides = 16 +material = SubResource( 38 ) + +[node name="Ring3" type="CSGPolygon" parent="enviroment"] +transform = Transform( 0.866025, 0.5, -2.18557e-08, 0, -4.37114e-08, -1, -0.5, 0.866025, -3.78552e-08, -10, 6.6, -33.4713 ) +polygon = PoolVector2Array( 13, -4, 14, -2, 15, -2, 15, -4 ) +mode = 1 +spin_degrees = 360.0 +spin_sides = 16 +material = SubResource( 38 ) + +[node name="Ring4" type="CSGPolygon" parent="enviroment"] +transform = Transform( 1.93185, -0.517638, 2.26267e-08, 0, -8.74228e-08, -2, 0.517638, 1.93185, -8.44439e-08, -11, -0.4, -62.4713 ) +polygon = PoolVector2Array( 13, -4, 14, -2, 15, -2, 15, -4 ) +mode = 1 +spin_degrees = 360.0 +spin_sides = 16 +material = SubResource( 38 ) + +[node name="platforms_slow" type="Spatial" parent="."] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, -4.4 ) + +[node name="pickup" type="CSGCylinder" parent="platforms_slow"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.3, -2 ) +use_collision = true +radius = 2.3 +height = 0.2 +sides = 11 + +[node name="Ring" type="CSGPolygon" parent="platforms_slow"] +transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.7, -8.07128 ) +use_collision = true +polygon = PoolVector2Array( 3, 0, 3.37031, 1.2588, 4.15364, 1.29316, 4, 0 ) +mode = 1 +spin_degrees = 360.0 +spin_sides = 16 +material = SubResource( 38 ) + +[node name="ramp2" type="CSGBox" parent="platforms_slow"] +transform = Transform( 1, 0, 0, 0, 0.984808, -0.173648, 0, 0.173648, 0.984808, 0, -1.2, -7.7 ) +use_collision = true +width = 2.4 +height = 0.4 +depth = 4.0 +material = SubResource( 22 ) + +[node name="slow_path" type="CSGBox" parent="platforms_slow"] +transform = Transform( 0.965926, 0, 0.258819, 0, 1, 0, -0.258819, 0, 0.965926, 0, -0.7, -11.4713 ) +use_collision = true +width = 2.2 +height = 0.6 +material = SubResource( 22 ) + +[node name="slow_path2" type="CSGBox" parent="platforms_slow"] +transform = Transform( 0.866025, 0, 0.5, 0, 1, 0, -0.5, 0, 0.866025, -1.4, -0.4, -14.3713 ) +use_collision = true +width = 2.2 +height = 0.6 +material = SubResource( 22 ) + +[node name="slow_path3" type="CSGBox" parent="platforms_slow"] +transform = Transform( 0.707107, 0, 0.707107, 0, 1, 0, -0.707107, 0, 0.707107, -2.6, 0.6, -16.3713 ) +use_collision = true +width = 2.2 +height = 0.6 +material = SubResource( 22 ) + +[node name="lift" type="Spatial" parent="platforms_slow"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8, -0.4, -16 ) +visible = false + +[node name="platform" type="CSGBox" parent="platforms_slow/lift"] +use_collision = true +width = 4.0 +height = 1.0 +depth = 4.0 +material = SubResource( 38 ) + +[node name="AnimationPlayer" type="AnimationPlayer" parent="platforms_slow/lift/platform"] +autoplay = "move" +anims/move = SubResource( 37 ) [node name="DirectionalLight" type="DirectionalLight" parent="."] transform = Transform( 0.707107, -0.5, 0.5, 0, 0.707107, 0.707107, -0.707107, -0.5, 0.5, 0, 5, 0 ) diff --git a/3d_platforma/Level1_platforms_slow.tscn b/3d_platforma/Level1_platforms_slow.tscn index d5cc4ea..eb24b92 100644 --- a/3d_platforma/Level1_platforms_slow.tscn +++ b/3d_platforma/Level1_platforms_slow.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://3d_platforma/texture_08.png" type="Texture" id=1] [ext_resource path="res://3d_platforma/sqare_norm.png" type="Texture" id=2] @@ -10,6 +10,26 @@ albedo_texture = ExtResource( 1 ) roughness = 0.85 uv1_triplanar = true +[sub_resource type="OpenSimplexNoise" id=28] +octaves = 2 +period = 0.8 + +[sub_resource type="NoiseTexture" id=29] +flags = 3 +width = 32 +height = 32 +noise = SubResource( 28 ) + +[sub_resource type="SpatialMaterial" id=22] +albedo_color = Color( 0.478431, 0.235294, 0.486275, 1 ) +roughness = 0.5 +roughness_texture = SubResource( 29 ) +normal_enabled = true +normal_scale = 1.0 +normal_texture = ExtResource( 2 ) +uv1_scale = Vector3( 3, 3, 3 ) +uv1_triplanar = true + [sub_resource type="Animation" id=37] resource_name = "move" length = 30.0 @@ -27,51 +47,37 @@ tracks/0/keys = { "values": [ 0.0, 10.0, 0.0 ] } -[sub_resource type="BoxShape" id=20] - -[sub_resource type="CubeMesh" id=21] - -[sub_resource type="OpenSimplexNoise" id=28] -octaves = 2 -period = 0.8 - -[sub_resource type="NoiseTexture" id=29] -flags = 3 -width = 32 -height = 32 -noise = SubResource( 28 ) - -[sub_resource type="SpatialMaterial" id=22] -albedo_color = Color( 0.603922, 0.0235294, 0.619608, 1 ) -roughness = 0.25 -roughness_texture = SubResource( 29 ) -normal_enabled = true -normal_scale = 1.0 -normal_texture = ExtResource( 2 ) -uv1_scale = Vector3( 3, 3, 3 ) -uv1_triplanar = true - [node name="platforms_slow" type="Spatial"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.1, 0 ) -[node name="thin" type="CSGBox" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, -12 ) +[node name="Ring" type="CSGPolygon" parent="."] +transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 1, -2.37128 ) use_collision = true -width = 4.0 -height = 0.2 -depth = 10.0 +polygon = PoolVector2Array( 3, 0, 3.37031, 1.2588, 4.15364, 1.29316, 4, 0 ) +mode = 1 +spin_degrees = 360.0 +spin_sides = 16 material = SubResource( 36 ) -[node name="ramp" type="CSGBox" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.4, -22 ) +[node name="ramp2" type="CSGBox" parent="."] +transform = Transform( 1, 0, 0, 0, 0.984808, -0.173648, 0, 0.173648, 0.984808, 0, -0.9, -2 ) use_collision = true -width = 4.0 -height = 1.0 -depth = 10.0 -material = SubResource( 36 ) +width = 2.4 +height = 0.4 +depth = 4.0 +material = SubResource( 22 ) + +[node name="pickup" type="CSGBox" parent="."] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, -15.5713 ) +use_collision = true +width = 2.2 +height = 0.6 +depth = 4.0 +material = SubResource( 22 ) [node name="lift" type="Spatial" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.4, -30 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8, -0.4, -16 ) +visible = false [node name="platform" type="CSGBox" parent="lift"] use_collision = true @@ -84,24 +90,9 @@ material = SubResource( 36 ) autoplay = "move" anims/move = SubResource( 37 ) -[node name="lego" type="StaticBody" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5, -1.9, -8 ) -__meta__ = { -"_edit_group_": true -} - -[node name="CollisionShape" type="CollisionShape" parent="lego"] -shape = SubResource( 20 ) - -[node name="MeshInstance" type="MeshInstance" parent="lego"] -mesh = SubResource( 21 ) -material/0 = SubResource( 22 ) - -[node name="CSGPolygon" type="CSGPolygon" parent="."] -transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 1, -12 ) +[node name="CSGCylinder" type="CSGCylinder" parent="."] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, -7 ) use_collision = true -polygon = PoolVector2Array( 3, -4, 3, 1, 4.15364, 1.29316, 4, -4 ) -mode = 1 -spin_degrees = 360.0 -spin_sides = 16 -material = SubResource( 36 ) +radius = 2.0 +height = 0.2 +sides = 11 diff --git a/3d_platforma/PanoSky.tres b/3d_platforma/PanoSky.tres new file mode 100644 index 0000000..8de41bc --- /dev/null +++ b/3d_platforma/PanoSky.tres @@ -0,0 +1,6 @@ +[gd_resource type="PanoramaSky" load_steps=2 format=2] + +[ext_resource path="res://3d_platforma/golden_bay_512.hdr" type="Texture" id=1] + +[resource] +panorama = ExtResource( 1 ) diff --git a/project.godot b/project.godot index 488eeed..ac2876b 100644 --- a/project.godot +++ b/project.godot @@ -69,6 +69,12 @@ common/drop_mouse_on_gui_input_disabled=true [input] +ui_end={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777230,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} move_forward={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":87,"unicode":0,"echo":false,"script":null) From 3c31ad66ac32c99c54983ab7bdf5bfba40c52253 Mon Sep 17 00:00:00 2001 From: Matteo Tietz Date: Sat, 20 Apr 2024 18:40:59 +0200 Subject: [PATCH 2/2] Work on audio players --- 3d_platforma/Level.tscn | 28 ++++++++++++++++++---- Tape/TapeFast.tscn | 27 +++++++++++++++++++++ Tape/TapeNormal.tscn | 27 +++++++++++++++++++++ Tape/{Tape.tscn => TapeSlow.tscn} | 9 +++---- project.godot | 1 - scripts/Library/Actions/PlaySound.gd | 3 +-- scripts/MusicSingleton.gd | 27 ++++++++++++++++++++- scripts/RegisterAudioStreamPlayerFast.gd | 5 ++++ scripts/RegisterAudioStreamPlayerNormal.gd | 5 ++++ scripts/RegisterAudioStreamPlayerSlow.gd | 5 ++++ 10 files changed, 125 insertions(+), 12 deletions(-) create mode 100644 Tape/TapeFast.tscn create mode 100644 Tape/TapeNormal.tscn rename Tape/{Tape.tscn => TapeSlow.tscn} (71%) create mode 100644 scripts/RegisterAudioStreamPlayerFast.gd create mode 100644 scripts/RegisterAudioStreamPlayerNormal.gd create mode 100644 scripts/RegisterAudioStreamPlayerSlow.gd diff --git a/3d_platforma/Level.tscn b/3d_platforma/Level.tscn index 2f65bc3..de14de0 100644 --- a/3d_platforma/Level.tscn +++ b/3d_platforma/Level.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=18 format=2] [ext_resource path="res://3d_platforma/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://scripts/Library/Actions/Snare Admiral 2.wav" type="AudioStream" id=3] @@ -7,7 +7,12 @@ [ext_resource path="res://scripts/Library/Actions/TriggerOnReady.gd" type="Script" id=6] [ext_resource path="res://scripts/Library/Actions/ActionList.gd" type="Script" id=7] [ext_resource path="res://scripts/Library/Actions/SFX BlackTiger.wav" type="AudioStream" id=8] -[ext_resource path="res://Tape/Tape.tscn" type="PackedScene" id=9] +[ext_resource path="res://Tape/TapeFast.tscn" type="PackedScene" id=9] +[ext_resource path="res://Tape/TapeNormal.tscn" type="PackedScene" id=10] +[ext_resource path="res://Tape/TapeSlow.tscn" type="PackedScene" id=11] +[ext_resource path="res://scripts/RegisterAudioStreamPlayerSlow.gd" type="Script" id=12] +[ext_resource path="res://scripts/RegisterAudioStreamPlayerFast.gd" type="Script" id=13] +[ext_resource path="res://scripts/RegisterAudioStreamPlayerNormal.gd" type="Script" id=14] [sub_resource type="SpatialMaterial" id=36] resource_name = "CheckerGrid" @@ -222,5 +227,20 @@ script = ExtResource( 1 ) [node name="PlaySound2" type="Node" parent="ActionList"] script = ExtResource( 1 ) -[node name="Tape" parent="." instance=ExtResource( 9 )] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2.1894 ) +[node name="TapeFast" parent="." instance=ExtResource( 9 )] +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, -1.34058, 0, -1.25926 ) + +[node name="TapeNormal" parent="." instance=ExtResource( 10 )] +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0.518271, 0, -1.35086 ) + +[node name="TapeSlow" parent="." instance=ExtResource( 11 )] +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 2.24, 0, -1.3138 ) + +[node name="AudioStreamPlayer3DSlow" type="AudioStreamPlayer3D" parent="."] +script = ExtResource( 12 ) + +[node name="AudioStreamPlayer3DNormal" type="AudioStreamPlayer3D" parent="."] +script = ExtResource( 14 ) + +[node name="AudioStreamPlayer3DFast" type="AudioStreamPlayer3D" parent="."] +script = ExtResource( 13 ) diff --git a/Tape/TapeFast.tscn b/Tape/TapeFast.tscn new file mode 100644 index 0000000..4c3bdc8 --- /dev/null +++ b/Tape/TapeFast.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://scripts/SetFastMusic.gd" type="Script" id=1] +[ext_resource path="res://Tape/tape.obj" type="ArrayMesh" id=2] +[ext_resource path="res://scripts/Library/Actions/TriggerOnCollision.gd" type="Script" id=3] + +[sub_resource type="BoxShape" id=1] + +[node name="TapeFast" type="Spatial"] +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, 0, 0 ) + +[node name="MeshInstance" type="MeshInstance" parent="."] +mesh = ExtResource( 2 ) + +[node name="Area" type="Area" parent="."] + +[node name="CollisionShape" type="CollisionShape" parent="Area"] +transform = Transform( 0.240864, 0, 0, 0, 1, 0, 0, 0, 1.66505, 0, 0, 0 ) +shape = SubResource( 1 ) + +[node name="TriggerOnCollision" type="Node" parent="Area"] +script = ExtResource( 3 ) +collision_area = NodePath("..") +action = NodePath("../SetFastMusic") + +[node name="SetFastMusic" type="Node" parent="Area"] +script = ExtResource( 1 ) diff --git a/Tape/TapeNormal.tscn b/Tape/TapeNormal.tscn new file mode 100644 index 0000000..75e39b4 --- /dev/null +++ b/Tape/TapeNormal.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://scripts/SetNormalMusic.gd" type="Script" id=1] +[ext_resource path="res://Tape/tape.obj" type="ArrayMesh" id=2] +[ext_resource path="res://scripts/Library/Actions/TriggerOnCollision.gd" type="Script" id=3] + +[sub_resource type="BoxShape" id=1] + +[node name="TapeNormal" type="Spatial"] +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, 0, 0 ) + +[node name="MeshInstance" type="MeshInstance" parent="."] +mesh = ExtResource( 2 ) + +[node name="Area" type="Area" parent="."] + +[node name="CollisionShape" type="CollisionShape" parent="Area"] +transform = Transform( 0.240864, 0, 0, 0, 1, 0, 0, 0, 1.66505, 0, 0, 0 ) +shape = SubResource( 1 ) + +[node name="TriggerOnCollision" type="Node" parent="Area"] +script = ExtResource( 3 ) +collision_area = NodePath("..") +action = NodePath("../SetNormalMusic") + +[node name="SetNormalMusic" type="Node" parent="Area"] +script = ExtResource( 1 ) diff --git a/Tape/Tape.tscn b/Tape/TapeSlow.tscn similarity index 71% rename from Tape/Tape.tscn rename to Tape/TapeSlow.tscn index 3513b02..2963995 100644 --- a/Tape/Tape.tscn +++ b/Tape/TapeSlow.tscn @@ -2,11 +2,12 @@ [ext_resource path="res://Tape/tape.obj" type="ArrayMesh" id=1] [ext_resource path="res://scripts/Library/Actions/TriggerOnCollision.gd" type="Script" id=2] -[ext_resource path="res://scripts/Library/Actions/PlaySound.gd" type="Script" id=3] +[ext_resource path="res://scripts/SetSlowMusic.gd" type="Script" id=3] [sub_resource type="BoxShape" id=1] -[node name="Tape" type="Spatial"] +[node name="TapeSlow" type="Spatial"] +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, 0, 0 ) [node name="MeshInstance" type="MeshInstance" parent="."] mesh = ExtResource( 1 ) @@ -20,7 +21,7 @@ shape = SubResource( 1 ) [node name="TriggerOnCollision" type="Node" parent="Area"] script = ExtResource( 2 ) collision_area = NodePath("..") -action = NodePath("../PlaySound") +action = NodePath("../SetSlowMusic") -[node name="PlaySound" type="Node" parent="Area"] +[node name="SetSlowMusic" type="Node" parent="Area"] script = ExtResource( 3 ) diff --git a/project.godot b/project.godot index d787765..4c4ea7a 100644 --- a/project.godot +++ b/project.godot @@ -133,5 +133,4 @@ common/enable_pause_aware_picking=true [rendering] -quality/driver/driver_name="GLES2" environment/default_environment="res://default_env.tres" diff --git a/scripts/Library/Actions/PlaySound.gd b/scripts/Library/Actions/PlaySound.gd index 0e95e9f..38077d1 100644 --- a/scripts/Library/Actions/PlaySound.gd +++ b/scripts/Library/Actions/PlaySound.gd @@ -8,6 +8,5 @@ func _ready(): func onTrigger(): - print("OnTrigger PlaySound") -# get_node( audioStreamPlayer ).play() + get_node( audioStreamPlayer ).play() diff --git a/scripts/MusicSingleton.gd b/scripts/MusicSingleton.gd index f153759..ebd41a8 100644 --- a/scripts/MusicSingleton.gd +++ b/scripts/MusicSingleton.gd @@ -6,6 +6,10 @@ func _ready() -> void: var change_slow_actions : Array = [] var gameSpeed : float = 1; var musicType: int = 0; +var audio_player_slow : AudioStreamPlayer3D +var audio_player_normal : AudioStreamPlayer3D +var audio_player_fast : AudioStreamPlayer3D +var current_audio_player : AudioStreamPlayer3D func setSlowMusic(): setMusicType( -1 ) @@ -19,7 +23,15 @@ func setNormalMusic(): func setMusicType( type:int ): musicType = type; - gameSpeed = 0 + if type == 0: + gameSpeed = 0 + +# current_playback_position : float = 0.0 +# if current_audio_player: +# current_audio_player.stop() +# current_playback_position = current_audio_player.get_playback_position() +# current_playback_position = current_audio_player.get_playback_position() +# current_playback_position = current_audio_player.get_playback_position() if type == 1: gameSpeed = 2 @@ -39,3 +51,16 @@ func unregister_change_action(change_action : Node) -> void: func change_music() -> void: for change_action in change_slow_actions: change_action.execute() + +func register_audio_player_slow(audio_player : AudioStreamPlayer3D) -> void: + print("Registered audio stream player fast") + audio_player_slow = audio_player + +func register_audio_player_normal(audio_player : AudioStreamPlayer3D) -> void: + print("Registered audio stream player normal") + audio_player_normal = audio_player + +func register_audio_player_fast(audio_player : AudioStreamPlayer3D) -> void: + print("Registered audio stream player fast") + audio_player_fast = audio_player + diff --git a/scripts/RegisterAudioStreamPlayerFast.gd b/scripts/RegisterAudioStreamPlayerFast.gd new file mode 100644 index 0000000..51f51bc --- /dev/null +++ b/scripts/RegisterAudioStreamPlayerFast.gd @@ -0,0 +1,5 @@ +extends AudioStreamPlayer3D + + +func _ready(): + MusicSingleton.register_audio_player_fast(self) diff --git a/scripts/RegisterAudioStreamPlayerNormal.gd b/scripts/RegisterAudioStreamPlayerNormal.gd new file mode 100644 index 0000000..0053928 --- /dev/null +++ b/scripts/RegisterAudioStreamPlayerNormal.gd @@ -0,0 +1,5 @@ +extends AudioStreamPlayer3D + + +func _ready(): + MusicSingleton.register_audio_player_normal(self) diff --git a/scripts/RegisterAudioStreamPlayerSlow.gd b/scripts/RegisterAudioStreamPlayerSlow.gd new file mode 100644 index 0000000..224b63f --- /dev/null +++ b/scripts/RegisterAudioStreamPlayerSlow.gd @@ -0,0 +1,5 @@ +extends AudioStreamPlayer3D + + +func _ready(): + MusicSingleton.register_audio_player_slow(self)