diff --git a/gameboard-easy.html b/gameboard-easy.html index 31868b1..bbfda91 100644 --- a/gameboard-easy.html +++ b/gameboard-easy.html @@ -4,7 +4,6 @@ Memory Card Premium - @@ -212,17 +204,26 @@ function flipCard(card) { if (!timerStarted) startTimer(); if (flipped.length === 2 || card.classList.contains("matched") || card.classList.contains("flipped")) return; + card.classList.add("flipped"); flipped.push(card); + if (flipped.length === 2) { moves++; document.getElementById("moves").textContent = moves; + let img1 = flipped[0].querySelector(".back img").src; let img2 = flipped[1].querySelector(".back img").src; + if (img1 === img2) { flipped.forEach(c => c.classList.add("matched")); score += 10; document.getElementById("score").textContent = score; + + // Tambah 5 detik jika benar + time += 5; + document.getElementById("timer").textContent = time; + flipped = []; } else { setTimeout(() => { @@ -236,6 +237,7 @@ function flipCard(card) { function startGame() { const board = document.getElementById("game-board"); board.innerHTML = ""; + shuffle(cards).forEach(image => { const card = document.createElement("div"); card.className = "card"; @@ -248,7 +250,13 @@ function startGame() { card.onclick = () => flipCard(card); board.appendChild(card); }); - time = 60; moves = 0; score = 0; flipped = []; timerStarted = false; + + time = 60; + moves = 0; + score = 0; + flipped = []; + timerStarted = false; + document.getElementById("timer").textContent = time; document.getElementById("moves").textContent = moves; document.getElementById("score").textContent = score;