diff --git a/gameboard-easy.html b/gameboard-easy.html index 63b506f..d6b9c38 100644 --- a/gameboard-easy.html +++ b/gameboard-easy.html @@ -5,23 +5,28 @@ Memory Card Premium @@ -172,16 +156,6 @@ const images = [ ]; let cards = [...images, ...images]; - -function shuffle(arr) { - let i = arr.length, j; - while (i > 0) { - j = Math.floor(Math.random() * i--); - [arr[i], arr[j]] = [arr[j], arr[i]]; - } - return arr; -} - let flipped = []; let timerStarted = false; let time = 60; @@ -193,7 +167,7 @@ function startTimer() { timerStarted = true; countdown = setInterval(() => { document.getElementById("timer").textContent = --time; - if (time <= 0) { + if(time <= 0){ clearInterval(countdown); alert("Waktu habis!"); document.querySelectorAll(".card").forEach(c => c.classList.add("flipped")); @@ -201,45 +175,45 @@ function startTimer() { }, 1000); } -function flipCard(card) { - if (!timerStarted) startTimer(); - if (flipped.length === 2 || card.classList.contains("matched") || card.classList.contains("flipped")) +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) { + 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) { + if(img1 === img2){ flipped.forEach(c => c.classList.add("matched")); score += 10; document.getElementById("score").textContent = score; - // Tambah 5 detik jika benar - time += 5; + time += 5; // tambah 5 detik jika cocok document.getElementById("timer").textContent = time; flipped = []; } else { - setTimeout(() => { - flipped.forEach(c => c.classList.remove("flipped")); + setTimeout(()=>{ + flipped.forEach(c=>c.classList.remove("flipped")); flipped = []; }, 800); } } } -function startGame() { +function startGame(){ const board = document.getElementById("game-board"); board.innerHTML = ""; - shuffle(cards).forEach(image => { + // tetap urutan (tidak shuffle) + cards.forEach(image => { const card = document.createElement("div"); card.className = "card"; card.innerHTML = ` @@ -248,7 +222,7 @@ function startGame() {
`; - card.onclick = () => flipCard(card); + card.onclick = ()=>flipCard(card); board.appendChild(card); }); @@ -265,6 +239,5 @@ function startGame() { startGame(); - diff --git a/mainboard.php b/mainboard.php index 824750e..71d7c7f 100644 --- a/mainboard.php +++ b/mainboard.php @@ -41,9 +41,10 @@ $user = $_SESSION['user']; // id, username, role
+

Easy Mode

+

Grid 3x4 (12 kartu)

+ +