mirror of
https://github.com/RYGhub/the-cold-night.git
synced 2024-11-25 14:14:19 +00:00
✨ Add dynamic music
This commit is contained in:
parent
beb9485ee4
commit
be3d7a9afc
2 changed files with 36 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=11 format=2]
|
[gd_scene load_steps=12 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/mechanics/Background.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://src/mechanics/Background.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://src/mechanics/Darkness.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://src/mechanics/Darkness.tscn" type="PackedScene" id=2]
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
[ext_resource path="res://src/music/BaseChoir.mp3" type="AudioStream" id=8]
|
[ext_resource path="res://src/music/BaseChoir.mp3" type="AudioStream" id=8]
|
||||||
[ext_resource path="res://src/music/BaseDrum.mp3" type="AudioStream" id=9]
|
[ext_resource path="res://src/music/BaseDrum.mp3" type="AudioStream" id=9]
|
||||||
[ext_resource path="res://src/music/BaseBell.mp3" type="AudioStream" id=10]
|
[ext_resource path="res://src/music/BaseBell.mp3" type="AudioStream" id=10]
|
||||||
|
[ext_resource path="res://src/levels/PhaseOneMusic.gd" type="Script" id=11]
|
||||||
|
|
||||||
[node name="Game" type="Node2D"]
|
[node name="Game" type="Node2D"]
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
|
@ -18,17 +19,22 @@ script = ExtResource( 6 )
|
||||||
layer = 0
|
layer = 0
|
||||||
|
|
||||||
[node name="PhaseOneMusic" type="Node" parent="PhaseOne"]
|
[node name="PhaseOneMusic" type="Node" parent="PhaseOne"]
|
||||||
|
script = ExtResource( 11 )
|
||||||
|
fire_path = NodePath("../PhaseOneContainer/Fire")
|
||||||
|
|
||||||
[node name="BaseBell" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
[node name="Bell" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
||||||
stream = ExtResource( 10 )
|
stream = ExtResource( 10 )
|
||||||
|
volume_db = -60.0
|
||||||
autoplay = true
|
autoplay = true
|
||||||
|
|
||||||
[node name="BaseChoir" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
[node name="Choir" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
||||||
stream = ExtResource( 8 )
|
stream = ExtResource( 8 )
|
||||||
|
volume_db = -60.0
|
||||||
autoplay = true
|
autoplay = true
|
||||||
|
|
||||||
[node name="BaseDrum" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
[node name="Drum" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
||||||
stream = ExtResource( 9 )
|
stream = ExtResource( 9 )
|
||||||
|
volume_db = -60.0
|
||||||
autoplay = true
|
autoplay = true
|
||||||
|
|
||||||
[node name="PhaseOneContainer" type="Node2D" parent="PhaseOne"]
|
[node name="PhaseOneContainer" type="Node2D" parent="PhaseOne"]
|
||||||
|
@ -39,17 +45,16 @@ tile_data = PoolIntArray( 0, 2, 0, 1, 2, 0, 2, 2, 0, 3, 2, 0, 4, 2, 0, 5, 2, 0,
|
||||||
[node name="Darkness" parent="PhaseOne/PhaseOneContainer" instance=ExtResource( 2 )]
|
[node name="Darkness" parent="PhaseOne/PhaseOneContainer" instance=ExtResource( 2 )]
|
||||||
position = Vector2( 553, 296 )
|
position = Vector2( 553, 296 )
|
||||||
|
|
||||||
[node name="Fire" parent="PhaseOne/PhaseOneContainer" instance=ExtResource( 3 )]
|
|
||||||
position = Vector2( 597, 323 )
|
|
||||||
script = null
|
|
||||||
|
|
||||||
[node name="Player" parent="PhaseOne/PhaseOneContainer" instance=ExtResource( 4 )]
|
[node name="Player" parent="PhaseOne/PhaseOneContainer" instance=ExtResource( 4 )]
|
||||||
position = Vector2( 500, 438 )
|
position = Vector2( 500, 438 )
|
||||||
|
|
||||||
[node name="Enemy" parent="PhaseOne/PhaseOneContainer" instance=ExtResource( 5 )]
|
[node name="Enemy" parent="PhaseOne/PhaseOneContainer" instance=ExtResource( 5 )]
|
||||||
visible = false
|
|
||||||
position = Vector2( 755, 508 )
|
position = Vector2( 755, 508 )
|
||||||
|
|
||||||
|
[node name="Fire" parent="PhaseOne/PhaseOneContainer" instance=ExtResource( 3 )]
|
||||||
|
position = Vector2( 493, 305 )
|
||||||
|
intensity = 0.3
|
||||||
|
|
||||||
[node name="UserInterface" type="CanvasLayer" parent="."]
|
[node name="UserInterface" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="UserIntefaceContainer" type="Panel" parent="UserInterface"]
|
[node name="UserIntefaceContainer" type="Panel" parent="UserInterface"]
|
||||||
|
|
22
src/levels/PhaseOneMusic.gd
Normal file
22
src/levels/PhaseOneMusic.gd
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
export var fire_path: NodePath
|
||||||
|
|
||||||
|
export var choir_min: float = 0.05
|
||||||
|
export var choir_max: float = 0.20
|
||||||
|
export var bell_min: float = 0.20
|
||||||
|
export var bell_max: float = 0.60
|
||||||
|
export var drum_min: float = 0.40
|
||||||
|
export var drum_max: float = 0.80
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
var fire = get_node(fire_path)
|
||||||
|
fire.connect("intensity_changed", self, "_on_fire_intensity_changed")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_fire_intensity_changed(value):
|
||||||
|
$Choir.volume_db = (smoothstep(choir_min, choir_max, value) - 1) * 60
|
||||||
|
$Bell.volume_db = (smoothstep(bell_min, bell_max, value) - 1) * 60
|
||||||
|
$Drum.volume_db = (smoothstep(drum_min, drum_max, value) - 1) * 60
|
||||||
|
pass
|
Loading…
Reference in a new issue