Fixed entity unloading on chunk

This commit is contained in:
2025-06-18 21:20:46 -05:00
parent ee22aadcc7
commit 3f22665e21
6 changed files with 23 additions and 61 deletions

View File

@ -105,7 +105,7 @@ void drawOverworldDraw(void) {
entity_t *entity = ENTITIES;
do {
drawOverworldDrawEntity(entity++);
} while(entity->type != ENTITY_TYPE_NULL);
} while(entity < ENTITIES + ENTITY_COUNT_MAX);
EndMode2D();
}
@ -113,6 +113,7 @@ void drawOverworldDraw(void) {
void drawOverworldDrawEntity(const entity_t *entity) {
assertNotNull(entity, "Entity pointer cannot be NULL");
if(entity->type == ENTITY_TYPE_NULL) return; // Skip null entities
uint32_t x = fx248Tou32(entity->x);
uint32_t y = fx248Tou32(entity->y);
@ -130,47 +131,4 @@ void drawOverworldDrawEntity(const entity_t *entity) {
(Vector2){ x, y },
WHITE
);
// DrawRectangle(
// x,
// y,
// TILE_WIDTH,
// TILE_HEIGHT,
// (entity->type == ENTITY_TYPE_PLAYER) ? BLUE : YELLOW
// );
// switch(entity->dir) {
// case ENTITY_DIR_NORTH:
// DrawTriangle(
// (Vector2){ x + TILE_WIDTH / 2, y },
// (Vector2){ x, y + TILE_HEIGHT },
// (Vector2){ x + TILE_WIDTH, y + TILE_HEIGHT },
// WHITE
// );
// break;
// case ENTITY_DIR_SOUTH:
// DrawTriangle(
// (Vector2){ x + TILE_WIDTH / 2, y + TILE_HEIGHT },
// (Vector2){ x + TILE_WIDTH, y },
// (Vector2){ x, y },
// WHITE
// );
// break;
// case ENTITY_DIR_WEST:
// DrawTriangle(
// (Vector2){ x, y + TILE_HEIGHT / 2 },
// (Vector2){ x + TILE_WIDTH, y + TILE_HEIGHT },
// (Vector2){ x + TILE_WIDTH, y },
// WHITE
// );
// break;
// case ENTITY_DIR_EAST:
// DrawTriangle(
// (Vector2){ x + TILE_WIDTH, y + TILE_HEIGHT / 2 },
// (Vector2){ x, y },
// (Vector2){ x, y + TILE_HEIGHT },
// WHITE
// );
// break;
// }
}