#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:
parent
1ece202731
commit
ac4b96ef49
6 changed files with 51 additions and 144 deletions
|
|
@ -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)")
|
||||
|
|
|
|||
Loading…
Reference in a new issue