chore: adjust player tank's size
This commit is contained in:
@@ -45,6 +45,7 @@ class PlayerTank extends Tank {
|
||||
|
||||
// Skin colors (reserved for future use)
|
||||
this._skinColors = null;
|
||||
this._skinId = 'default';
|
||||
|
||||
// Fire level system
|
||||
this.fireLevel = FIRE_LEVEL.LV1;
|
||||
|
||||
+24
-2
@@ -13,6 +13,7 @@ const {
|
||||
DIRECTION,
|
||||
DIR_VECTORS,
|
||||
} = require('../base/GameGlobal');
|
||||
const { drawTankSkin, DESIGN_HALF_SIZE } = require('./TankSkinRenderer');
|
||||
|
||||
class Tank {
|
||||
/**
|
||||
@@ -288,9 +289,30 @@ class Tank {
|
||||
};
|
||||
ctx.rotate(angles[this.direction]);
|
||||
|
||||
const hs = this.halfSize;
|
||||
// ★ Unified skin path — any tank with a skin id uses the SAME drawing
|
||||
// code as the SkinScene preview. Scale to match the actual tank size.
|
||||
// Clip laterally to the collision box so wide tracks / decorations
|
||||
// don't make the tank look wider than non-skinned tanks. Leave the
|
||||
// top/bottom un-clipped so the barrel can extend naturally (same as
|
||||
// legacy rendering).
|
||||
if (this._skinId) {
|
||||
const t = (typeof performance !== 'undefined' ? performance.now() : Date.now()) / 1000;
|
||||
const k = this.halfSize / DESIGN_HALF_SIZE;
|
||||
// Clip: lateral bounds = collision box; vertical = generous to allow barrel
|
||||
const barrelExtra = this.size * 0.55; // same as legacy barrelH
|
||||
ctx.beginPath();
|
||||
ctx.rect(-this.halfSize, -this.halfSize - barrelExtra, this.size, this.size + barrelExtra * 2);
|
||||
ctx.clip();
|
||||
ctx.save();
|
||||
ctx.scale(k, k);
|
||||
drawTankSkin(ctx, this._skinId, this._skinColors, t);
|
||||
ctx.restore();
|
||||
ctx.restore();
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine colors: use skin colors if this is a player tank with a skin
|
||||
// ── Legacy fallback for tanks without a skin id (enemy AI, etc.) ──
|
||||
const hs = this.halfSize;
|
||||
let bodyColor = this.color;
|
||||
let turretColor = this._darkenColor(this.color, 0.3);
|
||||
let trackColor = this._darkenColor(this.color, 0.4);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user