engine-c: infantry/mutant walk bob via Unit.anim
This commit is contained in:
parent
e78e010495
commit
5bba757785
3 changed files with 34 additions and 7 deletions
|
|
@ -249,6 +249,9 @@ static int live_unit_tracked(UnitType t) {
|
|||
static int live_unit_rolling(UnitType t) {
|
||||
return live_unit_wheeled(t) || live_unit_tracked(t);
|
||||
}
|
||||
static int live_unit_footed(UnitType t) {
|
||||
return t == UT_INFANTRY || t == UT_MUTANT;
|
||||
}
|
||||
|
||||
/* Spoke (wheeled) / hash (tracked) on tyre discs; phase = Unit.anim rad.
|
||||
* Local 30×30 chassis coords match snapshot LX/LY, scaled to live sz. */
|
||||
|
|
@ -333,8 +336,14 @@ void render_units(Game *g) {
|
|||
int cx = (int)(u->x - g->cam.x), cy = (int)(u->y - g->cam.y);
|
||||
/* Ground shadow before rotated body so units lift off sand. */
|
||||
draw_unit_shadow(g->ren, cx, cy, sz / 4 + 4);
|
||||
/* Foot infantry/mutant: vertical body bob; shadow stays grounded. */
|
||||
float bob_y = 0.0f;
|
||||
if (live_unit_footed(u->type)) {
|
||||
bob_y = sinf(u->anim) * 2.5f;
|
||||
cy += (int)(bob_y + (bob_y >= 0.0f ? 0.5f : -0.5f));
|
||||
}
|
||||
SDL_Texture *tex = g->spr.unit[u->type][u->faction];
|
||||
draw_tex_world(g, tex, u->x, u->y, sz, sz, u->heading, 255);
|
||||
draw_tex_world(g, tex, u->x, u->y + bob_y, sz, sz, u->heading, 255);
|
||||
/* rotating spokes / tread hashes (parity with snapshot tyre_mark) */
|
||||
live_draw_tyre_marks(g->ren, u, cx, cy, sz);
|
||||
/* cream heading tick (parity with snapshot LX/LY overlay) */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue