engine-c: infantry/mutant walk bob via Unit.anim

This commit is contained in:
local-model/engine-L2-grok-4.5 2026-09-19 13:03:33 +02:00
parent e78e010495
commit 5bba757785
No known key found for this signature in database
3 changed files with 34 additions and 7 deletions

View file

@ -130,7 +130,7 @@ static void draw_unit(Unit *u, int sx, int sy) {
uint8_t mr = 70, mg = 65, mb = 58; /* tyre */
float c = cosf(u->heading), s = sinf(u->heading);
const float sc = SHOT_UNIT_SCALE;
float ph = u->anim; /* continuous roll phase for wheeled/tracked */
float ph = u->anim; /* continuous roll/walk phase for wheeled/tracked/footed */
#define SI(n) ((int)((n) * sc + 0.5f))
#define LX(lx, ly) (sx + (int)((((lx)-15)*sc)*c - (((ly)-15)*sc)*s))
#define LY(lx, ly) (sy + (int)((((lx)-15)*sc)*s + (((ly)-15)*sc)*c))
@ -138,6 +138,12 @@ static void draw_unit(Unit *u, int sx, int sy) {
/* Ground shadow — depth cue so bodies don't melt into sand. */
disc(sx + SI(2), sy + SI(3), SI(9), 55, 48, 28);
/* Foot infantry/mutant: vertical body bob; shadow stays grounded. */
if (u->type == UT_INFANTRY || u->type == UT_MUTANT) {
float bob = sinf(ph) * 2.5f * sc;
sy += (int)(bob + (bob >= 0.0f ? 0.5f : -0.5f));
}
switch (u->type) {
case UT_INFANTRY:
disc(sx, sy, SI(9), ok, og, ob);