-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevelcomplete.html
62 lines (55 loc) · 2.09 KB
/
levelcomplete.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
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Level Complete - 3D Maze Game</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!-- Level Complete Overlay -->
<div id="levelCompleteOverlay" class="overlay">
<div class="overlay-content">
<h1>Level Complete!</h1>
<p>Proceed to Level <span id="nextLevel">1</span></p>
<button id="nextLevelButton">Next Level</button>
</div>
</div>
<script>
// Function to retrieve and display the next level number
function displayNextLevel() {
const currentLevel = parseInt(localStorage.getItem('currentLevel')) || 1;
const nextLevel = currentLevel + 1;
document.getElementById('nextLevel').textContent = nextLevel;
}
// Function to handle the next level button click
function handleNextLevel() {
let currentLevel = parseInt(localStorage.getItem('currentLevel')) || 1;
const maxLevel = 10;
if (currentLevel < maxLevel) {
currentLevel += 1;
localStorage.setItem('currentLevel', currentLevel);
// Redirect to the main game page to load the next level
window.location.href = 'index.html';
} else {
// If all levels are completed, show victory message
showVictory();
}
}
// Function to show Victory screen if all levels are completed
function showVictory() {
// Clear previous game data
localStorage.removeItem('currentLevel');
localStorage.removeItem('score');
// Store a victory flag
localStorage.setItem('victory', 'true');
// Redirect to the main game page
window.location.href = 'index.html';
}
// Initialize the page
window.onload = function() {
displayNextLevel();
document.getElementById('nextLevelButton').addEventListener('click', handleNextLevel);
};
</script>
</body>
</html>