Support large maps up to 8192x8192 tiles

Raise hard map size cap from 4096 to 8192 via MAX_MAP_SIZE constant.
Replace fixed 16 KB fgets buffer with dynamic line reader that handles
arbitrarily long tile rows. Check calloc returns for tile layer
allocation.

Add entity distance culling: skip updates for entities beyond 2x screen
width from camera, skip rendering beyond 64 px margin. Dead entities
bypass culling so cleanup callbacks always run. Player, spacecraft,
drone, and moving platforms set ENTITY_ALWAYS_UPDATE to opt out.

Replace naive 4-neighbor flood fill with scanline algorithm (O(height)
stack instead of O(area)) for safe use on large maps.

Raise MAX_ENTITY_SPAWNS from 128 to 512 and MAX_EXIT_ZONES from 8 to
16 to support populated large levels.
This commit is contained in:
Thomas
2026-03-01 15:17:58 +00:00
parent ad2d68a8b4
commit df3bc29fb7
11 changed files with 181 additions and 45 deletions

View File

@@ -526,7 +526,7 @@ void level_update(Level *level, float dt) {
}
/* Update all entities */
entity_update_all(&level->entities, dt, &level->map);
entity_update_all(&level->entities, dt, &level->map, &level->camera);
/* Handle collisions (only meaningful once player exists) */
if (level->player_spawned) {