Skip to content

Commit

Permalink
fix: use math to fix tessellation
Browse files Browse the repository at this point in the history
  • Loading branch information
spectrachrome committed Oct 17, 2023
1 parent f3fe499 commit 33f1435
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/src/plugins/hexMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,17 @@ const setupClickHandler = (map, game, grid, vectorSource) => {
*/
const drawGameBoard = (map, game, grid, vectorSource) => {
for (let y = 0; y < game.height; y++) {
// Make our edges straight again so the cell calculation works out
let xOffset = ((y % 2 !== 0) * 1) - y / 2;
if (y % 2 === 0) {
xOffset += 1.0;
} else {
xOffset += 0.5;
}

for (let x = 0; x < game.width; x++) {
const tile = game.board[y][x];
const hexCoords = grid.getHexagon([x, y]);
const hexCoords = grid.getHexagon([x + xOffset, y]);
const feature = new Feature(new Polygon([hexCoords]));

let style;
Expand Down

0 comments on commit 33f1435

Please sign in to comment.