engine-c: wreck draw + type variety + clash seed for KKND2 battlefield

Snapshot/live wreck silhouettes (type-aware hulls, scorch/smoke), seed ~22 clash wrecks in place_showcase, reset wreck ring on match setup.
This commit is contained in:
local-model/engine-L2-grok-4.5 2026-09-19 16:05:12 +02:00
parent 252cfd8175
commit d54d38e8df
No known key found for this signature in database
5 changed files with 176 additions and 5 deletions

View file

@ -181,18 +181,53 @@ void render_buildings(Game *g) {
}
}
/* Forward: defined below with live unit sizing. */
static int unit_screen_sz(UnitType t);
void render_wrecks(Game *g) {
for (int i = 0; i < g->wreck_count; i++) {
Wreck *w = &g->wrecks[i];
int tx = (int)(w->x / TILE), ty = (int)(w->y / TILE);
if (!map_in_bounds(&g->map, tx, ty)) continue;
if (g->map.fog[ty*g->map.w + tx] == 0) continue;
if (g->map.fog[ty * g->map.w + tx] == 0) continue;
SDL_Color c = faction_color(w->faction);
Uint8 dr = (Uint8)(c.r * 0.38f), dg = (Uint8)(c.g * 0.38f), db = (Uint8)(c.b * 0.38f);
int sx = (int)(w->x - g->cam.x), sy = (int)(w->y - g->cam.y);
SDL_SetRenderDrawColor(g->ren, c.r/2, c.g/2, c.b/2, 200);
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx-12, sy-9, 24, 18 });
SDL_SetRenderDrawColor(g->ren, 30, 28, 26, 200);
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx-8, sy-5, 16, 10 });
int sz = unit_screen_sz(w->type);
int hw = sz / 3, hh = sz / 4;
if (hw < 10) hw = 10;
if (hh < 7) hh = 7;
/* scorch under hull */
SDL_SetRenderDrawColor(g->ren, 42, 36, 28, 180);
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - hw - 2, sy - hh + 2, hw * 2 + 4, hh * 2 });
SDL_SetRenderDrawColor(g->ren, 28, 24, 20, 220);
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - hw, sy - hh, hw * 2, hh * 2 });
SDL_SetRenderDrawColor(g->ren, dr, dg, db, 210);
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - hw + 2, sy - hh + 2, hw * 2 - 4, hh * 2 - 4 });
/* type cues: tracks / wheels / crumpled body */
if (w->type == UT_TANK || w->type == UT_RAVAGER || w->type == UT_BEAST
|| w->type == UT_ARTILLERY) {
SDL_SetRenderDrawColor(g->ren, 48, 42, 36, 230);
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - hw, sy - hh / 2, 4, hh });
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx + hw - 4, sy - hh / 2, 4, hh });
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - 4, sy - hh - 2, 8, 6 }); /* dead turret */
} else if (w->type == UT_HARVESTER || w->type == UT_BUGGY || w->type == UT_JEEP
|| w->type == UT_FLAME || w->type == UT_MISSILE || w->type == UT_MEDIC) {
SDL_SetRenderDrawColor(g->ren, 30, 28, 26, 230);
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - hw + 2, sy - hh + 2, 6, 6 });
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx + hw - 8, sy - hh + 2, 6, 6 });
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - hw + 2, sy + hh - 8, 6, 6 });
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx + hw - 8, sy + hh - 8, 6, 6 });
} else {
/* infantry/mutant crumpled kit */
SDL_SetRenderDrawColor(g->ren, 48, 42, 36, 200);
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - 5, sy - 4, 10, 8 });
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx + 3, sy + 2, 5, 4 });
}
/* thin smoke puff */
SDL_SetRenderDrawColor(g->ren, 70, 68, 64, 160);
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx + 2, sy - hh - 6, 5, 5 });
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx + 5, sy - hh - 10, 3, 3 });
}
}