engine-c: scaffold beams + bld damage FX + wear showcase

This commit is contained in:
local-model/engine-L2-grok-4.5 2026-09-19 12:03:13 +02:00
parent a086ab23a6
commit b2469dbcde
No known key found for this signature in database
3 changed files with 114 additions and 4 deletions

View file

@ -99,11 +99,26 @@ void render_buildings(Game *g) {
SDL_Rect r = { sx, sy, W, H };
SDL_Texture *tex = g->spr.bld[b->type][b->faction];
if (b->build < 1.0f) {
/* construction: draw then scaffold overlay */
/* construction: ghost body + KKND2-style yard scaffold */
SDL_SetTextureAlphaMod(tex, 160);
SDL_RenderCopy(g->ren, tex, NULL, &r);
SDL_SetTextureAlphaMod(tex, 255);
int pct = (int)(b->build * 100);
int mid = sy + (int)(H * b->build);
/* corner posts + rails */
SDL_SetRenderDrawColor(g->ren, 175, 145, 85, 255);
SDL_RenderDrawLine(g->ren, sx, sy, sx, sy + H);
SDL_RenderDrawLine(g->ren, sx + W - 1, sy, sx + W - 1, sy + H);
SDL_RenderDrawLine(g->ren, sx, sy + H - 1, sx + W, sy + H - 1);
SDL_SetRenderDrawColor(g->ren, 210, 175, 100, 255);
SDL_RenderDrawLine(g->ren, sx, sy, sx + W, sy);
SDL_RenderDrawLine(g->ren, sx, mid, sx + W, mid);
/* X-braces + optional mid post */
SDL_SetRenderDrawColor(g->ren, 155, 125, 65, 230);
SDL_RenderDrawLine(g->ren, sx + 2, sy + 2, sx + W - 2, sy + H - 2);
SDL_RenderDrawLine(g->ren, sx + W - 2, sy + 2, sx + 2, sy + H - 2);
if (W >= 48)
SDL_RenderDrawLine(g->ren, sx + W / 2, sy, sx + W / 2, sy + H);
/* progress bar above */
SDL_Rect bar = { sx, sy - 8, W, 5 };
SDL_SetRenderDrawColor(g->ren, 200, 200, 200, 255);
SDL_RenderFillRect(g->ren, &bar);
@ -113,6 +128,25 @@ void render_buildings(Game *g) {
} else {
SDL_RenderCopy(g->ren, tex, NULL, &r);
}
/* battle wear: scorch + crack lines when damaged */
if (b->build >= 1.0f && b->max_hp > 0 && b->hp < b->max_hp * 0.95f) {
float dmg = 1.0f - (b->hp / b->max_hp);
int pw = W / 4; if (pw < 4) pw = 4;
int ph = H / 5; if (ph < 3) ph = 3;
SDL_SetRenderDrawColor(g->ren, 42, 32, 22, (Uint8)(90 + (int)(dmg * 110)));
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx + W / 4, sy + H / 3, pw, ph });
if (dmg > 0.3f)
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx + W / 2, sy + H / 2, pw, ph });
SDL_SetRenderDrawColor(g->ren, 25, 22, 18, 255);
SDL_RenderDrawLine(g->ren, sx + 4, sy + H / 4, sx + W / 2, sy + (H * 2) / 3);
SDL_RenderDrawLine(g->ren, sx + W / 2, sy + (H * 2) / 3, sx + W - 4, sy + H / 3);
if (dmg > 0.5f) {
SDL_RenderDrawLine(g->ren, sx + W / 3, sy + 2, sx + W / 3 + 4, sy + H - 2);
SDL_SetRenderDrawColor(g->ren, 90, 75, 55, 255);
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx + 2, sy + H - 4, 6, 4 });
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx + W - 10, sy + H - 5, 8, 5 });
}
}
/* health bar if damaged or selected */
if (b->hp < b->max_hp || b->selected) {
SDL_Rect bar = { sx, sy - 6, W, 4 };