Compare commits

..

No commits in common. "f2a2345b659ca765c9bcf7e299f356538d2f6cb4" and "3bd80afe30f57eb22d9f6a32e03275399c27c426" have entirely different histories.

View File

@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Memory Card</title>
<style>
body {
margin: 0;
@ -20,13 +21,14 @@ body {
align-items: center;
padding: 6px 10px;
width: 100%;
background: rgba(255, 255, 255, 0.6);
backdrop-filter: blur(14px);
background: rgb(255, 255, 255);
backdrop-filter: blur white(14px);
border-top: 2px solid rgba(255, 255, 255, 0.4);
border-bottom: 2px solid rgba(255, 255, 255, 0.4);
box-sizing: border-box;
}
.back-btn {
background: none;
border: none;
@ -36,11 +38,13 @@ body {
padding-left: 6px;
}
.right-info {
display: flex;
gap: 10px;
}
.pill {
display: flex;
align-items: center;
@ -59,56 +63,8 @@ body {
.icon {
font-size: 18px;
}
.gameboard {
display: grid;
grid-template-columns: repeat(5, 100px);
justify-content: center;
gap: 15px;
margin: 20px auto;
}
.card {
width: 100px;
height: 120px;
perspective: 1000px;
cursor: pointer;
}
.inner {
width: 100%;
height: 100%;
position: relative;
transform-style: preserve-3d;
transition: transform 0.5s;
}
.front, .back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
border-radius: 10px;
background: rgba(255,255,255,0.8);
}
.back {
transform: rotateY(180deg);
}
.card.flipped .inner {
transform: rotateY(180deg);
}
.back img {
max-width: 70%;
max-height: 70%;
}
</style>
</head>
<body>
<div id = "container">
@ -127,13 +83,14 @@ body {
<div class="pill" id="move-count">
<span class="icon">🎯</span> 0
</div>
</div>
</header>
<div id="game-board" class="gameboard">
</div>
</div>
<div class="gameboard">
</div>
</div>
<script>
const imageList = [
"alpukat.jpg",
@ -148,11 +105,12 @@ const imageList = [
"semangka.jpg"
];
let images = [...imageList, ...imageList];
let images = [...imageList, ...imageList]; // double for pairs
// SHUFFLE FUNCTION
function shuffle(array) {
let currentIndex = array.length, randomIndex;
while (currentIndex !== 0) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;
@ -161,7 +119,7 @@ function shuffle(array) {
return array;
}
// VARIABLES
let time = 60;
let timerElement = document.getElementById("timer");
let movesElement = document.getElementById("move-count");
@ -172,6 +130,7 @@ let moves = 0;
let score = 0;
let flippedCards = [];
// TIMER
function startTimer() {
if (timerStarted) return;
timerStarted = true;
@ -179,6 +138,7 @@ function startTimer() {
countdown = setInterval(() => {
time--;
timerElement.textContent = time;
if (time <= 0) {
clearInterval(countdown);
alert("Waktu Habis!");
@ -187,6 +147,7 @@ function startTimer() {
}, 1000);
}
// FLIP CARD FUNCTION
function flipCard(card) {
if (!timerStarted) startTimer();
@ -217,6 +178,7 @@ function flipCard(card) {
}
}
// START GAME
function startGame() {
const board = document.getElementById("game-board");
board.innerHTML = "";
@ -238,7 +200,7 @@ function startGame() {
board.appendChild(card);
});
// reset stats
time = 60;
timerElement.textContent = time;
timerStarted = false;
@ -248,8 +210,8 @@ function startGame() {
scoreElement.textContent = score;
}
startGame();
</script>
</body>
</html>