Merge branch 'main' of https://git-eng.ukwms.ac.id/2526-web/Kelompok02-Memory-Card
This commit is contained in:
commit
2bc754abb3
@ -1,10 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Memory Card</title>
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Memory Card</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
@ -21,14 +20,13 @@ body {
|
||||
align-items: center;
|
||||
padding: 6px 10px;
|
||||
width: 100%;
|
||||
background: rgb(255, 255, 255);
|
||||
backdrop-filter: blur white(14px);
|
||||
background: rgba(255, 255, 255, 0.6);
|
||||
backdrop-filter: blur(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;
|
||||
@ -38,13 +36,11 @@ body {
|
||||
padding-left: 6px;
|
||||
}
|
||||
|
||||
|
||||
.right-info {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
|
||||
.pill {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -57,42 +53,89 @@ body {
|
||||
font-size: 16px;
|
||||
color: #002a60;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.15),
|
||||
inset 0 0 4px rgba(255,255,255,0.5);
|
||||
inset 0 0 4px rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
.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">
|
||||
<header class="topbar">
|
||||
<div id="container">
|
||||
<header class="topbar">
|
||||
<button class="back-btn" onclick="window.location.href='mainboard.html'">←</button>
|
||||
|
||||
<div class="right-info">
|
||||
<div class="pill">
|
||||
<span class="icon">⏱</span> <span id="timer">60</span>s
|
||||
<span class="icon">⏱</span> <span id="timer">60</span>s
|
||||
</div>
|
||||
|
||||
<div class="pill" id="score">
|
||||
<span class="icon">⭐</span> 0
|
||||
<span class="icon">⭐</span> 0
|
||||
</div>
|
||||
|
||||
<div class="pill" id="move-count">
|
||||
<span class="icon">🎯</span> 0
|
||||
<span class="icon">🎯</span> 0
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</header>
|
||||
</header>
|
||||
|
||||
<div class="gameboard">
|
||||
|
||||
</div>
|
||||
<div id="game-board" class="gameboard">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const imageList = [
|
||||
const imageList = [
|
||||
"alpukat.jpg",
|
||||
"anggur.jpg",
|
||||
"apel.jpg",
|
||||
@ -105,12 +148,11 @@ body {
|
||||
"semangka.jpg"
|
||||
];
|
||||
|
||||
let images = [...imageList, ...imageList]; // double for pairs
|
||||
let images = [...imageList, ...imageList];
|
||||
|
||||
|
||||
// SHUFFLE FUNCTION
|
||||
function shuffle(array) {
|
||||
let currentIndex = array.length, randomIndex;
|
||||
|
||||
while (currentIndex !== 0) {
|
||||
randomIndex = Math.floor(Math.random() * currentIndex);
|
||||
currentIndex--;
|
||||
@ -119,7 +161,7 @@ function shuffle(array) {
|
||||
return array;
|
||||
}
|
||||
|
||||
// VARIABLES
|
||||
|
||||
let time = 60;
|
||||
let timerElement = document.getElementById("timer");
|
||||
let movesElement = document.getElementById("move-count");
|
||||
@ -130,7 +172,6 @@ let moves = 0;
|
||||
let score = 0;
|
||||
let flippedCards = [];
|
||||
|
||||
// TIMER
|
||||
function startTimer() {
|
||||
if (timerStarted) return;
|
||||
timerStarted = true;
|
||||
@ -138,7 +179,6 @@ function startTimer() {
|
||||
countdown = setInterval(() => {
|
||||
time--;
|
||||
timerElement.textContent = time;
|
||||
|
||||
if (time <= 0) {
|
||||
clearInterval(countdown);
|
||||
alert("Waktu Habis!");
|
||||
@ -147,7 +187,6 @@ function startTimer() {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// FLIP CARD FUNCTION
|
||||
function flipCard(card) {
|
||||
if (!timerStarted) startTimer();
|
||||
|
||||
@ -178,7 +217,6 @@ function flipCard(card) {
|
||||
}
|
||||
}
|
||||
|
||||
// START GAME
|
||||
function startGame() {
|
||||
const board = document.getElementById("game-board");
|
||||
board.innerHTML = "";
|
||||
@ -200,7 +238,7 @@ function startGame() {
|
||||
board.appendChild(card);
|
||||
});
|
||||
|
||||
// reset stats
|
||||
|
||||
time = 60;
|
||||
timerElement.textContent = time;
|
||||
timerStarted = false;
|
||||
@ -210,8 +248,8 @@ function startGame() {
|
||||
scoreElement.textContent = score;
|
||||
}
|
||||
|
||||
startGame();
|
||||
|
||||
startGame();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user