forked from YadavAkhileshh/Alien-Invasion-Defense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
394 lines (343 loc) · 15.1 KB
/
index.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="Akhilesh Yadav">
<link rel="icon" href="favicon.png" type="image/x-icon">
<title>Alien Invasion Defense</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" />
<link rel="stylesheet" href="Alien.css">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="welcome1.html">
<audio id="backgroundMusic" src="background-music.wav" loop></audio>
<audio id="hitSound" src="hit-sound.wav"></audio>
<audio id="gameOverSound" src="gameOver.wav"></audio>
<audio id="healthBoostSound" src="health-boost-sound.m4a"></audio>
<audio id="speedBoostSound" src="speed-boost.m4a"></audio>
<audio id="shieldSound" src="shield.m4a"></audio>
</head>
<body>
<!-- <div id="liveLife">LIVE LIFE: <span id="lives">3</span></div> -->
<div id="gameControls">
<div class="controlGroup">
<label for="levelSelect" id="difficulty">Select Difficulty:</label>
<select id="levelSelect">
<option value="easy">Easy</option>
<option value="medium" selected>Medium</option>
<option value="hard">Hard</option>
</select>
</div>
<!-- Player name displayed here -->
<div class="controlGroup">
<span id="displayName" class="playerName"></span>
</div>
<div class="controlGroup">
<button id="startButton"><i class="fas fa-play"></i> Start Game</button>
<button id="pauseButton" style="display: none"><i class="fas fa-play"></i> Game paused</button>
<button id="restartButton" style="display: none"><i class="fas fa-redo"></i> Play Again </button>
</div>
</div>
<div id="gameContainer">
<canvas id="gameCanvas"></canvas>
<div id="gameOver">
<i class="fas fa-exclamation-circle"></i> Game Over<br /><span id="finalScore"></span>
</div>
<div class="gameProgress">
<div id="warningMessage" class="hidden">Only 1 life remaining!</div>
<div id="liveScore">LIVE SCORE: <span id="score">0</span></div>
<button id="pauseResumeButton">Pause</button>
<button id="pauseResumeButton">Restart</button>
<div id="liveLife">LIVE LIFE: <span id="lives">3</span></div>
</div>
<div id="nextLevelMessage" class="hidden"></div>
<div id="gameControls">
<div class="controlGroup">
<label for="levelSelect" id="difficulty">Select Difficulty:</label>
<select id="levelSelect">
<option value="easy">Easy</option>
<option value="medium" selected>Medium</option>
<option value="hard">Hard</option>
</select>
</div>
<div class="controlGroup">
<span id="displayName" class="playerName"></span>
</div>
<div class="controlGroup">
<button id="startButton"><i class="fas fa-play"></i> Start Game</button>
<button id="pauseButton" style="display: none;"><i class="fas fa-pause"></i> Game Paused</button>
<button id="restartButton" style="display: none;"><i class="fas fa-redo"></i> Play Again</button>
<div id="faqbtn">
<a href="FAQs.html">
<button class="faq-btn">FAQs</button>
</a>
</div>
</div>
<!-- <div id="liveScore">LIVE SCORE: <span id="score">0</span></div> -->
</div>
</div>
<header>
<a class="navbar-brand" href="#">
<!-- Add the logo image -->
<img src="logo-updated.png" class="logo">
</a>
</header>
<!-- <canvas id="gameCanvas"></canvas> -->
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div id="header">
<div class="sidebar">
<div id="liveScore ">LIVE SCORE: <span id="score">0</span></div>
<div id="liveLife">LIVE LIFE: <span id="lives">3</span></div>
<div id="gameInfo">
<i class="fas fa-star"></i> <span id="score">0</span> |
<i class="fas fa-level-up-alt"></i> <span id="level">1</span> |
<i class="fas fa-heart"></i> <span id="lives">3</span>
<span id="healthBoostTimer"></span>
<span id="speedBoostTimer"></span>
<span id="shieldTimer"></span>
</div>
<div id="gameInfo">
<i class="fas fa-star"></i> <span id="score">0</span> |
<i class="fas fa-level-up-alt"></i> <span id="level">1</span> |
<i class="fas fa-heart"></i> <span id="lives">3</span>
<!-- New span elements to display power-up timers -->
<span id="healthBoostTimer"></span>
<span id="speedBoostTimer"></span>
<span id="shieldTimer"></span>
</div>
<div id="instructions">
</div>
<div id="instructions">
<div>
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox">
<div class="slider"></div>
</label>
<span id="mode-label">Light Mode</span>
</div>
<div id="volumeControl">
<div id="muteControl">
<button id="muteButton" class="styled-button">
<i class="fas fa-volume-up"></i>
<p id="musicVolumeText">Music Volume</p>
</button>
<div id="instructions">
<div>
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox">
<div class="slider"></div>
</label>
<span id="mode-label">Light Mode</span>
</div>
<div id="volumeControl">
<div id="muteControl">
<button id="muteButton" class="styled-button">
<i class="fas fa-volume-up"></i> Music Volume
</button>
</div>
<input type="range" id="volumeSlider" min="0" max="1" step="0.1" value="0.5">
</div>
<input type="range" id="volumeSlider" min="0" max="1" step="0.1" value="0.5">
</div>
</div>
<h2 class="primary-btn" id="instructionsTitle">Player Instructions</h2>
<h2 class="primary-btn" id="signupButton"><a style="color: black;" href="./signup/signup.html">SignUp/Register</a></h2>
<h2 class="primary-btn" id="logoutButton" style="display: none;"><i class="fas fa-sign-out-alt"></i> Logout</h2>
<div id="instructionsList">
<p><i class="fas fa-arrow-left"></i> Use Left/Right Arrow keys or swipe to move</p>
<p><i class="fas fa-bolt"></i> Tap or press Spacebar to shoot</p>
<p><i class="fas fa-fighter-jet"></i> Destroy red alien ships</p>
<p><i class="fas fa-shield-alt"></i> Avoid aliens reaching the bottom</p>
<p><i class="fas fa-clock"></i> Survive as long as possible!</p>
<p><i class="fas fa-plus-circle"></i> Collect Health Boost power-ups</p>
<p><i class="fas fa-tachometer-alt"></i> Collect Speed Boost power-ups</p>
<p><i class="fas fa-shield-alt"></i> Collect Shield power-ups</p>
<p><i class="fas fa-shield-alt"></i><a href="./rules.html">explore more</a></p>
</div>
</div>
</div>
<div id="gameOver">
<i class="fas fa-exclamation-circle"></i> Game Over<br /><span id="finalScore"></span>
</div>
<div id="highScore">
High Score: <span id="highScoreValue"></span>
</div>
<!-- Player name display -->
<div class="nameofplayer" id="displayName">
<h1></h1>
</div>
<!-- Control buttons for mobile -->
<div class="controls">
<button id="leftButton">←</button>
<button id="fireButton">🔫</button>
<button id="rightButton">→</button>
</div>
<script src="Alien.js"></script>
<script src="darkMode.js"></script>
<script>
// Display player's name from local storage
document.addEventListener("DOMContentLoaded", () => {
// Retrieve the stored JSON string and parse it back to an object
let personData = localStorage.getItem("signupData");
const signupButton = document.getElementById('signupButton'); //Signup button Id
const logoutButton = document.getElementById('logoutButton'); //logout button Id
// Check if person data exists
if (personData) {
// Parse the JSON string to an object
const person = JSON.parse(personData);
// Get the name from the person object
const name = person.fullName;
document.getElementById(
"displayName"
).textContent = `best of luck, ${name}!`;
signupButton.style.display = 'none';
logoutButton.style.display = 'block';
} else {
// If no data is found, use default
const defaultName = "Adventurer";
document.getElementById(
"displayName"
).textContent = `best of luck, ${defaultName}!`;
signupButton.style.display = 'block';
logoutButton.style.display = 'none';
}
logoutButton.addEventListener('click', () => {
// Clear the signup data from localStorage
localStorage.removeItem("signupData");
// Refresh the page or update the display accordingly
location.reload(); // Reloads the page to reflect changes
});
});
// Level selection handling
// Mute/Unmute
const muteButton = document.getElementById('muteButton');
muteButton.addEventListener('click', () => {
if (backgroundMusic.muted) {
backgroundMusic.muted = false;
muteButton.innerHTML = '<i class="fas fa-volume-mute"></i> Mute';
} else {
backgroundMusic.muted = true;
muteButton.innerHTML = '<i class="fas fa-volume-up"></i> Unmute';
}
// Add event listener for the restart button
document.getElementById("restartButton").addEventListener("click", () => {
// Call the restartGame function (assuming it's defined in Alien.js)
if (typeof restartGame === "function") {
restartGame();
} else {
console.error("restartGame function is not defined");
}
});
});
</script>
<script>
// JavaScript to handle level selection
const startButton = document.getElementById('startButton');
const levelSelect = document.getElementById('levelSelect');
startButton.addEventListener('click', () => {
const selectedLevel = levelSelect.value;
console.log('Game starting at level:', selectedLevel);
startGame(selectedLevel);
});
function startGame(level) {
switch(level) {
case 'easy':
console.log('Easy mode');
break;
case 'medium':
console.log('Medium mode');
break;
case 'hard':
console.log('Hard mode');
break;
default:
console.log('Unknown level');
}
}
</script>
FeedbackPage
<script>
const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");
// Assign initial colors to the circles
circles.forEach(function (circle) {
circle.x = 0;
circle.y = 0;
});
window.addEventListener("mousemove", function (e) {
coords.x = e.clientX;
coords.y = e.clientY;
});
function animateCircles() {
let x = coords.x;
let y = coords.y;
circles.forEach(function (circle, index) {
circle.style.left = x - 12 + "px";
circle.style.top = y - 12 + "px";
circle.style.scale=(circles.length - index) / circles.length;
circle.x = x;
circle.y = y;
const nextCircle = circles[index + 1] || circles[0];
x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.3;
});
requestAnimationFrame(animateCircles);
}
animateCircles();
</script>
<button class="feedback-button" onclick="window.location.href='feedback.html'">Feedback</button>
main
</body>
</html>