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;
// endRotSpeed
f32 minEndRotSpeed, maxEndRotSpeed;
// startColor
Color minStartColor, maxStartColor;
// endColor
Color minEndColor, maxEndColor;
Color startColor, endColor;
// lifetime
f32 minLifetime, maxLifetime;

View File

@@ -546,7 +546,6 @@ static void renderGame(Game *game, float dt) {
while (ecs_iter_next(&it)) {
Particle *particle = ecs_field(&it, Particle, 1);
for (i32 i = 0; i < it.count; i++) {
DrawCircleV(particle[i].pos, 2.0f, RED);
if (updateParticle(tex, &particle[i], dt))
ecs_delete(ECS, it.entities[i]);
}
@@ -773,17 +772,15 @@ void imguiRender(float dt, void *userData) {
} while (0)
igColor("minStartColor", data->minStartColor);
igColor("maxStartColor", data->maxStartColor);
igColor("minEndColor", data->minEndColor);
igColor("maxEndColor", data->maxEndColor);
igColor("startColor", data->startColor);
igColor("endColor", data->endColor);
#undef igColor
igSliderFloat("minLifetime", &data->minLifetime, 0.0f, 6.0f, "%.2f", 0);
igSliderFloat("maxLifetime", &data->maxLifetime, 0.0f, 6.0f, "%.2f", 0);
Particle particle = spawnParticle(&emitter);
ecs_entity_t e = entityCreateEmpty();
ecs_set_ptr(ECS, e, ParticleLayer1, &particle);
//ecs_entity_t e = entityCreateEmpty();
//ecs_set_ptr(ECS, e, ParticleLayer1, &particle);
}
if (igCollapsingHeader_TreeNodeFlags("Selection", 0)) {
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)
};
//BeginBlendMode(particle->blend);
BeginBlendMode(particle->blend);
f32 hSize = size * 0.5f;
Vector2 center = particle->pos;
Rectangle src = getTextureRect(particle->tileID);
@@ -62,7 +62,7 @@ bool updateParticle(const Texture2D tex, Particle *particle, f32 dt) {
center.y,
size, size
}, (Vector2) {hSize, hSize}, rot, color);
//EndBlendMode();
EndBlendMode();
particle->pos = Vector2Add(particle->pos, Vector2Scale(vel, dt));
particle->elapsed += dt;
@@ -98,8 +98,8 @@ Particle spawnParticle(const ParticleEmitter *emitter) {
.endSize = randFloatRange(data->minEndSize, data->maxEndSize),
.startRotSpeed = randFloatRange(data->minStartRotSpeed, data->maxStartRotSpeed),
.endRotSpeed = randFloatRange(data->minEndRotSpeed, data->maxEndRotSpeed),
.startColor = randColorRange(data->minStartColor, data->maxStartColor),
.endColor = randColorRange(data->minEndColor, data->maxEndColor),
.startColor = data->startColor,
.endColor = data->endColor,
.blend = data->blend,
.tileID = data->tileID,
.elapsed = 0.0f,