mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-21 11:09:30 -07:00
fix radar round/floor mismatch in calculations close #200
This commit is contained in:
@@ -9,10 +9,12 @@ const pixelToFile = (xPixel, yPixel) => {
|
|||||||
return `${yTile}-${xTile}`;
|
return `${yTile}-${xTile}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// convert a pixel location in the overall map to a pixel location on the tile
|
// convert a pixel location in the overall map to a pixel location on the tile set
|
||||||
const modTile = (xPixel, yPixel) => {
|
const modTile = (xPixel, yPixel) => {
|
||||||
const x = Math.round(xPixel) % TILE_SIZE.x;
|
// adjust for additional 1 tile when odd
|
||||||
const y = Math.round(yPixel) % TILE_SIZE.y;
|
const x = (Math.floor(xPixel) % (TILE_SIZE.x));
|
||||||
|
const y = (Math.floor(yPixel) % (TILE_SIZE.y));
|
||||||
|
|
||||||
return { x, y };
|
return { x, y };
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -46,8 +48,8 @@ const setTiles = (data) => {
|
|||||||
// determine which tiles are used
|
// determine which tiles are used
|
||||||
const usedTiles = [
|
const usedTiles = [
|
||||||
true,
|
true,
|
||||||
TILE_SIZE.x - tileShift.x < RADAR_FINAL_SIZE.width,
|
tileShift.x + TILE_SIZE.x > RADAR_FINAL_SIZE.width,
|
||||||
TILE_SIZE.y - tileShift.y < RADAR_FINAL_SIZE.width,
|
tileShift.y + TILE_SIZE.y > RADAR_FINAL_SIZE.height,
|
||||||
];
|
];
|
||||||
// if we need t[1] and t[2] then we also need t[3]
|
// if we need t[1] and t[2] then we also need t[3]
|
||||||
usedTiles.push(usedTiles[1] && usedTiles[2]);
|
usedTiles.push(usedTiles[1] && usedTiles[2]);
|
||||||
|
|||||||
Reference in New Issue
Block a user