engine-c: unit mid-layers/tyres + denser combat FX

This commit is contained in:
local-model/engine-L2-grok-4.5 2026-09-19 11:36:11 +02:00
parent c60752b878
commit aac30cb097
No known key found for this signature in database
4 changed files with 95 additions and 69 deletions

View file

@ -293,17 +293,33 @@ void render_bullets(Game *g) {
}
}
/* Soft disc for smoke/fire particles (parity with snapshot disc FX). */
static void draw_particle_disc(SDL_Renderer *ren, int cx, int cy, int rad,
Uint8 r, Uint8 g, Uint8 b, Uint8 a) {
SDL_SetRenderDrawColor(ren, r, g, b, a);
for (int j = -rad; j <= rad; j++) {
int half = (int)sqrtf((float)(rad * rad - j * j));
SDL_RenderDrawLine(ren, cx - half, cy + j, cx + half, cy + j);
}
}
void render_particles(Game *g) {
/* Larger combat FX (parity with snapshot particle sizes). */
/* Kind-aware combat FX: discs for smoke/fire, rects for sparks/debris. */
for (int i = 0; i < g->particle_count; i++) {
Particle *p = &g->particles[i];
int sx = (int)(p->x - g->cam.x), sy = (int)(p->y - g->cam.y);
float life_a = p->life / (p->max_life > 0 ? p->max_life : 1.0f);
if (life_a < 0.12f) continue;
Uint8 a = (Uint8)(255 * life_a);
SDL_SetRenderDrawColor(g->ren, p->r, p->g, p->b, a);
Uint8 rr = (Uint8)(p->r * life_a), gg = (Uint8)(p->g * life_a),
bb = (Uint8)(p->b * life_a);
int sz = (p->kind == 1) ? 5 : (p->kind == 3) ? 3 : (p->kind == 0) ? 4 : 3;
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - sz/2, sy - sz/2, sz + 1, sz + 1 });
if (p->kind == 0 || p->kind == 1) {
draw_particle_disc(g->ren, sx, sy, sz + 1, rr, gg, bb, a);
} else {
SDL_SetRenderDrawColor(g->ren, rr, gg, bb, a);
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - sz/2, sy - sz/2, sz + 1, sz + 1 });
}
}
}