engine-c: SDL live arid+scale+tracers parity with KKND_SHOT
This commit is contained in:
parent
5201f49d1d
commit
b03cd2a0e3
4 changed files with 129 additions and 63 deletions
|
|
@ -166,7 +166,8 @@ void render_units(Game *g) {
|
|||
int tx = (int)(u->x / TILE), ty = (int)(u->y / TILE);
|
||||
if (!map_in_bounds(&g->map, tx, ty) || g->map.fog[ty*g->map.w + tx] != 2) continue;
|
||||
}
|
||||
int sz = 28;
|
||||
/* Match snapshot SHOT_UNIT_SCALE 1.45 → live silhouette ~41px */
|
||||
int sz = 41;
|
||||
SDL_Texture *tex = g->spr.unit[u->type][u->faction];
|
||||
draw_tex_world(g, tex, u->x, u->y, sz, sz, u->heading, 255);
|
||||
/* selection ring */
|
||||
|
|
@ -174,21 +175,21 @@ void render_units(Game *g) {
|
|||
int cx = (int)(u->x - g->cam.x), cy = (int)(u->y - g->cam.y);
|
||||
SDL_SetRenderDrawColor(g->ren, 120, 255, 120, 220);
|
||||
for (int a = 0; a < 360; a += 12) {
|
||||
int px = cx + (int)(cosf(a*3.14159f/180)*16);
|
||||
int py = cy + (int)(sinf(a*3.14159f/180)*16);
|
||||
int px = cx + (int)(cosf(a*3.14159f/180)*22);
|
||||
int py = cy + (int)(sinf(a*3.14159f/180)*22);
|
||||
SDL_RenderDrawPoint(g->ren, px, py);
|
||||
}
|
||||
}
|
||||
/* health bar */
|
||||
if (u->hp < u->max_hp || u->selected) {
|
||||
int cx = (int)(u->x - g->cam.x), by = (int)(u->y - g->cam.y) - 18;
|
||||
int bw = 24;
|
||||
int cx = (int)(u->x - g->cam.x), by = (int)(u->y - g->cam.y) - 26;
|
||||
int bw = 32;
|
||||
SDL_Rect bg = { cx - bw/2, by, bw, 4 };
|
||||
SDL_SetRenderDrawColor(g->ren, 50, 50, 50, 255);
|
||||
SDL_RenderFillRect(g->ren, &bg);
|
||||
float f = u->hp / u->max_hp;
|
||||
SDL_Color c = (u->faction == FACTION_SURVIVOR) ? (SDL_Color){90,200,90,255}
|
||||
: (SDL_Color){220,110,220,255};
|
||||
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);
|
||||
SDL_RenderFillRect(g->ren, &fg);
|
||||
|
|
@ -203,9 +204,57 @@ void render_units(Game *g) {
|
|||
}
|
||||
|
||||
void render_bullets(Game *g) {
|
||||
/* Kind-aware tracers / shells with streak tails (parity with snapshot.c). */
|
||||
for (int i = 0; i < g->bullet_count; i++) {
|
||||
Bullet *b = &g->bullets[i];
|
||||
int sx = (int)(b->x - g->cam.x), sy = (int)(b->y - g->cam.y);
|
||||
float dx = b->tx - b->x, dy = b->ty - b->y;
|
||||
float d = sqrtf(dx * dx + dy * dy);
|
||||
if (d > 1.0f) {
|
||||
float ux = dx / d, uy = dy / d;
|
||||
int len = (b->kind == 2) ? 24 : (b->kind == 3) ? 18
|
||||
: (b->kind == 1) ? 14 : 10;
|
||||
for (int t = 1; t <= len; t++) {
|
||||
int tx = sx - (int)(ux * (float)t * 0.75f);
|
||||
int ty = sy - (int)(uy * (float)t * 0.75f);
|
||||
Uint8 fade = (Uint8)(255 - t * 9);
|
||||
if (b->kind == 2) {
|
||||
/* laser: cyan→magenta streak */
|
||||
SDL_SetRenderDrawColor(g->ren, fade, 80, 255, 220);
|
||||
SDL_RenderFillRect(g->ren, &(SDL_Rect){ tx - 1, ty - 1,
|
||||
(t < 3) ? 3 : 2, (t < 3) ? 3 : 2 });
|
||||
SDL_SetRenderDrawColor(g->ren, 220, 180, 255, 255);
|
||||
SDL_RenderDrawPoint(g->ren, tx, ty);
|
||||
} else if (b->kind == 3) {
|
||||
SDL_SetRenderDrawColor(g->ren, 255, (Uint8)(120 - t * 4), 30, 230);
|
||||
SDL_RenderFillRect(g->ren, &(SDL_Rect){ tx - 1, ty - 1,
|
||||
(t < 4) ? 3 : 2, (t < 4) ? 3 : 2 });
|
||||
} else {
|
||||
SDL_SetRenderDrawColor(g->ren, 255, (Uint8)(200 - t * 8), 50, 220);
|
||||
SDL_RenderFillRect(g->ren, &(SDL_Rect){ tx, ty, 2, 2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
int rad = (b->kind == 1 || b->kind == 3) ? 6 : 4;
|
||||
SDL_SetRenderDrawColor(g->ren, 255, 160, 40, 255);
|
||||
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - rad - 1, sy - rad - 1,
|
||||
(rad + 1) * 2, (rad + 1) * 2 });
|
||||
SDL_SetRenderDrawColor(g->ren, 255, 240, 140, 255);
|
||||
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - rad, sy - rad, rad * 2, rad * 2 });
|
||||
if (b->kind == 2) {
|
||||
SDL_SetRenderDrawColor(g->ren, 120, 200, 255, 255);
|
||||
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - rad - 1, sy - rad - 1,
|
||||
(rad + 1) * 2, (rad + 1) * 2 });
|
||||
SDL_SetRenderDrawColor(g->ren, 240, 220, 255, 255);
|
||||
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - (rad - 1), sy - (rad - 1),
|
||||
(rad - 1) * 2, (rad - 1) * 2 });
|
||||
} else if (b->kind == 3) {
|
||||
SDL_SetRenderDrawColor(g->ren, 255, 70, 30, 240);
|
||||
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx - 5, sy - 1, 6, 6 });
|
||||
SDL_SetRenderDrawColor(g->ren, 255, 200, 80, 240);
|
||||
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx, sy - 4, 4, 4 });
|
||||
}
|
||||
/* Keep sprite head as bright core on top of procedural tracer. */
|
||||
SDL_Texture *tex = g->spr.bullet[b->kind < 4 ? b->kind : 0];
|
||||
SDL_Rect r = { sx - 5, sy - 5, 10, 10 };
|
||||
SDL_RenderCopy(g->ren, tex, NULL, &r);
|
||||
|
|
@ -213,13 +262,16 @@ void render_bullets(Game *g) {
|
|||
}
|
||||
|
||||
void render_particles(Game *g) {
|
||||
/* Larger combat FX (parity with snapshot particle sizes). */
|
||||
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);
|
||||
Uint8 a = (Uint8)(255 * (p->life / p->max_life));
|
||||
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);
|
||||
int sz = (p->kind == 1) ? 3 : 2;
|
||||
SDL_RenderFillRect(g->ren, &(SDL_Rect){ sx-sz/2, sy-sz/2, sz, sz });
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -471,7 +523,7 @@ void render_minimap(Game *g) {
|
|||
case T_WATER: cr=44;cg=78;cb=120; break;
|
||||
case T_ROCK: cr=110;cg=104;cb=98; break;
|
||||
case T_SCRAP: cr=200;cg=170;cb=70; break;
|
||||
case T_GRASS: cr=86;cg=120;cb=64; break;
|
||||
case T_GRASS: cr=210;cg=170;cb=78; break; /* arid wasteland */
|
||||
}
|
||||
if (fv == 1) { cr/=2; cg/=2; cb/=2; }
|
||||
SDL_SetRenderDrawColor(g->ren, cr, cg, cb, 255);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue