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:
@@ -32,9 +32,10 @@ typedef enum EntityType {
|
||||
} EntityType;
|
||||
|
||||
/* Entity flags */
|
||||
#define ENTITY_INVINCIBLE (1 << 0)
|
||||
#define ENTITY_FACING_LEFT (1 << 1)
|
||||
#define ENTITY_DEAD (1 << 2)
|
||||
#define ENTITY_INVINCIBLE (1 << 0)
|
||||
#define ENTITY_FACING_LEFT (1 << 1)
|
||||
#define ENTITY_DEAD (1 << 2)
|
||||
#define ENTITY_ALWAYS_UPDATE (1 << 3) /* never culled by distance */
|
||||
|
||||
typedef struct Entity {
|
||||
EntityType type;
|
||||
@@ -66,7 +67,8 @@ typedef struct EntityManager {
|
||||
void entity_manager_init(EntityManager *em);
|
||||
Entity *entity_spawn(EntityManager *em, EntityType type, Vec2 pos);
|
||||
void entity_destroy(EntityManager *em, Entity *e);
|
||||
void entity_update_all(EntityManager *em, float dt, const Tilemap *map);
|
||||
void entity_update_all(EntityManager *em, float dt, const Tilemap *map,
|
||||
const Camera *cam);
|
||||
void entity_render_all(EntityManager *em, const Camera *cam);
|
||||
void entity_manager_clear(EntityManager *em);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user