ProPerNounpYK commited on
Commit
d96d2fc
·
verified ·
1 Parent(s): 4c4af5a

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +180 -390
index.html CHANGED
@@ -1,401 +1,191 @@
1
  <!DOCTYPE html>
2
- <html lang="ko">
3
  <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Space Guardians Game</title>
7
- <style>
8
- body {
9
- margin: 0;
10
- overflow: hidden;
11
- background: #1a1a1a;
12
- display: flex;
13
- justify-content: center;
14
- align-items: center;
15
- min-height: 100vh;
16
- }
17
-
18
- #introCanvas {
19
- cursor: pointer;
20
- }
21
-
22
- #gameCanvas {
23
- display: none;
24
- background-image: url('stage 1.jpg');
25
- background-size: cover;
26
- }
27
-
28
- #message {
29
- position: fixed;
30
- bottom: 550px;
31
- left: 0;
32
- width: 100%;
33
- color: white;
34
- text-align: center;
35
- font-size: 30px;
36
- font-family: Arial;
37
- display: none;
38
- }
39
-
40
- #stats {
41
- position: fixed;
42
- top: 20px;
43
- left: 20px;
44
- color: white;
45
- font-family: Arial;
46
- font-size: 28px;
47
- display: none;
48
- }
49
-
50
- #villainCount {
51
- position: fixed;
52
- top: 20px;
53
- right: 20px;
54
- color: white;
55
- font-family: Arial;
56
- font-size: 28px;
57
- display: none;
58
- }
59
-
60
- #healthBar {
61
- width: 300px;
62
- height: 30px;
63
- background: #333;
64
- margin-top: 5px;
65
- }
66
-
67
- #healthFill {
68
- width: 100%;
69
- height: 100%;
70
- background: red;
71
- transition: width 0.3s;
72
- }
73
-
74
- #bulletCount, #enemyCount {
75
- font-size: 28px;
76
- }
77
-
78
- #replayButton {
79
- position: fixed;
80
- top: 50%;
81
- left: 50%;
82
- transform: translate(-50%, -50%);
83
- padding: 15px 30px;
84
- font-size: 20px;
85
- font-family: Arial;
86
- background-color: white;
87
- color: black;
88
- border: none;
89
- border-radius: 5px;
90
- display: none;
91
- cursor: pointer;
92
- }
93
-
94
- #replayButton:hover {
95
- background-color: lightgray;
96
- }
97
- </style>
98
  </head>
99
  <body>
