Remove color randomness

This commit is contained in:
2024-01-30 19:39:52 +01:00
parent df581dcb9d
commit ab0fef8ebf
3 changed files with 10 additions and 15 deletions

View File

@@ -66,10 +66,8 @@ typedef struct ParticleEmitter {
f32 minStartRotSpeed, maxStartRotSpeed; f32 minStartRotSpeed, maxStartRotSpeed;
// endRotSpeed // endRotSpeed
f32 minEndRotSpeed, maxEndRotSpeed; f32 minEndRotSpeed, maxEndRotSpeed;
// startColor
Color minStartColor, maxStartColor; Color startColor, endColor;
// endColor
Color minEndColor, maxEndColor;
// lifetime // lifetime
f32 minLifetime, maxLifetime; f32 minLifetime, maxLifetime;

View File

@@ -546,7 +546,6 @@ static void renderGame(Game *game, float dt) {
while (ecs_iter_next(&it)) { while (ecs_iter_next(&it)) {
Particle *particle = ecs_field(&it, Particle, 1); Particle *particle = ecs_field(&it, Particle, 1);
for (i32 i = 0; i < it.count; i++) { for (i32 i = 0; i < it.count; i++) {
DrawCircleV(particle[i].pos, 2.0f, RED);
if (updateParticle(tex, &particle[i], dt)) if (updateParticle(tex, &particle[i], dt))
ecs_delete(ECS, it.entities[i]); ecs_delete(ECS, it.entities[i]);
} }
@@ -773,17 +772,15 @@ void imguiRender(float dt, void *userData) {
} while (0) } while (0)
igColor("minStartColor", data->minStartColor); igColor("startColor", data->startColor);
igColor("maxStartColor", data->maxStartColor); igColor("endColor", data->endColor);
igColor("minEndColor", data->minEndColor);
igColor("maxEndColor", data->maxEndColor);
#undef igColor #undef igColor
igSliderFloat("minLifetime", &data->minLifetime, 0.0f, 6.0f, "%.2f", 0); igSliderFloat("minLifetime", &data->minLifetime, 0.0f, 6.0f, "%.2f", 0);
igSliderFloat("maxLifetime", &data->maxLifetime, 0.0f, 6.0f, "%.2f", 0); igSliderFloat("maxLifetime", &data->maxLifetime, 0.0f, 6.0f, "%.2f", 0);
Particle particle = spawnParticle(&emitter); Particle particle = spawnParticle(&emitter);
ecs_entity_t e = entityCreateEmpty(); //ecs_entity_t e = entityCreateEmpty();
ecs_set_ptr(ECS, e, ParticleLayer1, &particle); //ecs_set_ptr(ECS, e, ParticleLayer1, &particle);
} }
if (igCollapsingHeader_TreeNodeFlags("Selection", 0)) { if (igCollapsingHeader_TreeNodeFlags("Selection", 0)) {
switch (input->state) { switch (input->state) {

View File

@@ -49,7 +49,7 @@ bool updateParticle(const Texture2D tex, Particle *particle, f32 dt) {
.a = lerpInt(startC.a, endC.a, alpha) .a = lerpInt(startC.a, endC.a, alpha)
}; };
//BeginBlendMode(particle->blend); BeginBlendMode(particle->blend);
f32 hSize = size * 0.5f; f32 hSize = size * 0.5f;
Vector2 center = particle->pos; Vector2 center = particle->pos;
Rectangle src = getTextureRect(particle->tileID); Rectangle src = getTextureRect(particle->tileID);
@@ -62,7 +62,7 @@ bool updateParticle(const Texture2D tex, Particle *particle, f32 dt) {
center.y, center.y,
size, size size, size
}, (Vector2) {hSize, hSize}, rot, color); }, (Vector2) {hSize, hSize}, rot, color);
//EndBlendMode(); EndBlendMode();
particle->pos = Vector2Add(particle->pos, Vector2Scale(vel, dt)); particle->pos = Vector2Add(particle->pos, Vector2Scale(vel, dt));
particle->elapsed += dt; particle->elapsed += dt;
@@ -98,8 +98,8 @@ Particle spawnParticle(const ParticleEmitter *emitter) {
.endSize = randFloatRange(data->minEndSize, data->maxEndSize), .endSize = randFloatRange(data->minEndSize, data->maxEndSize),
.startRotSpeed = randFloatRange(data->minStartRotSpeed, data->maxStartRotSpeed), .startRotSpeed = randFloatRange(data->minStartRotSpeed, data->maxStartRotSpeed),
.endRotSpeed = randFloatRange(data->minEndRotSpeed, data->maxEndRotSpeed), .endRotSpeed = randFloatRange(data->minEndRotSpeed, data->maxEndRotSpeed),
.startColor = randColorRange(data->minStartColor, data->maxStartColor), .startColor = data->startColor,
.endColor = randColorRange(data->minEndColor, data->maxEndColor), .endColor = data->endColor,
.blend = data->blend, .blend = data->blend,
.tileID = data->tileID, .tileID = data->tileID,
.elapsed = 0.0f, .elapsed = 0.0f,