mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-27 19:44:21 +00:00
@@ -321,7 +321,16 @@ export function euclDistFN(
|
||||
root: TileRef,
|
||||
dist: number,
|
||||
): (gm: GameMap, tile: TileRef) => boolean {
|
||||
return (gm: GameMap, n: TileRef) => gm.euclideanDist(root, n) <= dist;
|
||||
return (gm: GameMap, n: TileRef) => {
|
||||
// shifts the root tile’s coordinates by -0.5 so that its “center”
|
||||
// center becomes the corner of four pixels rather than the middle of one pixel.
|
||||
// just makes things based off even pixels instead of odd. Used to use 9x9 icons now 10x10 icons etc...
|
||||
const rootX = gm.x(root) - 0.5;
|
||||
const rootY = gm.y(root) - 0.5;
|
||||
const dx = gm.x(n) - rootX;
|
||||
const dy = gm.y(n) - rootY;
|
||||
return Math.sqrt(dx * dx + dy * dy) <= dist;
|
||||
};
|
||||
}
|
||||
|
||||
export function manhattanDistFN(
|
||||
|
||||
Reference in New Issue
Block a user