#139: the prologue's debris belt keeps off the screen too

The belt was laid out with its own arithmetic - a centre BELT_AHEAD in front
of the fleet, rocks spread BELT_DEPTH either side of it - so its near edge
reached back to within a screen of the convoy. At the aspect it was
eyeballed on that was just outside the view; at a wider one, or any zoom
out, rocks appeared in plain sight.

#126 already answered this question for the rest of the game, so the answer
is borrowed rather than restated: AsteroidField's keep-out rect and its
push-out-through-the-nearest-edge placement are public now, and the belt
runs through them. That also means the two cannot drift apart later.

The distance moves as well, 2200 to 2900. The clamp alone would work, but it
would work by pressing every stray rock onto the boundary line; with the
belt properly out in front, the clamp has almost nothing left to do and the
belt still looks laid out ahead rather than pinned to the edge of the
screen. Measured: nearest rock 1551 units out, against a keep-out that
reaches 1100.
This commit is contained in:
Loïc Wisniewski 2026-08-28 15:37:11 +02:00
commit ac4b96ef49
6 changed files with 51 additions and 144 deletions

View file

@ -15,7 +15,7 @@ extends SceneTree
# materialise in plain sight several hundred pixels away.
#
# Verifies:
# 1. _safe_position never returns a point inside the keep-out area, for
# 1. safe_position never returns a point inside the keep-out area, for
# candidates all around it and including its exact centre. Checked
# directly rather than by looking at where asteroids happened to land:
# with ~54 asteroids over 25 chunks, any single run only rarely
@ -60,7 +60,7 @@ func _process(delta: float) -> bool:
var centre: Vector2 = fleet.get_centroid()
var safe: float = field.safe_spawn_radius
var keep_out: Rect2 = field._keep_out_rect(centre)
var keep_out: Rect2 = field.keep_out_rect(centre)
# --- 3. the keep-out area is the screen, not the old bubble ---
var on_screen: Rect2 = ViewUtils.get_visible_world_rect(field)
@ -89,11 +89,11 @@ func _process(delta: float) -> bool:
var candidate: Vector2 = keep_out.get_center() + dir * d
if not keep_out.has_point(candidate):
continue
if keep_out.has_point(field._safe_position(candidate, keep_out)):
if keep_out.has_point(field.safe_position(candidate, keep_out)):
let_one_through = true
# Candidates already outside must be returned untouched.
var outside: Vector2 = keep_out.get_center() + dir * (reach * 3.0)
if field._safe_position(outside, keep_out).distance_to(outside) > 0.001:
if field.safe_position(outside, keep_out).distance_to(outside) > 0.001:
moved_an_outside_one = true
if let_one_through:
print("TEST_ASTEROID_SAFE_SPAWN: FAIL (the guard left a spawn inside the visible area)")

View file

@ -32,6 +32,7 @@ extends SceneTree
# P. #128 - the prologue opens STOPPED behind its first line, and
# acknowledging it is what starts the world
# Q. #133 - the handover runs straight into the first quest
# R. #139 - no belt rock is laid down inside the visible screen
var game_state: Node
var scene: Node
@ -276,6 +277,26 @@ func _process(delta: float) -> bool:
% [ahead, standing.size()])
print("belt: %d rocks, %d of them across the lane ahead" % [standing.size(), ahead])
# --- R. #139: and none of it appears on screen ------------
# The belt used to be laid out with its own arithmetic, which put
# its near edge within a screen of the fleet - so rocks popped
# into existence in view. It goes through the asteroid field's
# own keep-out now, the same one #126 gave the rest of the game.
var field: Node2D = scene.get_node("AsteroidField")
var keep_out: Rect2 = field.keep_out_rect(fleet.get_centroid())
var visible_rect: Rect2 = ViewUtils.get_visible_world_rect(field)
if visible_rect.size.x > 1.0 and not keep_out.encloses(visible_rect):
return _fail("the belt's keep-out %s does not cover the screen %s" \
% [keep_out, visible_rect])
var nearest: float = 1.0e9
for rock in standing:
if keep_out.has_point(rock.global_position):
return _fail("a belt rock was laid down at %s, inside the view %s" \
% [rock.global_position, keep_out])
nearest = minf(nearest, absf(rock.global_position.y - fleet.get_centroid().y))
print("no belt rock inside the keep-out %.0fx%.0f; nearest is %.0f ahead" \
% [keep_out.size.x, keep_out.size.y, nearest])
# --- G. the breach takes the wheel ----------------------
director._begin(director.Beat.BREACH)
if not game_state.intro_locks_movement: