engine-c: live heading tick + muzzle/death FX
This commit is contained in:
parent
7b182166e8
commit
073f38db7a
2 changed files with 36 additions and 15 deletions
|
|
@ -200,30 +200,43 @@ void render_units(Game *g) {
|
|||
draw_unit_shadow(g->ren, cx, cy, sz / 4 + 4);
|
||||
SDL_Texture *tex = g->spr.unit[u->type][u->faction];
|
||||
draw_tex_world(g, tex, u->x, u->y, sz, sz, u->heading, 255);
|
||||
/* cream heading tick (parity with snapshot LX/LY overlay) */
|
||||
{
|
||||
float tick = (float)(sz / 2 + 6);
|
||||
int hx = cx + (int)(cosf(u->heading) * tick);
|
||||
int hy = cy + (int)(sinf(u->heading) * tick);
|
||||
SDL_SetRenderDrawColor(g->ren, 250, 245, 210, 255);
|
||||
SDL_RenderDrawLine(g->ren, cx, cy, hx, hy);
|
||||
SDL_SetRenderDrawColor(g->ren, 255, 250, 220, 220);
|
||||
SDL_RenderDrawLine(g->ren, cx + 1, cy, hx + 1, hy);
|
||||
}
|
||||
/* selection ring — larger for heavy chassis */
|
||||
if (u->selected) {
|
||||
int rad = (u->type == UT_TANK || u->type == UT_BEAST || u->type == UT_RAVAGER)
|
||||
? sz / 2 + 4 : sz / 2 + 2;
|
||||
SDL_SetRenderDrawColor(g->ren, 120, 255, 120, 220);
|
||||
for (int a = 0; a < 360; a += 12) {
|
||||
SDL_SetRenderDrawColor(g->ren, 255, 245, 60, 220);
|
||||
for (int a = 0; a < 360; a += 10) {
|
||||
int px = cx + (int)(cosf(a * 3.14159f / 180) * rad);
|
||||
int py = cy + (int)(sinf(a * 3.14159f / 180) * rad);
|
||||
SDL_RenderDrawPoint(g->ren, px, py);
|
||||
}
|
||||
}
|
||||
/* health bar */
|
||||
/* HP bar: green→red strip like snapshot */
|
||||
if (u->hp < u->max_hp || u->selected) {
|
||||
int by = cy - sz / 2 - 6;
|
||||
int bw = sz - 8;
|
||||
int by = cy - sz / 2 - 8;
|
||||
int bw = sz - 6;
|
||||
if (bw < 24) bw = 24;
|
||||
SDL_Rect outline = { cx - bw / 2 - 1, by - 1, bw + 2, 6 };
|
||||
SDL_SetRenderDrawColor(g->ren, 20, 18, 14, 255);
|
||||
SDL_RenderFillRect(g->ren, &outline);
|
||||
SDL_Rect bg = { cx - bw / 2, by, bw, 4 };
|
||||
SDL_SetRenderDrawColor(g->ren, 50, 50, 50, 255);
|
||||
SDL_SetRenderDrawColor(g->ren, 55, 48, 36, 255);
|
||||
SDL_RenderFillRect(g->ren, &bg);
|
||||
float f = u->hp / u->max_hp;
|
||||
SDL_Color c = (u->faction == FACTION_SURVIVOR) ? (SDL_Color){55,235,55,255}
|
||||
: (SDL_Color){255,40,255,255};
|
||||
SDL_Rect fg = { cx - bw / 2, by, (int)(bw * f), 4 };
|
||||
SDL_SetRenderDrawColor(g->ren, c.r, c.g, c.b, 255);
|
||||
if (f < 0) f = 0; if (f > 1) f = 1;
|
||||
Uint8 hr = (Uint8)(255 * (1.0f - f)), hg = (Uint8)(230 * f);
|
||||
SDL_Rect fg = { cx - bw / 2, by, (int)(bw * f + 0.5f), 4 };
|
||||
SDL_SetRenderDrawColor(g->ren, hr, hg, 40, 255);
|
||||
SDL_RenderFillRect(g->ren, &fg);
|
||||
/* cargo indicator for harvesters */
|
||||
if (u->type == UT_HARVESTER && u->cargo > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue