simple level selection menu, change level logic (#3)

This commit is contained in:
Taevas 2025-04-24 14:54:54 +02:00
parent 9890e0a625
commit 59bed24acd
Signed by: Taevas
SSH key fingerprint: SHA256:Y5Hv18xwPvUKSlgkx1sPnRO3L2mc03ehC7BzrnZVEyY
13 changed files with 199 additions and 134 deletions

View file

@ -4,7 +4,13 @@
script/source = "class_name Player
extends Node3D
var velocity: Vector3 = Vector3(0, 0, 0)
signal velocity_change
var velocity := 0.0:
get: return velocity
set(value):
if value != velocity:
velocity_change.emit(value)
velocity = value
func _physics_process(_delta: float) -> void:
$SpotLightMain.position = $Sphere.position + Vector3(0, 5, 0)
@ -13,22 +19,21 @@ func _physics_process(_delta: float) -> void:
$SpotLightRight.position = $Sphere.position
$SpotLightBottom.position = $Sphere.position
## Keep the ball at the center of the camera, at a distance
# Keep the ball at the center of the camera, at a distance
$Camera.position = $Sphere.position + Vector3(0, 0, 15)
## Angle of the camera, so the player can see where the ball is going
velocity = $Sphere.linear_velocity
var desired_x = max(min(velocity.y, 35), -35)
var desired_y = max(min(-velocity.x, 50), -50)
# Angle of the camera, so the player can see where the ball is going
velocity = abs($Sphere.linear_velocity.x) + abs($Sphere.linear_velocity.y)
var desired_x = max(min($Sphere.linear_velocity.y, 35), -35)
var desired_y = max(min(-$Sphere.linear_velocity.x, 50), -50)
var difference_x = $Camera.rotation_degrees.x - desired_x
var difference_y = $Camera.rotation_degrees.y - desired_y
$Camera.rotation_degrees.x -= max(min(difference_x / 2, 3), -3)
$Camera.rotation_degrees.y -= max(min(difference_y / 2, 3), -3)
## FOV of the camera, so it unzooms more at higher velocities
# FOV of the camera, so it unzooms more at higher velocities
const default_fov = 75
var total_velocity = abs(velocity.x) + abs(velocity.y)
$Camera.fov = default_fov + (total_velocity / 12)
$Camera.fov = default_fov + (velocity / 12)
"
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_vumbr"]

View file

@ -29,6 +29,7 @@ vertex_color_use_as_albedo = true
albedo_color = Color(0.212217, 0.468618, 0, 1)
[node name="Tree" type="Node3D"]
physics_interpolation_mode = 2
script = SubResource("GDScript_tbkod")
[node name="Dirt" type="CSGBox3D" parent="."]