openfree commited on
Commit
f5e5fa2
·
verified ·
1 Parent(s): 13219b7

Create index-backup1.html

Browse files
Files changed (1) hide show
  1. index-backup1.html +371 -0
index-backup1.html ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Zombie Survival</title>
6
+ <style>
7
+ body {
8
+ margin: 0;
9
+ overflow: hidden;
10
+ background: #333;
11
+ font-family: Arial, sans-serif;
12
+ cursor: crosshair;
13
+ }
14
+
15
+ #score {
16
+ position: fixed;
17
+ top: 20px;
18
+ left: 20px;
19
+ color: #fff;
20
+ font-size: 24px;
21
+ z-index: 100;
22
+ }
23
+
24
+ #health {
25
+ position: fixed;
26
+ top: 20px;
27
+ right: 20px;
28
+ color: #f00;
29
+ font-size: 24px;
30
+ z-index: 100;
31
+ }
32
+
33
+ #startScreen {
34
+ position: fixed;
35
+ top: 0;
36
+ left: 0;
37
+ width: 100%;
38
+ height: 100%;
39
+ background: rgba(0, 0, 0, 0.8);
40
+ display: flex;
41
+ flex-direction: column;
42
+ justify-content: center;
43
+ align-items: center;
44
+ z-index: 1000;
45
+ }
46
+
47
+ #startButton {
48
+ padding: 15px 40px;
49
+ font-size: 24px;
50
+ background: #4CAF50;
51
+ color: white;
52
+ border: none;
53
+ border-radius: 5px;
54
+ cursor: pointer;
55
+ transition: transform 0.2s;
56
+ }
57
+
58
+ #startButton:hover {
59
+ transform: scale(1.1);
60
+ }
61
+
62
+ #gameTitle {
63
+ color: #fff;
64
+ font-size: 48px;
65
+ margin-bottom: 30px;
66
+ text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
67
+ }
68
+
69
+ #gameOver {
70
+ position: fixed;
71
+ top: 50%;
72
+ left: 50%;
73
+ transform: translate(-50%, -50%);
74
+ color: #f00;
75
+ font-size: 48px;
76
+ display: none;
77
+ text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
78
+ z-index: 100;
79
+ }
80
+
81
+ .bullet {
82
+ position: absolute;
83
+ width: 8px;
84
+ height: 8px;
85
+ background: #ffd700;
86
+ border-radius: 50%;
87
+ z-index: 50;
88
+ box-shadow: 0 0 10px #ffd700;
89
+ }
90
+
91
+ #player {
92
+ position: absolute;
93
+ width: 40px;
94
+ height: 40px;
95
+ background: #0f0;
96
+ border-radius: 50%;
97
+ transform-origin: center;
98
+ z-index: 90;
99
+ box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
100
+ }
101
+
102
+ #playerGun {
103
+ position: absolute;
104
+ width: 20px;
105
+ height: 8px;
106
+ background: #666;
107
+ top: 50%;
108
+ right: -15px;
109
+ transform: translateY(-50%);
110
+ }
111
+
112
+ .zombie {
113
+ position: absolute;
114
+ width: 40px;
115
+ height: 40px;
116
+ background: #8B0000;
117
+ border-radius: 50%;
118
+ z-index: 80;
119
+ }
120
+
121
+ .explosion {
122
+ position: absolute;
123
+ width: 40px;
124
+ height: 40px;
125
+ border-radius: 50%;
126
+ animation: explode 0.5s ease-out forwards;
127
+ z-index: 85;
128
+ }
129
+
130
+ @keyframes explode {
131
+ 0% {
132
+ transform: scale(1);
133
+ background: #ff4500;
134
+ opacity: 1;
135
+ }
136
+ 100% {
137
+ transform: scale(2);
138
+ background: #ff0000;
139
+ opacity: 0;
140
+ }
141
+ }
142
+
143
+ .muzzleFlash {
144
+ position: absolute;
145
+ width: 20px;
146
+ height: 20px;
147
+ background: #ffd700;
148
+ border-radius: 50%;
149
+ opacity: 0;
150
+ animation: flash 0.1s ease-out;
151
+ }
152
+
153
+ @keyframes flash {
154
+ 0% { opacity: 1; transform: scale(1); }
155
+ 100% { opacity: 0; transform: scale(2); }
156
+ }
157
+ </style>
158
+ </head>
159
+ <body>
160
+ <audio id="bgMusic" src="soundz.wav" loop></audio>
161
+
162
+ <div id="startScreen">
163
+ <h1 id="gameTitle">ZOMBIE SURVIVAL</h1>
164
+ <button id="startButton">START GAME</button>
165
+ </div>
166
+
167
+ <div id="score">Score: 0</div>
168
+ <div id="health">Health: 100</div>
169
+ <div id="gameOver">GAME OVER</div>
170
+ <div id="player">
171
+ <div id="playerGun"></div>
172
+ </div>
173
+
174
+ <script>
175
+ const startScreen = document.getElementById('startScreen');
176
+ const startButton = document.getElementById('startButton');
177
+ const player = document.getElementById('player');
178
+ const scoreElement = document.getElementById('score');
179
+ const healthElement = document.getElementById('health');
180
+ const gameOverElement = document.getElementById('gameOver');
181
+ const bgMusic = document.getElementById('bgMusic');
182
+
183
+ let score = 0;
184
+ let health = 100;
185
+ let zombies = [];
186
+ let bullets = [];
187
+ let gameRunning = false;
188
+ let mouseX = 0;
189
+ let mouseY = 0;
190
+ let playerX = window.innerWidth / 2;
191
+ let playerY = window.innerHeight / 2;
192
+ let zombieSpawnInterval;
193
+
194
+ function startGame() {
195
+ startScreen.style.display = 'none';
196
+ gameRunning = true;
197
+ score = 0;
198
+ health = 100;
199
+ scoreElement.textContent = `Score: ${score}`;
200
+ healthElement.textContent = `Health: ${health}`;
201
+ gameOverElement.style.display = 'none';
202
+
203
+ // Start background music
204
+ bgMusic.play();
205
+
206
+ zombies.forEach(zombie => zombie.element.remove());
207
+ zombies = [];
208
+ bullets.forEach(bullet => bullet.element.remove());
209
+ bullets = [];
210
+
211
+ playerX = window.innerWidth / 2;
212
+ playerY = window.innerHeight / 2;
213
+ updatePlayer();
214
+
215
+ zombieSpawnInterval = setInterval(createZombie, 1000);
216
+ requestAnimationFrame(gameLoop);
217
+ }
218
+
219
+ function updatePlayer() {
220
+ player.style.left = `${playerX - 20}px`;
221
+ player.style.top = `${playerY - 20}px`;
222
+
223
+ const angle = Math.atan2(mouseY - playerY, mouseX - playerX);
224
+ player.style.transform = `rotate(${angle}rad)`;
225
+ }
226
+
227
+ function createZombie() {
228
+ if (!gameRunning) return;
229
+
230
+ const zombie = document.createElement('div');
231
+ zombie.className = 'zombie';
232
+
233
+ const side = Math.floor(Math.random() * 4);
234
+ let x, y;
235
+
236
+ switch(side) {
237
+ case 0: x = Math.random() * window.innerWidth; y = -40; break;
238
+ case 1: x = window.innerWidth + 40; y = Math.random() * window.innerHeight; break;
239
+ case 2: x = Math.random() * window.innerWidth; y = window.innerHeight + 40; break;
240
+ case 3: x = -40; y = Math.random() * window.innerHeight; break;
241
+ }
242
+
243
+ document.body.appendChild(zombie);
244
+ zombies.push({
245
+ element: zombie,
246
+ x: x,
247
+ y: y,
248
+ speed: 2 + Math.random()
249
+ });
250
+ }
251
+
252
+ function createMuzzleFlash() {
253
+ const flash = document.createElement('div');
254
+ flash.className = 'muzzleFlash';
255
+ const angle = Math.atan2(mouseY - playerY, mouseX - playerX);
256
+ const distance = 30;
257
+ const flashX = playerX + Math.cos(angle) * distance;
258
+ const flashY = playerY + Math.sin(angle) * distance;
259
+
260
+ flash.style.left = `${flashX - 10}px`;
261
+ flash.style.top = `${flashY - 10}px`;
262
+ document.body.appendChild(flash);
263
+
264
+ setTimeout(() => flash.remove(), 100);
265
+ }
266
+
267
+ function shoot(e) {
268
+ if (!gameRunning || e.button !== 0) return;
269
+
270
+ const bullet = document.createElement('div');
271
+ bullet.className = 'bullet';
272
+
273
+ const angle = Math.atan2(mouseY - playerY, mouseX - playerX);
274
+ const velocity = {
275
+ x: Math.cos(angle) * 15,
276
+ y: Math.sin(angle) * 15
277
+ };
278
+
279
+ createMuzzleFlash();
280
+
281
+ document.body.appendChild(bullet);
282
+ bullets.push({
283
+ element: bullet,
284
+ x: playerX,
285
+ y: playerY,
286
+ velocity: velocity
287
+ });
288
+ }
289
+
290
+ function createExplosion(x, y) {
291
+ const explosion = document.createElement('div');
292
+ explosion.className = 'explosion';
293
+ explosion.style.left = `${x - 20}px`;
294
+ explosion.style.top = `${y - 20}px`;
295
+ document.body.appendChild(explosion);
296
+
297
+ setTimeout(() => explosion.remove(), 500);
298
+ }
299
+
300
+ function gameLoop() {
301
+ if (!gameRunning) return;
302
+
303
+ bullets.forEach((bullet, bulletIndex) => {
304
+ bullet.x += bullet.velocity.x;
305
+ bullet.y += bullet.velocity.y;
306
+ bullet.element.style.left = `${bullet.x - 4}px`;
307
+ bullet.element.style.top = `${bullet.y - 4}px`;
308
+
309
+ if (bullet.x < 0 || bullet.x > window.innerWidth ||
310
+ bullet.y < 0 || bullet.y > window.innerHeight) {
311
+ bullet.element.remove();
312
+ bullets.splice(bulletIndex, 1);
313
+ }
314
+ });
315
+
316
+ zombies.forEach((zombie, zombieIndex) => {
317
+ const angle = Math.atan2(playerY - zombie.y, playerX - zombie.x);
318
+ zombie.x += Math.cos(angle) * zombie.speed;
319
+ zombie.y += Math.sin(angle) * zombie.speed;
320
+ zombie.element.style.left = `${zombie.x - 20}px`;
321
+ zombie.element.style.top = `${zombie.y - 20}px`;
322
+
323
+ const distToPlayer = Math.hypot(playerX - zombie.x, playerY - zombie.y);
324
+ if (distToPlayer < 40) {
325
+ health -= 1;
326
+ healthElement.textContent = `Health: ${health}`;
327
+ if (health <= 0) gameOver();
328
+ }
329
+
330
+ bullets.forEach((bullet, bulletIndex) => {
331
+ const distToBullet = Math.hypot(bullet.x - zombie.x, bullet.y - zombie.y);
332
+ if (distToBullet < 30) {
333
+ createExplosion(zombie.x, zombie.y);
334
+ zombie.element.remove();
335
+ bullet.element.remove();
336
+ zombies.splice(zombieIndex, 1);
337
+ bullets.splice(bulletIndex, 1);
338
+ score += 10;
339
+ scoreElement.textContent = `Score: ${score}`;
340
+ }
341
+ });
342
+ });
343
+
344
+ requestAnimationFrame(gameLoop);
345
+ }
346
+
347
+ function gameOver() {
348
+ gameRunning = false;
349
+ gameOverElement.style.display = 'block';
350
+ clearInterval(zombieSpawnInterval);
351
+ bgMusic.pause();
352
+ bgMusic.currentTime = 0;
353
+ setTimeout(() => {
354
+ startScreen.style.display = 'flex';
355
+ }, 2000);
356
+ }
357
+
358
+ document.addEventListener('mousemove', (e) => {
359
+ mouseX = e.clientX;
360
+ mouseY = e.clientY;
361
+ if (gameRunning) updatePlayer();
362
+ });
363
+
364
+ document.addEventListener('mousedown', shoot);
365
+ startButton.addEventListener('click', startGame);
366
+
367
+ // Initial setup
368
+ updatePlayer();
369
+ </script>
370
+ </body>
371
+ </html>