Skip to content

Commit

Permalink
Merge pull request #9 from reigeiku/fix-tiles-not-loading
Browse files Browse the repository at this point in the history
fix(board): add draw board to draw saved game after it's been loaded
  • Loading branch information
reigeiku committed Apr 29, 2024
2 parents 8203080 + 23ab177 commit f55cdd9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/heart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ const redrawBoard = (): void => {
}
};

const drawBoard = (): void => {
for (let y = 0; y < 4; y++) {
for (let x = 0; x < 4; x++) {
const currTileValue: number = tilesValues[y][x];
if (!currTileValue) continue;
drawTile(y, x, currTileValue);
}
}
};

const start = (): void => {
tileCoords = createCoords();
scores = getScores();
Expand All @@ -186,6 +196,7 @@ const start = (): void => {
bestScoreBoard.innerText = bestScore.toString();

tilesValues = JSON.parse(boardAsString);
drawBoard();
};

window.addEventListener("resize", redrawBoard);
Expand Down

0 comments on commit f55cdd9

Please sign in to comment.