From 6eddf11cfaebff385e0f96ce1bbb438920f5cce1 Mon Sep 17 00:00:00 2001 From: Klemen Plestenjak Date: Sat, 10 Feb 2024 14:33:07 +0100 Subject: [PATCH] Fix rotation --- game/components.h | 8 ++++---- game/main.c | 1 - game/systems/s_animation.c | 5 +++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/game/components.h b/game/components.h index ad8623f..d85b151 100644 --- a/game/components.h +++ b/game/components.h @@ -129,10 +129,10 @@ static ParticleEmitter GET_BLOOD_EMITTER() { .data.maxStartSize = 3.3f, .data.minEndSize = 0.8f, .data.maxEndSize = 1.1f, - .data.minStartRotSpeed = 8.0f, - .data.maxStartRotSpeed = 14.0f, - .data.minEndRotSpeed = 4.5f, - .data.maxEndRotSpeed = 6.2f, + .data.minStartRotSpeed = 0.0f, + .data.maxStartRotSpeed = 360.0f, + .data.minEndRotSpeed = 400.5f, + .data.maxEndRotSpeed = 600.2f, .data.startColor = { 210, 0, 0, 255 }, .data.endColor = { 110, 10, 10, 32 }, .data.minLifetime = 0.23, diff --git a/game/main.c b/game/main.c index 14dd200..ee1de7b 100644 --- a/game/main.c +++ b/game/main.c @@ -535,7 +535,6 @@ static void renderGame(Game *game, float dt) { 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]); } diff --git a/game/systems/s_animation.c b/game/systems/s_animation.c index 5cc7337..2dd43d2 100644 --- a/game/systems/s_animation.c +++ b/game/systems/s_animation.c @@ -87,7 +87,6 @@ bool updateParticle(const Texture2D tex, Particle *particle, f32 dt) { Vector2 vel = Vector2Lerp(particle->startVel, particle->endVel, alpha); f32 size = Lerp(particle->startSize, particle->endSize, alpha); - f32 rot = Lerp(particle->startRotSpeed, particle->endRotSpeed, alpha); Color startC = particle->startColor; Color endC = particle->endColor; Color color = lerpColor(startC, endC, alpha); @@ -104,9 +103,11 @@ bool updateParticle(const Texture2D tex, Particle *particle, f32 dt) { center.x, center.y, size, size - }, (Vector2) {hSize, hSize}, rot, color); + }, (Vector2) {hSize, hSize}, particle->rotation * DEG2RAD, color); EndBlendMode(); + f32 rot = Lerp(particle->startRotSpeed, particle->endRotSpeed, alpha); + particle->rotation += rot * dt; particle->pos = Vector2Add(particle->pos, Vector2Scale(vel, dt)); particle->elapsed += dt; return alpha >= 1.0f;