diff --git a/game/main.c b/game/main.c index 1838b02..14dd200 100644 --- a/game/main.c +++ b/game/main.c @@ -529,6 +529,20 @@ static void renderGame(Game *game, float dt) { qsort(drawData, numDraws, sizeof(*drawData), cmpDrawData); Texture2D tex = game->tileset.tiles; + // Draw particle layer 0 + it = ecs_query_iter(ECS, game->particles0Query); + ecs_defer_begin(ECS); + while (ecs_iter_next(&it)) { + Particle *particle = ecs_field(&it, ParticleLayer0, 1); + for (i32 i = 0; i < it.count; i++) { + bzLogInfo("what"); + if (updateParticle(tex, &particle[i], dt)) + ecs_delete(ECS, it.entities[i]); + } + } + ecs_defer_end(ECS); + + // Draw entities for (i32 i = 0; i < numDraws; i++) { DrawData draw = drawData[i]; Color c = WHITE; @@ -550,7 +564,7 @@ static void renderGame(Game *game, float dt) { it = ecs_query_iter(ECS, game->particles1Query); ecs_defer_begin(ECS); while (ecs_iter_next(&it)) { - Particle *particle = ecs_field(&it, Particle, 1); + Particle *particle = ecs_field(&it, ParticleLayer1, 1); for (i32 i = 0; i < it.count; i++) { if (updateParticle(tex, &particle[i], dt)) ecs_delete(ECS, it.entities[i]); diff --git a/game/systems/s_animation.c b/game/systems/s_animation.c index c80f99a..5cc7337 100644 --- a/game/systems/s_animation.c +++ b/game/systems/s_animation.c @@ -72,7 +72,6 @@ void updateParticleEmitter(ecs_iter_t *it) { i32 emmit = data.emmitRate + data.emmitVariance * randFloatRange(data.emmitVarianceMin, data.emmitVarianceMax); for (i32 pIdx = 0; pIdx < emmit; pIdx++) { ecs_entity_t pEntity = entityCreateEmpty(); - ecs_set_ptr(ECS, pEntity, ParticleLayer0, NULL); Particle particle = spawnParticle(&emitter[i]); ecs_set_id(ECS, pEntity, emitter[i].targetParticles, sizeof(particle), &particle); }