lock in the first level

This commit is contained in:
Taevas 2025-02-22 19:46:19 +01:00
parent 3b56cd4c81
commit 7a18c4f8c6
14 changed files with 201 additions and 16 deletions

View file

@ -6,12 +6,14 @@
[sub_resource type="GDScript" id="GDScript_3yq1l"]
script/source = "extends Control
var player_ready = false
const normal = 7
const stronger = normal * 3
func _process(delta: float) -> void:
var grav = stronger if Input.is_key_pressed(KEY_SHIFT) else normal
PhysicsServer3D.area_set_param(get_viewport().find_world_3d().space, PhysicsServer3D.AREA_PARAM_GRAVITY, grav)
if player_ready:
var grav = stronger if Input.is_key_pressed(KEY_SHIFT) else normal
PhysicsServer3D.area_set_param(get_viewport().find_world_3d().space, PhysicsServer3D.AREA_PARAM_GRAVITY, grav)
"
[sub_resource type="GDScript" id="GDScript_my602"]
@ -43,10 +45,11 @@ func _input(ev: InputEvent) -> void:
self.rotation_degrees = 90
$AudioStreamPlayer.pitch_scale = 0.95
if direction != PhysicsServer3D.area_get_param(
if get_parent().player_ready == false or direction != PhysicsServer3D.area_get_param(
get_viewport().find_world_3d().space,
PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR
):
get_parent().player_ready = true
PhysicsServer3D.area_set_param(
get_viewport().find_world_3d().space,
PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR,

View file

@ -7,8 +7,6 @@
script/source = "extends Node3D
func _process(_delta: float) -> void:
#if $Sphere.position.y < -2:
# $Sphere.position.y = 0
$SpotLightMain.position = $Sphere.position + Vector3(0, 5, 0)
$SpotLightTop.position = $Sphere.position
$SpotLightLeft.position = $Sphere.position
@ -20,12 +18,12 @@ 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 / 2, 20), -20)
var desired_y = max(min(-velocity.x / 2, 45), -45)
var desired_x = max(min(velocity.y, 20), -20)
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
$Camera.rotation_degrees.x -= max(min(difference_x / 4, 3), -3)
$Camera.rotation_degrees.y -= max(min(difference_y / 4, 3), -3)
$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
const default_fov = 75

View file

@ -1,25 +1,39 @@
[gd_scene load_steps=3 format=3 uid="uid://cpm3laywhlbq5"]
[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="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"]
[sub_resource type="GDScript" id="GDScript_86vhg"]
script/source = "extends CSGTorus3D
var happy_material = preload(\"res://graphics/happy_material.tres\")
var collected = false
func _on_area_3d_body_entered(body: Node3D) -> void:
if collected == false and body.name == \"Sphere\":
print(\"YES \", body)
self.material = happy_material
collected = true
$AudioStreamPlayer.play()
"
[sub_resource type="CylinderShape3D" id="CylinderShape3D_tgirv"]
radius = 4.0
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_251sn"]
random_pitch = 1.3
streams_count = 2
stream_0/stream = ExtResource("2_2so43")
stream_1/stream = ExtResource("3_lkqw0")
[node name="Ring" type="CSGTorus3D"]
use_collision = true
inner_radius = 4.0
outer_radius = 8.0
sides = 16
ring_sides = 8
material = ExtResource("1_48h5f")
script = SubResource("GDScript_86vhg")
[node name="Area3D" type="Area3D" parent="."]
@ -27,4 +41,7 @@ script = SubResource("GDScript_86vhg")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
shape = SubResource("CylinderShape3D_tgirv")
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = SubResource("AudioStreamRandomizer_251sn")
[connection signal="body_entered" from="Area3D" to="." method="_on_area_3d_body_entered"]

18
elements/sign.tscn Normal file
View file

@ -0,0 +1,18 @@
[gd_scene format=3 uid="uid://c77bli40240nk"]
[node name="Sign" type="Node3D"]
[node name="Text" type="Label3D" parent="."]
text = "Sample text"
font_size = 1024
[node name="CSGBox3D" type="CSGBox3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5.1)
use_collision = true
size = Vector3(80, 30, 10)
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -138.981, -5)
use_collision = true
radius = 4.0
height = 256.0