Add emission to ParticleEmitter

This commit is contained in:
2024-02-10 10:13:18 +01:00
parent ae71e259fd
commit aa0fea49e9
4 changed files with 46 additions and 6 deletions

View File

@@ -567,6 +567,30 @@ static void renderGame(Game *game, float dt) {
drawPlayerInputUI();
EndMode2D();
InputState *input = ecs_singleton_get_mut(ECS, InputState);
if (IsKeyReleased(KEY_SPACE)) {
ParticleEmitter emitter = {
.emitterLifetime = 2.0f,
.targetParticles = ecs_id(ParticleLayer1),
.data.emmitRate = 1.2f,
.data.emmitVariance = 1.0f,
.data.emmitVarianceMin = 0.0f,
.data.emmitVarianceMax = 1.0f,
.pos = input->mouseWorld,
.data.startColor = { 210, 0, 0, 210 },
.data.endColor = { 110, 10, 10, 110 },
.data.minLifetime = 1.0f,
.data.maxLifetime = 2.2f,
.data.minStartSize = 4.0f,
.data.maxStartSize = 6.0f,
.data.tileID = getParticleTypeTile(PARTICLE_CIRCLE),
.data.blend = BLEND_ADDITIVE
};
ecs_entity_t e = entityCreateEmpty();
ecs_set_ptr(ECS, e, ParticleEmitter, &emitter);
}
}
void render(float dt, void *userData) {