simple level selection menu, change level logic (#3)
This commit is contained in:
parent
9890e0a625
commit
59bed24acd
13 changed files with 199 additions and 134 deletions
|
@ -1,12 +1,22 @@
|
|||
[gd_scene load_steps=12 format=3 uid="uid://ovtknjyj83gh"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://w3fetao1pegm" path="res://levels/level.gd" id="1_rj40i"]
|
||||
[ext_resource type="PackedScene" uid="uid://cnnvwotv33u1b" path="res://elements/player.tscn" id="2_b00jj"]
|
||||
[ext_resource type="PackedScene" uid="uid://cpm3laywhlbq5" path="res://elements/ring.tscn" id="3_hel5x"]
|
||||
[ext_resource type="PackedScene" uid="uid://dw0xl8644x166" path="res://elements/gravity.tscn" id="3_muudg"]
|
||||
[ext_resource type="PackedScene" uid="uid://c77bli40240nk" path="res://elements/sign.tscn" id="4_atq6y"]
|
||||
[ext_resource type="PackedScene" uid="uid://dnuakh7n3fuij" path="res://levels/base/music.tscn" id="4_uq42r"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_1yugx"]
|
||||
script/source = "extends Level
|
||||
|
||||
func _init() -> void:
|
||||
self.id = \"base\"
|
||||
|
||||
func _on_player_velocity_change(new_velocity: float) -> void:
|
||||
self.velocity = new_velocity
|
||||
self.music.adaptInstrumentsToVelocity(new_velocity * 1.5)
|
||||
"
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_hs6gw"]
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_hyysp"]
|
||||
|
@ -30,7 +40,7 @@ ambient_light_color = Color(1, 1, 1, 1)
|
|||
reflected_light_source = 2
|
||||
|
||||
[node name="Base" type="Node3D"]
|
||||
script = ExtResource("1_rj40i")
|
||||
script = SubResource("GDScript_1yugx")
|
||||
metadata/_custom_type_script = "uid://w3fetao1pegm"
|
||||
|
||||
[node name="Gravity" parent="." instance=ExtResource("3_muudg")]
|
||||
|
@ -155,6 +165,8 @@ transform = Transform3D(0.0172464, 0.899835, 0, -0.899835, 0.0172464, 0, 0, 0, 0
|
|||
[node name="Ring13" parent="Rings" instance=ExtResource("3_hel5x")]
|
||||
transform = Transform3D(0.0114976, 0.59989, 0, -0.59989, 0.0114976, 0, 0, 0, 0.6, -414.274, 8.64172, 0)
|
||||
|
||||
[connection signal="velocity_change" from="Player" to="." method="_on_player_velocity_change"]
|
||||
|
||||
[editable path="Signs/Sign"]
|
||||
[editable path="Signs/Sign7"]
|
||||
[editable path="Signs/Sign2"]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
[gd_scene load_steps=11 format=3 uid="uid://e1761h6d522a"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://w3fetao1pegm" path="res://levels/level.gd" id="1_fdxcj"]
|
||||
[ext_resource type="PackedScene" uid="uid://dw0xl8644x166" path="res://elements/gravity.tscn" id="2_gxmta"]
|
||||
[ext_resource type="PackedScene" uid="uid://cnnvwotv33u1b" path="res://elements/player.tscn" id="2_mjogx"]
|
||||
[ext_resource type="PackedScene" uid="uid://cakmsiye3hjfe" path="res://levels/forest/music.tscn" id="3_n1xsx"]
|
||||
|
@ -8,6 +7,17 @@
|
|||
[ext_resource type="PackedScene" uid="uid://da6lkdiskdh8v" path="res://elements/tree.tscn" id="6_1e514"]
|
||||
[ext_resource type="PackedScene" uid="uid://c77bli40240nk" path="res://elements/sign.tscn" id="6_ifogr"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_mqwxc"]
|
||||
script/source = "extends Level
|
||||
|
||||
func _init() -> void:
|
||||
self.id = \"forest\"
|
||||
|
||||
func _on_player_velocity_change(new_velocity: float) -> void:
|
||||
self.velocity = new_velocity
|
||||
self.music.adaptInstrumentsToVelocity(new_velocity)
|
||||
"
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_grcut"]
|
||||
sky_top_color = Color(0, 0.504542, 0.579919, 1)
|
||||
sky_horizon_color = Color(9.62615e-08, 0.776269, 0.496436, 1)
|
||||
|
@ -29,7 +39,7 @@ ambient_light_color = Color(1, 1, 1, 1)
|
|||
reflected_light_source = 2
|
||||
|
||||
[node name="Forest" type="Node3D"]
|
||||
script = ExtResource("1_fdxcj")
|
||||
script = SubResource("GDScript_mqwxc")
|
||||
metadata/_custom_type_script = "uid://w3fetao1pegm"
|
||||
|
||||
[node name="Gravity" parent="." instance=ExtResource("2_gxmta")]
|
||||
|
@ -261,4 +271,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -218.208, 206.247, 0)
|
|||
[node name="Ring23" parent="Rings" instance=ExtResource("4_p8yhq")]
|
||||
transform = Transform3D(0.939693, 0.34202, 0, -0.34202, 0.939693, 0, 0, 0, 1, -1018.15, -96.9134, 0)
|
||||
|
||||
[connection signal="velocity_change" from="Player" to="." method="_on_player_velocity_change"]
|
||||
|
||||
[editable path="Sign"]
|
||||
|
|
|
@ -4,13 +4,15 @@ extends Node3D
|
|||
signal ring_collected
|
||||
signal completed
|
||||
|
||||
var seconds_spent: float = 0.00
|
||||
## Lowercase, spaceless name of the level
|
||||
var id: String
|
||||
var music: Music
|
||||
var velocity: float = 0.0
|
||||
var rings: Array[Ring] = []
|
||||
var finished_rings_count: int = 0
|
||||
|
||||
func _ready() -> void:
|
||||
assert(len(id) > 0, self.name + " has no id!")
|
||||
var children = get_children()
|
||||
for child in children:
|
||||
if is_instance_of(child, Music):
|
||||
|
@ -31,8 +33,3 @@ func collect_ring():
|
|||
|
||||
if finished_rings_count >= len(rings):
|
||||
completed.emit()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
seconds_spent += delta
|
||||
velocity = abs($Player.velocity.x) + abs($Player.velocity.y)
|
||||
music.adaptInstrumentsToVelocity(velocity, delta)
|
||||
|
|
|
@ -40,7 +40,9 @@ func changeVolume(db: float) -> void:
|
|||
AudioServer.set_bus_volume_db(bus_index, db + Settings.volume_music)
|
||||
AudioServer.set_bus_mute(bus_index, Settings.volume_music <= -15.0)
|
||||
|
||||
func adaptInstrumentsToVelocity(velocity: float, delta: float) -> void:
|
||||
func adaptInstrumentsToVelocity(velocity: float) -> void:
|
||||
## temp
|
||||
const delta = 0.00833333333333
|
||||
var instruments_needed = floor(velocity / 8)
|
||||
var instruments_playing = instruments.filter(func(i: AudioStreamPlayer): return i.volume_db > -50)
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://drnqmu4lka22d"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://w3fetao1pegm" path="res://levels/level.gd" id="1_3m1pa"]
|
||||
[ext_resource type="PackedScene" uid="uid://drfy3vhe6skp1" path="res://levels/night/music.tscn" id="1_npc74"]
|
||||
[ext_resource type="PackedScene" uid="uid://cnnvwotv33u1b" path="res://elements/player.tscn" id="2_bc1ig"]
|
||||
[ext_resource type="PackedScene" uid="uid://dw0xl8644x166" path="res://elements/gravity.tscn" id="2_lfplq"]
|
||||
|
@ -9,6 +8,21 @@
|
|||
[ext_resource type="PackedScene" uid="uid://b4jtpua36m6b1" path="res://elements/star.tscn" id="7_ltcl0"]
|
||||
[ext_resource type="PackedScene" uid="uid://da6lkdiskdh8v" path="res://elements/tree.tscn" id="8_kgstj"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_akhnt"]
|
||||
script/source = "extends Level
|
||||
|
||||
func _init() -> void:
|
||||
self.id = \"night\"
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
$Tree.rotate_x(delta / 3)
|
||||
$Tree.rotate_y(delta)
|
||||
|
||||
func _on_player_velocity_change(new_velocity: float) -> void:
|
||||
self.velocity = new_velocity
|
||||
self.music.adaptInstrumentsToVelocity(new_velocity * 2)
|
||||
"
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_x6q8u"]
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_lu6nv"]
|
||||
|
@ -28,7 +42,7 @@ ambient_light_color = Color(1, 1, 1, 1)
|
|||
reflected_light_source = 2
|
||||
|
||||
[node name="Night" type="Node3D"]
|
||||
script = ExtResource("1_3m1pa")
|
||||
script = SubResource("GDScript_akhnt")
|
||||
metadata/_custom_type_script = "uid://w3fetao1pegm"
|
||||
|
||||
[node name="Gravity" parent="." instance=ExtResource("2_lfplq")]
|
||||
|
@ -193,7 +207,7 @@ transform = Transform3D(-1.31134e-07, -3, 0, 3, -1.31134e-07, 0, 0, 0, 3, -104.2
|
|||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, -12.3896, -2, 0)
|
||||
|
||||
[node name="Tree" parent="." instance=ExtResource("8_kgstj")]
|
||||
transform = Transform3D(-3.79443, -7.04289, 0, 7.04289, -3.79443, 0, 0, 0, 8, 28.958, -413.185, -93.8242)
|
||||
transform = Transform3D(-3.79271, -7.04382, 0, 7.04382, -3.79271, 0, 0, 0, 8, 28.958, -413.185, -93.8242)
|
||||
|
||||
[node name="Signs" type="Node3D" parent="."]
|
||||
|
||||
|
@ -327,6 +341,8 @@ transform = Transform3D(-0.99693, 0.0731445, -0.0279554, -0.0555776, -0.912445,
|
|||
[node name="Star32" parent="Stars" instance=ExtResource("7_ltcl0")]
|
||||
transform = Transform3D(-0.99693, 0.0731445, -0.0279554, -0.0555776, -0.912445, -0.405407, -0.055161, -0.402609, 0.913709, 0.952739, 0.24193, 7.10684)
|
||||
|
||||
[connection signal="velocity_change" from="Player" to="." method="_on_player_velocity_change"]
|
||||
|
||||
[editable path="Signs/Sign"]
|
||||
[editable path="Signs/Sign4"]
|
||||
[editable path="Signs/Sign2"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue