From d58328992ce0d362299b3f3c2599c05f1d8eee85 Mon Sep 17 00:00:00 2001 From: Juan Pa Date: Mon, 23 Nov 2026 18:01:53 -0800 Subject: [PATCH] test(platformer): wait for the spawn to land instead of counting 12 frames The Orbital Ops and Enchanted Repo smoke suites checked is_on_floor() a fixed 12 physics frames after change_scene_to_file(). Godot's physics clock lags the engine's own start-up, so the first process frame runs a burst of catch-up steps (up to the 8-step cap) before the deferred scene swap lands. Start-up grew from ~115 ms (#40) to ~230 ms (mostly #97), so 7 of the 12 awaited frames now pass with no scene present and the 10 px drop onto the floor needs 7 real steps. Both checks now wait_for the spawned player to touch the floor, as the later checks already do. Co-Authored-By: Claude --- hoppys-adventure-arcade/tests/enchanted_repo_smoke.gd | 10 ++++++++-- hoppys-adventure-arcade/tests/orbital_ops_smoke.gd | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/hoppys-adventure-arcade/tests/enchanted_repo_smoke.gd b/hoppys-adventure-arcade/tests/enchanted_repo_smoke.gd index 177856d5..0b5a42fe 100644 --- a/hoppys-adventure-arcade/tests/enchanted_repo_smoke.gd +++ b/hoppys-adventure-arcade/tests/enchanted_repo_smoke.gd @@ -30,14 +30,20 @@ func place(pos: Vector2) -> void: func release() -> void: for action in ["jump","move_right","move_left","attack"]: Input.action_release(action) +func spawned_on_floor() -> bool: + var scene := current_scene + return scene!=null and scene.get("player")!=null and scene.player.is_on_floor() + func run() -> void: change_scene_to_file("res://scenes/platformer/enchanted_repo.tscn") - await frames(12) + # Engine start-up leaves the physics clock behind, so the first process frame runs a burst of + # catch-up steps before the deferred scene swap lands; count on the floor, not on frames. + await wait_for(spawned_on_floor,2.0,"Fresh run spawns on visible ground") level=current_scene player=level.player + check(player.hp==3,"Fresh run starts at full health") await process_frame level._resume() - check(player.hp==3 and player.is_on_floor(),"Fresh run spawns on visible ground") check(level.music.stream==level.FOREST_MUSIC,"The Enchanted Repo theme starts traversal") check(not level.boss.active and level.boss.hp==12,"Monolith waits with intact armor") await capture("/tmp/enchanted-spawn.png") diff --git a/hoppys-adventure-arcade/tests/orbital_ops_smoke.gd b/hoppys-adventure-arcade/tests/orbital_ops_smoke.gd index 6d2b642c..c9df9983 100644 --- a/hoppys-adventure-arcade/tests/orbital_ops_smoke.gd +++ b/hoppys-adventure-arcade/tests/orbital_ops_smoke.gd @@ -25,14 +25,20 @@ func place(pos: Vector2) -> void: player.reset_physics_interpolation() level.camera.reset_smoothing() +func spawned_on_floor() -> bool: + var scene := current_scene + return scene!=null and scene.get("player")!=null and scene.player.is_on_floor() + func run() -> void: change_scene_to_file("res://scenes/platformer/orbital_ops.tscn") - await frames(12) + # Engine start-up leaves the physics clock behind, so the first process frame runs a burst of + # catch-up steps before the deferred scene swap lands; count on the floor, not on frames. + await wait_for(spawned_on_floor,2.0,"Spawn settles on visible station floor") level=current_scene player=level.player + check(player.hp==3,"Fresh run starts at full health") await process_frame level._resume() - check(player.hp==3 and player.is_on_floor(),"Spawn settles on visible station floor") check(level.music.stream==level.ORBITAL_LEVEL_MUSIC,"Zero-G Deploy starts traversal") check(level.projectiles.get_child_count()==0 and not level.boss.active,"Fresh run starts with inactive boss and no shots") await capture("/tmp/orbital-spawn.png")