-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.html
54 lines (47 loc) · 1.78 KB
/
game.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Connect 4 Game</title>
<link
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
rel="stylesheet"
/>
<link rel="stylesheet" href="css/game.css" />
</head>
<body class="bg-dark text-white">
<div class="container text-center mt-5 position-relative">
<h1 class="display-4">Connect 4</h1>
<div class="d-flex justify-content-around mt-4">
<div id="player-wins" class="text-warning">Player Wins: 0</div>
<div id="cpu-wins" class="text-primary">CPU Wins: 0</div>
</div>
<div id="game-board" class="justify-content-center mt-4"></div>
<button id="restart-btn" class="btn btn-warning mt-4">
Restart Game
</button>
<button id="back-btn" class="btn btn-secondary mt-4">Main Menu</button>
<div
id="notification"
class="notification position-absolute top-50 start-50 translate-middle p-4 rounded shadow-lg"
></div>
</div>
<!-- Dynamically load the appropriate JavaScript based on the selected difficulty -->
<script>
const difficulty = localStorage.getItem("selectedDifficulty");
if (difficulty) {
const script = document.createElement("script");
script.src = `js/${difficulty}.js`;
document.body.appendChild(script);
} else {
console.error("No difficulty selected. Redirecting to home.");
window.location.href = "index.html";
}
// Add event listener to the back button
document.getElementById("back-btn").addEventListener("click", () => {
window.location.href = "index.html";
});
</script>
</body>
</html>