Feat/1 movement foundation #5
@@ -0,0 +1,91 @@
|
|||||||
|
extends Node3D
|
||||||
|
class_name TestLevelBuilder
|
||||||
|
## Builds the test level ONLY from code — no .tscn SubResource references.
|
||||||
|
## Attach to a Node3D and call build() from _ready().
|
||||||
|
|
||||||
|
func build() -> void:
|
||||||
|
_build_floor()
|
||||||
|
_build_walls()
|
||||||
|
_build_lighting()
|
||||||
|
_build_camera()
|
||||||
|
_build_ui()
|
||||||
|
|
||||||
|
|
||||||
|
func _box_static(pos: Vector3, size: Vector3, color: Color) -> StaticBody3D:
|
||||||
|
var body := StaticBody3D.new()
|
||||||
|
body.position = pos
|
||||||
|
body.name = "Static_" + str(pos)
|
||||||
|
add_child(body)
|
||||||
|
var shape := CollisionShape3D.new()
|
||||||
|
shape.shape = BoxShape3D.new()
|
||||||
|
shape.shape.size = size
|
||||||
|
body.add_child(shape)
|
||||||
|
var mesh := MeshInstance3D.new()
|
||||||
|
mesh.mesh = BoxMesh.new()
|
||||||
|
mesh.mesh.size = size
|
||||||
|
var mat := StandardMaterial3D.new()
|
||||||
|
mat.albedo_color = color
|
||||||
|
mesh.mesh.surface_set_material(0, mat)
|
||||||
|
body.add_child(mesh)
|
||||||
|
return body
|
||||||
|
|
||||||
|
|
||||||
|
func _build_floor() -> void:
|
||||||
|
_box_static(Vector3(0, -1.1, 0), Vector3(30, 0.4, 30), Color(0.35, 0.25, 0.15))
|
||||||
|
|
||||||
|
|
||||||
|
func _build_walls() -> void:
|
||||||
|
# Thin, tall walls for wallrun / walljump testing
|
||||||
|
_box_static(Vector3(0, 3, -15), Vector3(30, 6, 0.4), Color(0.55, 0.45, 0.35))
|
||||||
|
_box_static(Vector3(15, 3, 0), Vector3(0.4, 6, 30), Color(0.55, 0.45, 0.35))
|
||||||
|
_box_static(Vector3(-15, 3, 0), Vector3(0.4, 6, 30), Color(0.55, 0.45, 0.35))
|
||||||
|
|
||||||
|
|
||||||
|
func _build_lighting() -> void:
|
||||||
|
var sun := DirectionalLight3D.new()
|
||||||
|
sun.name = "Sun"
|
||||||
|
sun.position = Vector3(0, 10, 0)
|
||||||
|
sun.rotation_degrees = Vector3(50, 0, 0)
|
||||||
|
sun.light_color = Color(1, 0.95, 0.85)
|
||||||
|
sun.light_energy = 1.1
|
||||||
|
sun.shadow_enabled = true
|
||||||
|
add_child(sun)
|
||||||
|
|
||||||
|
|
||||||
|
func _build_camera() -> void:
|
||||||
|
var cam := Camera3D.new()
|
||||||
|
cam.name = "FpsCamera"
|
||||||
|
cam.current = true
|
||||||
|
cam.position = Vector3(0, 1.7, 0)
|
||||||
|
cam.fov = 90.0
|
||||||
|
add_child(cam)
|
||||||
|
# Spawn marker
|
||||||
|
var spawn := Node3D.new()
|
||||||
|
spawn.name = "PlayerSpawn"
|
||||||
|
spawn.position = Vector3(0, 1.5, 8)
|
||||||
|
add_child(spawn)
|
||||||
|
|
||||||
|
|
||||||
|
func _build_ui() -> void:
|
||||||
|
var canvas := CanvasLayer.new()
|
||||||
|
canvas.name = "UI"
|
||||||
|
add_child(canvas)
|
||||||
|
var speed := Label.new()
|
||||||
|
speed.name = "SpeedLabel"
|
||||||
|
speed.offset_left = 16
|
||||||
|
speed.offset_top = 16
|
||||||
|
speed.offset_right = 520
|
||||||
|
speed.offset_bottom = 48
|
||||||
|
speed.text = "Speed: 0.0 m/s | State: --- | Chain: +0%"
|
||||||
|
canvas.add_child(speed)
|
||||||
|
var help := Label.new()
|
||||||
|
help.name = "HelpLabel"
|
||||||
|
help.offset_left = 16
|
||||||
|
help.offset_top = 52
|
||||||
|
help.offset_right = 720
|
||||||
|
help.offset_bottom = 108
|
||||||
|
help.text = (
|
||||||
|
"WASD Move | Sprint=Shift | Slide=Ctrl+S | "
|
||||||
|
"Double-Jump=Space twice | Dash=LShift | Wall-Jump=Jump at wall"
|
||||||
|
)
|
||||||
|
canvas.add_child(help)
|
||||||
+1
-1
@@ -11,7 +11,7 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Papaya-Shooter"
|
config/name="Papaya-Shooter"
|
||||||
config/features=PackedStringArray("4.2", "Forward Plus")
|
config/features=PackedStringArray("4.6", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|||||||
@@ -1,81 +1,3 @@
|
|||||||
[gd_scene load_steps=5 format=3]
|
[gd_scene format=3]
|
||||||
|
|
||||||
[node name="TestLevel" type="Node3D"]
|
[node name="TestLevel" type="Node3D"]
|
||||||
|
|
||||||
[node name="StaticFloor" type="StaticBody3D" parent="."]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.1, 0)
|
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticFloor"]
|
|
||||||
shape = SubResource(1)
|
|
||||||
|
|
||||||
[node name="FloorMesh" type="MeshInstance3D" parent="StaticFloor"]
|
|
||||||
mesh = BoxMesh.new()
|
|
||||||
|
|
||||||
[node name="WallN" type="StaticBody3D" parent="."]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, -15)
|
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="WallN"]
|
|
||||||
shape = SubResource(2)
|
|
||||||
|
|
||||||
[node name="WallEMesh" type="MeshInstance3D" parent="WallE"]
|
|
||||||
mesh = BoxMesh.new()
|
|
||||||
|
|
||||||
[node name="WallE" type="StaticBody3D" parent="."]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 15, 3, 0)
|
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="WallE"]
|
|
||||||
shape = SubResource(3)
|
|
||||||
|
|
||||||
[node name="WallEMesh" type="MeshInstance3D" parent="WallE"]
|
|
||||||
mesh = BoxMesh.new()
|
|
||||||
|
|
||||||
[node name="WallW" type="StaticBody3D" parent="."]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -15, 3, 0)
|
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="WallW"]
|
|
||||||
shape = SubResource(4)
|
|
||||||
|
|
||||||
[node name="WallWMesh" type="MeshInstance3D" parent="WallW"]
|
|
||||||
mesh = BoxMesh.new()
|
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.866025, 0.5, 0, -0.5, 0.866025, 0, 8, 0)
|
|
||||||
light_color = Color(1, 0.95, 0.85, 1)
|
|
||||||
light_energy = 1.0
|
|
||||||
shadow_enabled = true
|
|
||||||
|
|
||||||
[node name="PlayerSpawn" type="Node3D" parent="."]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 8)
|
|
||||||
|
|
||||||
[node name="UI" type="CanvasLayer" parent="."]
|
|
||||||
|
|
||||||
[node name="SpeedLabel" type="Label" parent="UI"]
|
|
||||||
offset_left = 16.0
|
|
||||||
offset_top = 16.0
|
|
||||||
offset_right = 480.0
|
|
||||||
offset_bottom = 48.0
|
|
||||||
text = "Speed: 0.0 m/s | State: --- | Chain: +0%"
|
|
||||||
|
|
||||||
[node name="HelpLabel" type="Label" parent="UI"]
|
|
||||||
offset_left = 16.0
|
|
||||||
offset_top = 52.0
|
|
||||||
offset_right = 620.0
|
|
||||||
offset_bottom = 108.0
|
|
||||||
text = "WASD Move | Sprint=Shift | Slide=Ctrl+S | Double-Jump=Space twice | Dash=LShift | Wall-Jump=Jump at wall"
|
|
||||||
|
|
||||||
[node name="FpsCamera" type="Camera3D" parent="."]
|
|
||||||
current = true
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.7, 0)
|
|
||||||
fov = 90.0
|
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="1"]
|
|
||||||
size = Vector3(30, 0.4, 30)
|
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="2"]
|
|
||||||
size = Vector3(30, 6, 0.4)
|
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="3"]
|
|
||||||
size = Vector3(30, 6, 0.4)
|
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="4"]
|
|
||||||
size = Vector3(30, 6, 0.4)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user