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
|
|
@ -925,28 +925,43 @@ void snapshot_capture(Game *g, const char *path) {
|
|||
draw_unit(u, sx, sy);
|
||||
}
|
||||
|
||||
/* projectiles — bright tracers / shells with streak tails (KKND2-like) */
|
||||
/* projectiles — lofted shell/missile sample parabola; else linear streak */
|
||||
for (int i = 0; i < g->bullet_count; i++) {
|
||||
Bullet *p = &g->bullets[i];
|
||||
int sx = (int)(p->x - camx), sy = (int)(p->y - camy);
|
||||
float dx = p->tx - p->x, dy = p->ty - p->y;
|
||||
float d = sqrtf(dx * dx + dy * dy);
|
||||
if (d > 1.0f) {
|
||||
float ux = dx / d, uy = dy / d;
|
||||
int len = (p->kind == 2) ? 32 : (p->kind == 3) ? 24
|
||||
: (p->kind == 1) ? 20 : 14;
|
||||
int lofted = (p->kind == 1 || p->kind == 3) && p->loft > 0.5f;
|
||||
if (lofted) {
|
||||
int len = (p->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_t fade = (uint8_t)(255 - t * 9);
|
||||
if (p->kind == 2) {
|
||||
/* laser beam: cyan→magenta streak */
|
||||
disc(tx, ty, (t < 3) ? 2 : 1, fade, 80, 255);
|
||||
px(tx, ty, 220, 180, 255);
|
||||
} else if (p->kind == 3) {
|
||||
disc(tx, ty, (t < 4) ? 2 : 1, 255, (uint8_t)(120 - t * 4), 30);
|
||||
} else {
|
||||
disc(tx, ty, 1, 255, (uint8_t)(200 - t * 8), 50);
|
||||
float tp = p->prog - step * (float)t;
|
||||
if (tp < 0.0f) break;
|
||||
float wx = p->ox + (p->tx - p->ox) * tp;
|
||||
float wy = p->oy + (p->ty - p->oy) * tp
|
||||
- p->loft * 4.0f * tp * (1.0f - tp);
|
||||
int tx = (int)(wx - camx);
|
||||
int ty = (int)(wy - camy);
|
||||
if (p->kind == 3)
|
||||
disc(tx, ty, (t < 4) ? 2 : 1, 255, (uint8_t)(120 - t * 3), 30);
|
||||
else
|
||||
disc(tx, ty, 1, 255, (uint8_t)(200 - t * 7), 50);
|
||||
}
|
||||
} else {
|
||||
float dx = p->tx - p->x, dy = p->ty - p->y;
|
||||
float d = sqrtf(dx * dx + dy * dy);
|
||||
if (d > 1.0f) {
|
||||
float ux = dx / d, uy = dy / d;
|
||||
int len = (p->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_t fade = (uint8_t)(255 - t * 9);
|
||||
if (p->kind == 2) {
|
||||
disc(tx, ty, (t < 3) ? 2 : 1, fade, 80, 255);
|
||||
px(tx, ty, 220, 180, 255);
|
||||
} else {
|
||||
disc(tx, ty, 1, 255, (uint8_t)(200 - t * 8), 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue