another one

This commit is contained in:
Nathan 2025-12-17 23:21:06 +07:00
parent c82cd12595
commit 33a32aeb6c

View File

@ -18,7 +18,6 @@ function playSFX(audio) {
}
}
// Interaksi pertama untuk aktifkan suara
document.addEventListener('click', function initAudio() {
if(musicMuted) {
musicMuted = false;
@ -40,10 +39,13 @@ toggleBtn.onclick = (e) => {
musicMuted = !musicMuted;
};
// --- GAME LOGIC ---
// --- GAME LOGIC MEDIUM ---
// 8 GAMBAR (Total 16 Kartu)
const images = [
"images/fruit1.png", "images/fruit2.png", "images/fruit3.png", "images/fruit4.png",
"images/fruit5.png", "images/fruit6.png", "images/fruit7.png", "images/fruit8.png"
"images/fruit1.png", "images/fruit2.png", "images/fruit3.png",
"images/fruit4.png", "images/fruit5.png", "images/fruit6.png",
"images/fruit7.png", "images/fruit8.png"
];
let cards = [...images, ...images];
@ -139,6 +141,20 @@ function showEndScreen(isWin) {
document.getElementById("moveBonusEnd").textContent = "+" + moveBonus;
document.getElementById("totalScoreEnd").textContent = total;
document.getElementById("endScreen").style.display = "flex";
if (isWin) {
let formData = new FormData();
formData.append('score', total);
formData.append('difficulty', 'Medium');
fetch('score.php', {
method: 'POST',
body: formData
})
.then(response => response.text())
.then(result => console.log("Status Database: " + result))
.catch(error => console.error('Error:', error));
}
}
function flipCard(card) {
@ -202,7 +218,9 @@ function startGame() {
card.onclick = () => flipCard(card);
board.appendChild(card);
});
time = 60; moves = 0; score = 0; combo = 1;
time = 60;
moves = 0; score = 0; combo = 1;
pendingMatch = false; flipped = []; timerStarted = false;
document.getElementById("timer").textContent = time;
document.getElementById("moves").textContent = moves;