diff --git a/engine-c/openkknd b/engine-c/openkknd index 1848619..4fa9fdf 100755 Binary files a/engine-c/openkknd and b/engine-c/openkknd differ diff --git a/engine-c/src/render.c b/engine-c/src/render.c index 1623418..32f50ef 100644 --- a/engine-c/src/render.c +++ b/engine-c/src/render.c @@ -158,6 +158,34 @@ void render_wrecks(Game *g) { } } +/* Per-type live silhouette size (parity with snapshot SHOT_UNIT_SCALE kinds). */ +static int unit_screen_sz(UnitType t) { + switch (t) { + case UT_INFANTRY: return 36; + case UT_MUTANT: return 38; + case UT_JEEP: + case UT_BUGGY: return 40; + case UT_FLAME: + case UT_MISSILE: + case UT_MEDIC: return 42; + case UT_ARTILLERY: + case UT_HARVESTER: return 46; + case UT_TANK: return 48; + case UT_BEAST: return 50; + case UT_RAVAGER: return 52; + default: return 41; + } +} + +/* Unrotated ground shadow disc (must sit under rotated unit tex). */ +static void draw_unit_shadow(SDL_Renderer *ren, int cx, int cy, int rad) { + SDL_SetRenderDrawColor(ren, 55, 48, 28, 200); + for (int j = -rad; j <= rad; j++) { + int half = (int)sqrtf((float)(rad * rad - j * j)); + SDL_RenderDrawLine(ren, cx - half + 2, cy + j + 3, cx + half + 2, cy + j + 3); + } +} + void render_units(Game *g) { for (int i = 0; i < g->unit_count; i++) { Unit *u = &g->units[i]; @@ -166,36 +194,40 @@ 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; } - /* Match snapshot SHOT_UNIT_SCALE 1.45 → live silhouette ~41px */ - int sz = 41; + int sz = unit_screen_sz(u->type); + 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); 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 */ + /* selection ring — larger for heavy chassis */ if (u->selected) { - int cx = (int)(u->x - g->cam.x), cy = (int)(u->y - g->cam.y); + int rad = (u->type == UT_TANK || u->type == UT_BEAST || u->type == UT_RAVAGER) + ? sz / 2 + 4 : sz / 2 + 2; 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)*22); - int py = cy + (int)(sinf(a*3.14159f/180)*22); + int px = cx + (int)(cosf(a * 3.14159f / 180) * rad); + int py = cy + (int)(sinf(a * 3.14159f / 180) * rad); 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) - 26; - int bw = 32; - SDL_Rect bg = { cx - bw/2, by, bw, 4 }; + int by = cy - sz / 2 - 6; + int bw = sz - 8; + if (bw < 24) bw = 24; + 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){55,235,55,255} : (SDL_Color){255,40,255,255}; - SDL_Rect fg = { cx - bw/2, by, (int)(bw * f), 4 }; + 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); /* cargo indicator for harvesters */ if (u->type == UT_HARVESTER && u->cargo > 0) { - SDL_Rect cg = { cx - bw/2, by - 4, (int)(bw * u->cargo / 1000), 2 }; + SDL_Rect cg = { cx - bw / 2, by - 4, (int)(bw * u->cargo / 1000), 2 }; SDL_SetRenderDrawColor(g->ren, 230, 190, 70, 255); SDL_RenderFillRect(g->ren, &cg); } diff --git a/engine-c/src/sprites.c b/engine-c/src/sprites.c index f319e9f..5e34c82 100644 --- a/engine-c/src/sprites.c +++ b/engine-c/src/sprites.c @@ -182,65 +182,83 @@ SDL_Texture *sprites_make_unit(SDL_Renderer *r, UnitType t, Faction f) { } /* ---------------- building sprites ---------------- */ +/* Bright concrete pad + BT_* interiors (parity with snapshot draw_bld). */ SDL_Texture *sprites_make_bld(SDL_Renderer *r, BuildingType t, Faction f) { int w = bld_def(t)->w, h = bld_def(t)->h; int W = w * TILE, H = h * TILE; SDL_Surface *s = new_surf(W, H); SDL_Color base = faction_color(f); SDL_Color dark = darken(base, 0.5f); - SDL_Color lite = lighten(base, 0.4f); - /* Bright sand pad + dark ridge outline (arid wasteland plate). */ - SDL_Color wall = { 198, 168, 108, 255 }; - SDL_Color wall2 = { 155, 128, 78, 255 }; - const Uint8 ok = 28, og = 24, ob = 18; + SDL_Color lite = lighten(base, 0.35f); + const Uint8 ok = 22, og = 20, ob = 16; + const Uint8 wall = 205, wall2 = 175; - fill_rect(s, 0, 0, W, H, wall2.r, wall2.g, wall2.b, 255); - fill_rect(s, 2, 2, W - 4, H - 4, ok, og, ob, 255); - fill_rect(s, 4, 4, W - 8, H - 8, wall.r, wall.g, wall.b, 255); - ring(s, W/2, H/2, (W