Add timer

This commit is contained in:
Marcel
2018-05-10 12:37:35 +02:00
parent 21e687a207
commit f94aff64f4

View File

@@ -1,5 +1,7 @@
const canvas = document.getElementById('minesweeper-game'); const canvas = document.getElementById('minesweeper-game');
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
const container = document.getElementById('game-container');
const timeEl = document.getElementById('time');
const fieldSize = {x: 16, y: 12}; const fieldSize = {x: 16, y: 12};
let tileSize; let tileSize;
@@ -16,6 +18,9 @@ let zoomFactor = 1;
let renderingConfig; let renderingConfig;
let startTime = 0;
let timer;
/** /**
* Defines all possible colors for the tile numbers * Defines all possible colors for the tile numbers
* @type {{ 1: string, 2: string, 3: string, 4: string, 6: string }} * @type {{ 1: string, 2: string, 3: string, 4: string, 6: string }}
@@ -482,6 +487,7 @@ overlay2Canvas.addEventListener("click", (e) => {
if (isFirstClick) { if (isFirstClick) {
initBombs(pos.x, pos.y); initBombs(pos.x, pos.y);
initTime();
isFirstClick = false; isFirstClick = false;
} }