fixing client color check

This commit is contained in:
HF 2020-03-15 21:35:04 +01:00
parent 298a568566
commit cf60df75e6
2 changed files with 6 additions and 3 deletions

View File

@ -123,9 +123,12 @@ export function getPixelFromChunkOffset(
return [x, y];
}
export function getCellInsideChunk(pixel: Cell): Cell {
export function getCellInsideChunk(
canvasSize: number,
pixel: Cell,
): Cell {
// TODO assert is positive!
return pixel.map((x) => mod(x, TILE_SIZE));
return pixel.map((x) => mod(x + canvasSize / 2, TILE_SIZE));
}
export function screenToWorld(

View File

@ -72,7 +72,7 @@ class ChunkLoader {
return 0;
}
return chunk.getColorIndex(
getCellInsideChunk([x, y]),
getCellInsideChunk(canvasSize, [x, y]),
);
}