engine-c: denser mid-air tracers + artillery/missile arcs
This commit is contained in:
parent
1ef6df4ce5
commit
b4d3388701
7 changed files with 187 additions and 76 deletions
|
|
@ -439,36 +439,53 @@ void render_units(Game *g) {
|
|||
}
|
||||
|
||||
void render_bullets(Game *g) {
|
||||
/* Kind-aware tracers / shells with streak tails (parity with snapshot.c). */
|
||||
/* Kind-aware tracers / shells; lofted kinds sample the parabola trail. */
|
||||
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) ? 32 : (b->kind == 3) ? 24
|
||||
: (b->kind == 1) ? 20 : 14;
|
||||
int lofted = (b->kind == 1 || b->kind == 3) && b->loft > 0.5f;
|
||||
if (lofted) {
|
||||
int len = (b->kind == 3) ? 28 : 22;
|
||||
float step = 0.018f;
|
||||
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);
|
||||
float tp = b->prog - step * (float)t;
|
||||
if (tp < 0.0f) break;
|
||||
float wx = b->ox + (b->tx - b->ox) * tp;
|
||||
float wy = b->oy + (b->ty - b->oy) * tp
|
||||
- b->loft * 4.0f * tp * (1.0f - tp);
|
||||
int tx = (int)(wx - g->cam.x);
|
||||
int ty = (int)(wy - g->cam.y);
|
||||
if (b->kind == 3) {
|
||||
SDL_SetRenderDrawColor(g->ren, 255, (Uint8)(120 - t * 3), 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_SetRenderDrawColor(g->ren, 255, (Uint8)(200 - t * 7), 50, 220);
|
||||
SDL_RenderFillRect(g->ren, &(SDL_Rect){ tx, ty, 2, 2 });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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) ? 32 : 14;
|
||||
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) {
|
||||
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 {
|
||||
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) ? 8 : 5;
|
||||
SDL_SetRenderDrawColor(g->ren, 255, 160, 40, 255);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue