Replaces the fixed centred arena with per-world tile geometry, which is the foundation the remaining features sit on. - MapGrid: tile grid with three independent flags -- blocks movement, bullets, sight -- so a pit stops feet but not bullets or eyes, and a barricade stops feet and bullets but not eyes. Circle collision with per-axis sliding, and Bresenham line of sight shared by fog and aggro. - MapGen: rooms and corridors generated from (seed, depth), with hand-authored boss arenas from Rooms stamped in first so a corridor can never carve through a designed fight. Reachability from spawn to boss is asserted over 40 seeds -- "usually connected" is the failure mode that ruins one run in twenty. - Dungeons are populated at creation, per room, instead of gating on waves. You explore and choose your fights; the run ends when the boss dies, not when the map is swept. Boss rooms have no lock, so walking out is always available. - Aggro: enemies need range AND line of sight, so a dungeon stays quiet until engaged and cover actually protects. - Hard fog, scrolling camera, and terrain rendering. Maps are streamed per peer in chunks around that peer's player, and the seed is deliberately NOT sent -- a client holding it could regenerate the whole dungeon, which is a map hack for free. Stream radius (900u) is wider than view radius (460u) because the client predicts movement against walls and simulates bullets that die on them; the accepted cost is a cheater seeing a little further than the fog, never the floor plan. Partial map knowledge means wall deaths must be announced rather than derived. A test caught the subtle half of that: out-of-bounds tiles read as WALL by design, so checking geometry before bounds reported every bullet leaving the map as a wall kill. 128 tests (was 103); check.sh, test.sh and smoke.sh pass. 0.26 ms/tick with 4 players and a boss, ~65x headroom.
This commit is contained in:
@@ -3,10 +3,17 @@ extends GutTest
|
||||
## would end the run, so its slot bookkeeping is tested directly.
|
||||
|
||||
var pool: BulletPool
|
||||
var map: MapGrid
|
||||
|
||||
|
||||
func before_each() -> void:
|
||||
pool = BulletPool.new()
|
||||
# Bullets now die against real geometry rather than a global rectangle, so
|
||||
# the pool needs a map to cull against at all.
|
||||
map = MapGrid.new(42, 24, MapGrid.Kind.WALL)
|
||||
map.fill_rect(Rect2i(1, 1, 40, 22), MapGrid.Kind.FLOOR)
|
||||
map.centre_on_origin()
|
||||
pool.map = map
|
||||
|
||||
|
||||
func _spawn(p := Vector2.ZERO, v := Vector2(100, 0), life := 60) -> int:
|
||||
@@ -57,11 +64,45 @@ func test_bullets_expire_at_end_of_life() -> void:
|
||||
assert_eq(pool.live_count, 0)
|
||||
|
||||
|
||||
func test_bullets_leaving_the_arena_are_culled() -> void:
|
||||
var start := Vector2(SimConfig.ARENA_HALF.x, 0.0)
|
||||
func test_bullets_leaving_the_map_are_culled() -> void:
|
||||
var start := Vector2(map.world_rect().end.x, 0.0)
|
||||
var a := _spawn(start, Vector2(100000, 0), 600)
|
||||
pool.step()
|
||||
assert_eq(pool.alive[a], 0, "a bullet past the cull margin must not linger")
|
||||
assert_eq(pool.wall_kill_log.size(), 0,
|
||||
"leaving the map is derivable from the map size, so it is not announced")
|
||||
|
||||
|
||||
func test_bullets_stopped_by_a_wall_are_logged_for_announcement() -> void:
|
||||
# A client is only streamed the map near itself, so it cannot work out that
|
||||
# a bullet hit a wall it has never been sent. The server has to say so.
|
||||
var a := _spawn(map.tile_centre(2, 12), Vector2(-600.0, 0.0), 600)
|
||||
var id: int = pool.uid[a]
|
||||
for _i in 10:
|
||||
pool.step()
|
||||
assert_eq(pool.alive[a], 0)
|
||||
assert_true(pool.wall_kill_log.has(id), "wall deaths must be announceable")
|
||||
|
||||
|
||||
## Wall collision samples the bullet's position once per tick, so a bullet that
|
||||
## travels more than one tile per tick can step straight over a wall. Nothing in
|
||||
## the game comes close today, but a future "fast projectile" upgrade could, and
|
||||
## it would look like walls randomly failing.
|
||||
func test_bullet_speeds_stay_below_the_tunnelling_threshold() -> void:
|
||||
var limit := MapGrid.TILE / SimConfig.TICK_DELTA
|
||||
assert_lt(SimConfig.PLAYER_BULLET_SPEED * 2.0, limit,
|
||||
"even at the doubled speed an upgrade could grant, a bullet must not " +
|
||||
"cross a whole tile in one tick or it will tunnel through walls")
|
||||
|
||||
|
||||
func test_a_pool_with_no_map_does_not_cull() -> void:
|
||||
# Standalone pools (used by emitter tests) have no geometry; culling
|
||||
# against nothing would silently delete their bullets.
|
||||
var bare := BulletPool.new()
|
||||
var a := bare.spawn(Vector2(1.0e6, 0.0), Vector2.ZERO, 5.0, 60, 10,
|
||||
SimConfig.TEAM_ENEMY, SimConfig.KIND_ORB)
|
||||
bare.step()
|
||||
assert_eq(bare.alive[a], 1)
|
||||
|
||||
|
||||
func test_pool_saturation_returns_minus_one_rather_than_growing() -> void:
|
||||
|
||||
Reference in New Issue
Block a user