feedback3 WD: the boss rounds' prep shows the leader on its spawn tile with its HP bar, and its hit tiles in red beside an operator's range preview (community report #12)
This commit is contained in:
1 parent
2582367cea
commit
207a49103f
8 files changed
+282
-11
No files matched your search
@@ -38,6 +38,21 @@ export function hitRectAt(x, y, a) {
|
||||
const cx = x + (Number(a.dx) || 0), cy = y + (Number(a.dy) || 0);
|
||||
return { x0: cx - a.w / 2, x1: cx + a.w / 2, y0: cy - a.h / 2, y1: cy + a.h / 2 };
|
||||
}
|
||||
/**
|
||||
* Board tiles ([[row, col]]) a unit at (x, y) is hit on — as server/sim/body.js bodyKeys: a huge unit (`hitArea`) every tile
|
||||
* its rectangle overlaps (open intervals: a tile only touched along an edge is not), a point unit the tile of its
|
||||
* position; clipped to the rows × cols grid (19 × 21). The Final Assault prep draws a leader's (render/app.js, report #12).
|
||||
*/
|
||||
export function hitTiles(x, y, a, rows = 19, cols = 21) {
|
||||
if (!Number.isFinite(x) || !Number.isFinite(y)) return [];
|
||||
const R = hitRectAt(x, y, a);
|
||||
if (!R) { const r = Math.round(y), c = Math.round(x); return r >= 0 && r < rows && c >= 0 && c < cols ? [[r, c]] : []; }
|
||||
const r0 = Math.max(0, Math.floor(R.y0 + 0.5 + EPS)), r1 = Math.min(rows - 1, Math.ceil(R.y1 - 0.5 - EPS));
|
||||
const c0 = Math.max(0, Math.floor(R.x0 + 0.5 + EPS)), c1 = Math.min(cols - 1, Math.ceil(R.x1 - 0.5 - EPS));
|
||||
const out = [];
|
||||
for (let r = r0; r <= r1; r++) for (let c = c0; c <= c1; c++) out.push([r, c]);
|
||||
return out;
|
||||
}
|
||||
const inArea = (A, g) => !!A && !!g && g.x >= A.x0 && g.x <= A.x1 && g.y >= A.y0 && g.y <= A.y1;
|
||||
/** Screen point inside a huge body's upright box: `hw` tiles (its px per tile) either side of its x, feet up to head. */
|
||||
const inBox = (b, px, py) => !!b && b.hw > 0 && b.s > 0 && Math.abs(px - b.x) <= b.hw * b.s
|
||||
|
||||
Reference in new issue
Block a user