chain levels with spaghetti

This commit is contained in:
Taevas 2025-02-23 00:46:23 +01:00
parent 7a18c4f8c6
commit 6a59b54c11
10 changed files with 465 additions and 15 deletions

View file

@ -18,7 +18,7 @@ func _process(_delta: float) -> void:
## Angle of the camera, so the player can see where the ball is going
var velocity: Vector3 = $Sphere.linear_velocity
var desired_x = max(min(velocity.y, 20), -20)
var desired_x = max(min(velocity.y, 35), -35)
var desired_y = max(min(-velocity.x, 50), -50)
var difference_x = $Camera.rotation_degrees.x - desired_x
var difference_y = $Camera.rotation_degrees.y - desired_y

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=7 format=3 uid="uid://cpm3laywhlbq5"]
[ext_resource type="Material" uid="uid://brwwlwb1rpro7" path="res://levels/base/material.tres" id="1_48h5f"]
[ext_resource type="Material" uid="uid://brwwlwb1rpro7" path="res://graphics/unhappy_material.tres" id="1_48h5f"]
[ext_resource type="AudioStream" uid="uid://b0cl5v6q1ocbv" path="res://sounds/ring1.ogg" id="2_2so43"]
[ext_resource type="AudioStream" uid="uid://cvvs74ep5d4wt" path="res://sounds/ring2.ogg" id="3_lkqw0"]
@ -10,12 +10,14 @@ script/source = "extends CSGTorus3D
var happy_material = preload(\"res://graphics/happy_material.tres\")
var collected = false
signal collect_signal
func _on_area_3d_body_entered(body: Node3D) -> void:
if collected == false and body.name == \"Sphere\":
self.material = happy_material
collected = true
$AudioStreamPlayer.play()
collect_signal.emit()
"
[sub_resource type="CylinderShape3D" id="CylinderShape3D_tgirv"]

View file

@ -41,9 +41,11 @@ func makeAudioStreamPlayers(music_name: String):
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
makeAudioStreamPlayers(\"base\")
for player in stream_players:
player.play()
var level = get_parent().get_parent()
if is_instance_valid(level) and level is Node3D:
makeAudioStreamPlayers(level.name.to_lower())
for player in stream_players:
player.play()
func handleMusicWithVelocity(velocity: float, delta: float) -> void:
var instruments_needed = floor(velocity / 7)