100
- <canvas id="introCanvas"></canvas>
101
- <canvas id="gameCanvas"></canvas>
102
- <div id="message"></div>
103
- <div id="stats">
104
- Health:
105
- <div id="healthBar"><div id="healthFill"></div></div>
106
- Bullets: <span id="bulletCount">35</span>
107
- </div>
108
- <div id="villainCount">Villains: <span id="enemyCount">30</span></div>
109
- <button id="replayButton">Replay</button>
110
-
111
- <audio id="bgMusic" src="cinematic-time-lapse-115672.mp3" loop></audio>
112
- <audio id="playerShootSound" src="Maincharactergunsound.mp3"></audio>
113
- <audio id="enemyShootSound" src="Renovatorsgunshot.mp3"></audio>
114
- <audio id="playerHitSound" src="Maincharactershot.mp3"></audio>
115
- <audio id="enemyHitSound" src="Renovatorsgetshot.mp3"></audio>
116
-
117
- <script>
118
- const introCanvas = document.getElementById('introCanvas');
119
- const ctx = introCanvas.getContext('2d');
120
- const message = document.getElementById('message');
121
- const healthFill = document.getElementById('healthFill');
122
- const bulletCount = document.getElementById('bulletCount');
123
- const enemyCount = document.getElementById('enemyCount');
124
- const replayButton = document.getElementById('replayButton');
125
- const gameCanvas = document.getElementById('gameCanvas');
126
- const gameCtx = gameCanvas.getContext('2d');
127
-
128
- let particles = [];
129
- let currentPhraseIndex = 0;
130
- let animationFrame;
131
- let mouseX = 0;
132
- let mouseY = 0;
133
- let gameStarted = false;
134
- let gameOver = false;
135
-
136
- introCanvas.width = window.innerWidth;
137
- introCanvas.height = window.innerHeight;
138
- gameCanvas.width = window.innerWidth;
139
- gameCanvas.height = window.innerHeight;
140
-
141
- // Particle class to generate text effect during intro
142
- class Particle {
143
- constructor(x, y, targetX, targetY) {
144
- this.x = Math.random() * introCanvas.width;
145
- this.y = Math.random() * introCanvas.height;
146
- this.targetX = targetX;
147
- this.targetY = targetY;
148
- this.dx = (Math.random() - 0.5) * 8;
149
- this.dy = (Math.random() - 0.5) * 8;
150
- this.radius = 2;
151
- this.alpha = 1;
152
- this.fadeSpeed = 0.02;
153
- }
154
-
155
- draw() {
156
- ctx.beginPath();
157
- ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
158
- ctx.fillStyle = `rgba(255, 255, 255, ${this.alpha})`;
159
- ctx.fill();
160
- ctx.closePath();
161
- }
162
-
163
- update() {
164
- const distance = Math.hypot(mouseX - this.x, mouseY - this.y);
165
-
166
- if (distance < 100) {
167
- this.x += this.dx;
168
- this.y += this.dy;
169
- } else {
170
- this.x += (this.targetX - this.x) * 0.1;
171
- this.y += (this.targetY - this.y) * 0.1;
172
- }
173
- }
174
- }
175
-
176
- function createParticles(phrase) {
177
- let newParticles = [];
178
- ctx.clearRect(0, 0, introCanvas.width, introCanvas.height);
179
-
180
- const lines = phrase.text.split('\n');
181
-
182
- lines.forEach((line, index) => {
183
- const size = phrase.sizes ? phrase.sizes[index] : phrase.size;
184
- ctx.font = `${size}px Arial`;
185
- ctx.fillStyle = 'white';
186
- ctx.textAlign = 'center';
187
- ctx.textBaseline = 'middle';
188
-
189
- const spacing = phrase.spacing || size * 1.2;
190
- const y = (introCanvas.height / 2 - 20) + (index - (lines.length - 1) / 2) * spacing;
191
- ctx.fillText(line, introCanvas.width / 2, y);
192
- });
193
-
194
- const imageData = ctx.getImageData(0, 0, introCanvas.width, introCanvas.height).data;
195
-
196
- for (let y = 0; y < introCanvas.height; y += 4) {
197
- for (let x = 0; x < introCanvas.width; x += 4) {
198
- const index = (y * introCanvas.width + x) * 4;
199
- const alpha = imageData[index + 3];
200
-
201
- if (alpha > 128) {
202
- newParticles.push(new Particle(x, y, x, y));
203
- }
204
- }
205
- }
206
-
207
- ctx.clearRect(0, 0, introCanvas.width, introCanvas.height);
208
- return newParticles;
209
- }
210
-
211
- function transition() {
212
- if (currentPhraseIndex < phrases.length - 1) {
213
- currentPhraseIndex++;
214
- const currentPhrase = phrases[currentPhraseIndex];
215
-
216
- particles.forEach(particle => {
217
- particle.dx = (Math.random() - 0.5) * 20;
218
- particle.dy = (Math.random() - 0.5) * 20;
219
- const fadeOut = setInterval(() => {
220
- particle.alpha -= particle.fadeSpeed;
221
- if (particle.alpha <= 0) clearInterval(fadeOut);
222
- }, 50);
223
- });
224
-
225
- setTimeout(() => {
226
- particles = createParticles(currentPhrase);
227
- particles.forEach(particle => {
228
- particle.alpha = 0;
229
- const fadeIn = setInterval(() => {
230
- particle.alpha += particle.fadeSpeed;
231
- if (particle.alpha >= 1) clearInterval(fadeIn);
232
- }, 50);
233
- });
234
- }, 800);
235
-
236
- if (currentPhrase.duration) {
237
- setTimeout(transition, currentPhrase.duration);
238
- }
239
- } else {
240
- // 마지막 문구가 표시된 후 1초 후에 게임 시작
241
- setTimeout(() => {
242
- cancelAnimationFrame(animationFrame); // 인트로 애니메이션 중지
243
- introCanvas.style.display = 'none';
244
- gameCanvas.style.display = 'block';
245
- document.getElementById('stats').style.display = 'block';
246
- document.getElementById('villainCount').style.display = 'block';
247
- document.getElementById('message').style.display = 'block';
248
- startGame(); // 게임 시작
249
- }, 1000);
250
  }
251
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
253
- function animate() {
254
- ctx.clearRect(0, 0, introCanvas.width, introCanvas.height);
255
  particles.forEach(particle => {
256
- particle.update();
257
- particle.draw();
 
 
 
258
  });
259
- animationFrame = requestAnimationFrame(animate);
260
- }
261
-
262
- window.addEventListener('mousemove', (e) => {
263
- mouseX = e.clientX;
264
- mouseY = e.clientY;
265
- });
266
-
267
- window.addEventListener('click', () => {
268
- if (!gameStarted) {
269
- introCanvas.style.display = 'none';
270
- gameCanvas.style.display = 'block';
271
- startGame();
272
- }
273
- });
274
-
275
- const phrases = [
276
- { text: 'Space Guardians Game\nComing soon!', size: 80, duration: 2000 },
277
- { text: 'The fate of New York is in your hands.', size: 60, duration: 2000 },
278
- { text: 'Defeat the Renovators and save the city in 2030!', size: 60, duration: 3000 }
279
- ];
280
-
281
- let particles = createParticles(phrases[0]);
282
-
283
- animate(); // 시작 시 인트로 애니메이션
284
-
285
- // 게임 시작 함수
286
- function startGame() {
287
- const player = {
288
- x: gameCanvas.width / 2,
289
- y: gameCanvas.height - 250,
290
- width: 250,
291
- height: 250,
292
- speed: 10,
293
- health: 10,
294
- bullets: 35,
295
- direction: 1,
296
- image: new Image(),
297
- imageLeft: 'Maincharacterdefaultleft.png',
298
- imageRight: 'Maincharacterdefaultright.png',
299
- imageShootLeft: 'gunshotleft.png',
300
- imageShootRight: 'gunshotright.png',
301
- imageHitLeft: 'ExplosionLeft.png',
302
- imageHitRight: 'ExplosionRight.png'
303
- };
304
-
305
- player.image.src = player.imageRight;
306
-
307
- let enemies = [];
308
- let bullets = [];
309
- let enemyBullets = [];
310
- let enemiesRemaining = 30;
311
-
312
- let gameOver = false;
313
-
314
- function spawnEnemy() {
315
- if (enemies.length >= 10) return;
316
-
317
- const side = Math.random() < 0.5 ? 0 : gameCanvas.width;
318
- const enemy = {
319
- x: side,
320
- y: Math.random() * (gameCanvas.height - 150),
321
- width: 250,
322
- height: 250,
323
- speed: side === 0 ? 1 : -1,
324
- image: new Image(),
325
- imageLeft: 'Renovators Default Right.png',
326
- imageRight: 'RenovatorsDefaultLeft.png',
327
- imageShootLeft: 'RenovatorsgunLeft.png',
328
- imageShootRight: 'RenovatorsGunRight.png',
329
- imageHitLeft: 'RenovatorsExplodeLeft.png',
330
- imageHitRight: 'RenovatorsExplodeRight.png',
331
- lastShootTime: Date.now()
332
- };
333
- enemy.image.src = side === 0 ? enemy.imageLeft : enemy.imageRight;
334
- enemies.push(enemy);
335
- }
336
-
337
- function enemyShoot(enemy) {
338
- const now = Date.now();
339
- if (now - enemy.lastShootTime >= 3000) {
340
- enemy.image.src = enemy.speed > 0 ? enemy.imageShootRight : enemy.imageShootLeft;
341
- enemyBullets.push({
342
- x: enemy.x + enemy.width / 2,
343
- y: enemy.y + enemy.height / 2.5,
344
- width: 10,
345
- height: 5,
346
- speed: enemy.speed > 0 ? 5 : -5
347
- });
348
- enemy.lastShootTime = now;
349
- enemyShootSound.play();
350
- }
351
- }
352
-
353
- // 총알 업데이트
354
- function updateBullets() {
355
- bullets.forEach((bullet, index) => {
356
- bullet.x += bullet.speed;
357
- gameCtx.fillStyle = 'yellow';
358
- gameCtx.fillRect(bullet.x, bullet.y, 10, 5);
359
- });
360
- }
361
-
362
- // 적 업데이트
363
- function updateEnemies() {
364
- enemies.forEach((enemy, enemyIndex) => {
365
- enemy.x += enemy.speed;
366
- gameCtx.drawImage(enemy.image, enemy.x, enemy.y, enemy.width, enemy.height);
367
- if (checkCollision(player, enemy)) {
368
- handlePlayerEnemyCollision(enemy, enemyIndex);
369
- }
370
- enemyShoot(enemy);
371
- });
372
- }
373
-
374
- // 게임 업데이트 루프
375
- function updateGame() {
376
- gameCtx.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
377
- player.direction = mouseX > player.x ? 1 : -1;
378
- player.image.src = player.direction === 1 ? player.imageRight : player.imageLeft;
379
- gameCtx.drawImage(player.image, player.x, player.y, player.width, player.height);
380
-
381
- updateBullets();
382
- updateEnemies();
383
- enemyBullets.forEach((bullet, index) => {
384
- bullet.x += bullet.speed;
385
- gameCtx.fillStyle = 'orange';
386
- gameCtx.fillRect(bullet.x, bullet.y, bullet.width, bullet.height);
387
- });
388
-
389
- if (!gameOver) {
390
- requestAnimationFrame(updateGame);
391
- }
392
- }
393
-
394
- // 적 생성 주기
395
- setInterval(spawnEnemy, 2000);
396
- bgMusic.play();
397
- updateGame();
398
- }
399
- </script>
400
  </body>
401
  </html>
 
1
  <!DOCTYPE html>
2
+ <html>
3
  <head>
4
+ <style>
5
+ body {
6
+ margin: 0;
7
+ overflow: hidden;
8
+ background: #1a1a1a;
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ min-height: 100vh;
13
+ }
14
+
15
+ canvas {
16
+ cursor: pointer;
17
+ }
18
+ </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </head>
20
  <body>
21
+ <canvas id="canvas"></canvas>
22
+
23
+ <script>
24
+ const canvas = document.getElementById('canvas');
25
+ const ctx = canvas.getContext('2d');
26
+
27
+ let particles = [];
28
+ const phrases = [
29
+ { text: 'Hello everyone.', size: 65, duration: 5000 },
30
+ { text: 'You have been selected as the next\nTimewalker for our team of Space Guardians.', size: 50, duration: 7000 },
31
+ { text: 'Repair the collapsing timelines\nand return safely.', size: 55, duration: 6000 },
32
+ { text: 'Good luck.\n- From the Space Guardians Leader', sizes: [65, 45], spacing: 45, duration: 6000 },
33
+ { text: 'TimeWalker', size: 65, duration: 3000 },
34
+ { text: 'Chapter 1', size: 65, duration: null }
35
+ ];
36
+
37
+ let currentPhraseIndex = 0;
38
+ let animationFrame;
39
+ let mouseX = 0;
40
+ let mouseY = 0;
41
+
42
+ canvas.width = window.innerWidth;
43
+ canvas.height = window.innerHeight;
44
+
45
+ class Particle {
46
+ constructor(x, y, targetX, targetY) {
47
+ this.x = Math.random() * canvas.width;
48
+ this.y = Math.random() * canvas.height;
49
+ this.targetX = targetX;
50
+ this.targetY = targetY;
51
+ this.dx = (Math.random() - 0.5) * 8;
52
+ this.dy = (Math.random() - 0.5) * 8;
53
+ this.radius = 2;
54
+ this.alpha = 1;
55
+ this.fadeSpeed = 0.02;
56
+ }
57
+
58
+ draw() {
59
+ ctx.beginPath();
60
+ ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
61
+ ctx.fillStyle = `rgba(255, 255, 255, ${this.alpha})`;
62
+ ctx.fill();
63
+ ctx.closePath();
64
+ }
65
+
66
+ update() {
67
+ const distance = Math.hypot(mouseX - this.x, mouseY - this.y);
68
+
69
+ if(distance < 100) {
70
+ this.x += this.dx;
71
+ this.y += this.dy;
72
+ } else {
73
+ this.x += (this.targetX - this.x) * 0.1;
74
+ this.y += (this.targetY - this.y) * 0.1;
75
+ }
76
+ }
77
+ }
78
+
79
+ function createParticles(phrase) {
80
+ let newParticles = [];
81
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
82
+
83
+ const lines = phrase.text.split('\n');
84
+
85
+ lines.forEach((line, index) => {
86
+ const size = phrase.sizes ? phrase.sizes[index] : phrase.size;
87
+ ctx.font = `${size}px Arial`;
88
+ ctx.fillStyle = 'white';
89
+ ctx.textAlign = 'center';
90
+ ctx.textBaseline = 'middle';
91
+
92
+ const spacing = phrase.spacing || size * 1.2;
93
+ const y = (canvas.height/2 - 20) + (index - (lines.length-1)/2) * spacing;
94
+ ctx.fillText(line, canvas.width/2, y);
95
+ });
96
+
97
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
98
+
99
+ for(let y = 0; y < canvas.height; y += 4) {
100
+ for(let x = 0; x < canvas.width; x += 4) {
101
+ const index = (y * canvas.width + x) * 4;
102
+ const alpha = imageData[index + 3];
103
+
104
+ if(alpha > 128) {
105
+ newParticles.push(new Particle(x, y, x, y));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
  }
108
+ }
109
+
110
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
111
+ return newParticles;
112
+ }
113
+
114
+ function transition() {
115
+ if(currentPhraseIndex < phrases.length - 1) {
116
+ currentPhraseIndex++;
117
+ const currentPhrase = phrases[currentPhraseIndex];
118
+
119
+ particles.forEach(particle => {
120
+ particle.dx = (Math.random() - 0.5) * 20;
121
+ particle.dy = (Math.random() - 0.5) * 20;
122
+ const fadeOut = setInterval(() => {
123
+ particle.alpha -= particle.fadeSpeed;
124
+ if(particle.alpha <= 0) clearInterval(fadeOut);
125
+ }, 50);
126
+ });
127
 
128
+ setTimeout(() => {
129
+ particles = createParticles(currentPhrase);
130
  particles.forEach(particle => {
131
+ particle.alpha = 0;
132
+ const fadeIn = setInterval(() => {
133
+ particle.alpha += particle.fadeSpeed;
134
+ if(particle.alpha >= 1) clearInterval(fadeIn);
135
+ }, 50);
136
  });
137
+ }, 800);
138
+
139
+ if(currentPhrase.duration) {
140
+ setTimeout(transition, currentPhrase.duration);
141
+ }
142
+ }
143
+ }
144
+
145
+ function animate() {
146
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
147
+ particles.forEach(particle => {
148
+ particle.update();
149
+ particle.draw();
150
+ });
151
+ animationFrame = requestAnimationFrame(animate);
152
+ }
153
+
154
+ canvas.addEventListener('mousemove', (e) => {
155
+ mouseX = e.clientX;
156
+ mouseY = e.clientY;
157
+ });
158
+
159
+ window.addEventListener('resize', () => {
160
+ canvas.width = window.innerWidth;
161
+ canvas.height = window.innerHeight;
162
+ particles = createParticles(phrases[currentPhraseIndex]);
163
+ });
164
+
165
+ particles = createParticles(phrases[0]);
166
+ particles.forEach(particle => {
167
+ particle.alpha = 0;
168
+ const fadeIn = setInterval(() => {
169
+ particle.alpha += particle.fadeSpeed;
170
+ if(particle.alpha >= 1) clearInterval(fadeIn);
171
+ }, 50);
172
+ });
173
+
174
+ animate();
175
+ setTimeout(transition, phrases[0].duration);
176
+
177
+ function playAudioForDuration(url, duration) {
178
+ const audio = new Audio(url);
179
+ audio.play();
180
+ setTimeout(() => {
181
+ audio.pause();
182
+ audio.currentTime = 0; // Reset to start
183
+ }, duration);
184
+ }
185
+
186
+ // Play audio for 31 seconds
187
+ playAudioForDuration('reflected-light-147979.mp3', 31000);
188
+
189
+ </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  </body>
191
  </html>