WIP: add Camera3D, fix jump/forward-direction bugs, add mouse capture, build game.tscn composition
This commit is contained in:
@@ -18,13 +18,15 @@ func _initialize() -> void:
|
||||
|
||||
func _run() -> void:
|
||||
await process_frame
|
||||
print("SMOKE: loading test level scene")
|
||||
print("SMOKE: loading game scene")
|
||||
|
||||
# Load the test level scene (which includes the player). Use the same
|
||||
# SceneTree API as the real game so `current_scene` is populated before
|
||||
# the scene is added and its _ready() callbacks fire. That ordering is
|
||||
# what the player's spawn lookup (get_tree().current_scene) depends on.
|
||||
var packed: PackedScene = load("res://scenes/worlds/test_level.tscn")
|
||||
# Load scenes/game.tscn -- the real PC2 composition point (Level + Player
|
||||
# as siblings, per docs/architecture/pc2_test_level.md §4), not the level
|
||||
# scene directly. Use the same SceneTree API as the real game so
|
||||
# `current_scene` is populated before the scene is added and its
|
||||
# _ready() callbacks fire. That ordering is what the player's spawn
|
||||
# lookup (get_tree().current_scene) depends on.
|
||||
var packed: PackedScene = load("res://scenes/game.tscn")
|
||||
var result := change_scene_to_packed(packed)
|
||||
if result != OK:
|
||||
printerr("SMOKE: failed to change scene, error ", result)
|
||||
@@ -32,11 +34,11 @@ func _run() -> void:
|
||||
return
|
||||
|
||||
await scene_changed
|
||||
var level: Node3D = current_scene as Node3D
|
||||
print("SMOKE: level ready")
|
||||
var game: Node3D = current_scene as Node3D
|
||||
print("SMOKE: game scene ready")
|
||||
|
||||
# 1. Verify the player node exists in the scene tree.
|
||||
var player: Node = level.get_node("Player")
|
||||
var player: Node = game.get_node("Player")
|
||||
_check("Player node exists in test level", player != null)
|
||||
_check("Player is a CharacterBody3D", player is CharacterBody3D)
|
||||
|
||||
@@ -52,13 +54,12 @@ func _run() -> void:
|
||||
mesh is MeshInstance3D and (mesh as MeshInstance3D).mesh != null)
|
||||
|
||||
# 3. Verify the player spawned at the PlayerSpawn marker position.
|
||||
var spawn_marker: Marker3D = level.get_node("PlayerSpawn")
|
||||
var spawn_marker: Marker3D = game.get_node("Level/PlayerSpawn")
|
||||
_check("PlayerSpawn marker exists", spawn_marker != null)
|
||||
|
||||
# The player's _ready() should have moved it to the spawn marker's
|
||||
# global position. Since both are direct children of the level root
|
||||
# (and the level root is at the origin), their global positions equal
|
||||
# their local positions.
|
||||
# global position. Compare global positions directly (not local) since
|
||||
# Player and Level sit at different depths under Game.
|
||||
var expected_pos: Vector3 = spawn_marker.global_position
|
||||
_check("Player spawned at PlayerSpawn position",
|
||||
player.global_position == expected_pos)
|
||||
@@ -71,6 +72,13 @@ func _run() -> void:
|
||||
_check("Player has WALK_SPEED constant", constants.has("WALK_SPEED"))
|
||||
_check("Player has GRAVITY constant", constants.has("GRAVITY"))
|
||||
_check("Player has JUMP_VELOCITY constant", constants.has("JUMP_VELOCITY"))
|
||||
_check("JUMP_VELOCITY is positive (upward)", float(constants.get("JUMP_VELOCITY", -1.0)) > 0.0)
|
||||
|
||||
# 5. Verify the player has a Camera3D so the game is actually viewable
|
||||
# from the player's perspective, not just a walking capsule with no view.
|
||||
var camera: Node = player.get_node_or_null("Camera3D")
|
||||
_check("Player has a Camera3D", camera is Camera3D)
|
||||
_check("Camera3D is current", camera is Camera3D and (camera as Camera3D).current)
|
||||
|
||||
print("\n=== SMOKE RESULT: %d/%d passed ===" % [_passed, _passed + _failed])
|
||||
quit(0 if _failed == 0 else 1)
|
||||
|
||||
Reference in New Issue
Block a user