Spaces:
Running
Running
cutechicken
commited on
Update index.html
Browse files- index.html +52 -23
index.html
CHANGED
@@ -304,6 +304,9 @@
|
|
304 |
bullets = [];
|
305 |
items = [];
|
306 |
effects = [];
|
|
|
|
|
|
|
307 |
|
308 |
bgm.loop = true;
|
309 |
bgm.play().catch(err => console.error("Error playing game music:", err));
|
@@ -312,25 +315,33 @@
|
|
312 |
initRound();
|
313 |
gameLoop();
|
314 |
}
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
}
|
331 |
-
countdownEl.textContent = countdownTime > 0 ? countdownTime : 'GO!';
|
332 |
-
}, 1000);
|
333 |
}
|
|
|
|
|
|
|
334 |
|
335 |
function initRound() {
|
336 |
console.log(`Initializing round ${currentRound}`);
|
@@ -605,6 +616,9 @@ const defaultPlayerStats = {
|
|
605 |
}
|
606 |
|
607 |
shoot() {
|
|
|
|
|
|
|
608 |
const mgSound = new Audio('firemg.ogg');
|
609 |
mgSound.volume = 0.5;
|
610 |
mgSound.play();
|
@@ -622,10 +636,13 @@ const defaultPlayerStats = {
|
|
622 |
}
|
623 |
|
624 |
update() {
|
|
|
|
|
|
|
625 |
this.x -= this.speed;
|
626 |
|
627 |
const now = Date.now();
|
628 |
-
if (now - this.lastShot > 200) {
|
629 |
this.shoot();
|
630 |
this.lastShot = now;
|
631 |
}
|
@@ -659,9 +676,17 @@ const defaultPlayerStats = {
|
|
659 |
}
|
660 |
|
661 |
function spawnSpitfires() {
|
662 |
-
|
|
|
663 |
const now = Date.now();
|
664 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
665 |
const positions = [
|
666 |
canvas.height * 0.2,
|
667 |
canvas.height * 0.5,
|
@@ -675,15 +700,19 @@ function spawnSpitfires() {
|
|
675 |
|
676 |
// 2์ด ํ ์คํํ์ด์ด ์์ฑ
|
677 |
setTimeout(() => {
|
678 |
-
|
679 |
-
|
680 |
-
|
|
|
|
|
|
|
681 |
}, 2000);
|
682 |
|
683 |
lastSpitfireSpawn = now;
|
684 |
}
|
685 |
}
|
686 |
}
|
|
|
687 |
|
688 |
class SupportUnit {
|
689 |
constructor(yPosition) {
|
|
|
304 |
bullets = [];
|
305 |
items = [];
|
306 |
effects = [];
|
307 |
+
spitfires = []; // ์คํํ์ด์ด ๋ฐฐ์ด ์ด๊ธฐํ ์ถ๊ฐ
|
308 |
+
warningLines = []; // ๊ฒฝ๊ณ ์ ๋ฐฐ์ด ์ด๊ธฐํ ์ถ๊ฐ
|
309 |
+
lastSpitfireSpawn = Date.now(); // ์คํฐ ํ์ด๋จธ ์ด๊ธฐํ
|
310 |
|
311 |
bgm.loop = true;
|
312 |
bgm.play().catch(err => console.error("Error playing game music:", err));
|
|
|
315 |
initRound();
|
316 |
gameLoop();
|
317 |
}
|
318 |
+
function startCountdown() {
|
319 |
+
isCountingDown = true;
|
320 |
+
countdownTime = 3;
|
321 |
+
countdownEl.style.display = 'block';
|
322 |
+
countdownEl.textContent = countdownTime;
|
323 |
+
bgm.pause();
|
324 |
+
countSound.play();
|
325 |
+
|
326 |
+
// ์คํํ์ด์ด ๊ด๋ จ ์์ ์ด๊ธฐํ
|
327 |
+
spitfires = [];
|
328 |
+
warningLines = [];
|
329 |
+
lastSpitfireSpawn = 0; // 0์ผ๋ก ์ด๊ธฐํํ์ฌ ์ ๋ผ์ด๋ ์์ ์ ๋ฐ๋ก ์คํฐ๋๋๋ก ํจ
|
330 |
+
|
331 |
+
// ์คํํ์ด์ด๊ฐ ๋ฐ์ฌํ ์ด์ ์ ๊ฑฐ
|
332 |
+
bullets = bullets.filter(bullet => !bullet.isSpitfireBullet);
|
333 |
|
334 |
+
const countInterval = setInterval(() => {
|
335 |
+
countdownTime--;
|
336 |
+
if(countdownTime <= 0) {
|
337 |
+
clearInterval(countInterval);
|
338 |
+
countdownEl.style.display = 'none';
|
339 |
+
isCountingDown = false;
|
340 |
+
bgm.play();
|
|
|
|
|
|
|
341 |
}
|
342 |
+
countdownEl.textContent = countdownTime > 0 ? countdownTime : 'GO!';
|
343 |
+
}, 1000);
|
344 |
+
}
|
345 |
|
346 |
function initRound() {
|
347 |
console.log(`Initializing round ${currentRound}`);
|
|
|
616 |
}
|
617 |
|
618 |
shoot() {
|
619 |
+
// ์นด์ดํธ๋ค์ด ์ค์๋ ๋ฐ์ฌํ์ง ์์
|
620 |
+
if (isCountingDown) return;
|
621 |
+
|
622 |
const mgSound = new Audio('firemg.ogg');
|
623 |
mgSound.volume = 0.5;
|
624 |
mgSound.play();
|
|
|
636 |
}
|
637 |
|
638 |
update() {
|
639 |
+
// ์นด์ดํธ๋ค์ด ์ค์ด๋ฉด false๋ฅผ ๋ฐํํ์ฌ ์คํํ์ด์ด ์ ๊ฑฐ
|
640 |
+
if (isCountingDown) return false;
|
641 |
+
|
642 |
this.x -= this.speed;
|
643 |
|
644 |
const now = Date.now();
|
645 |
+
if (now - this.lastShot > 200) {
|
646 |
this.shoot();
|
647 |
this.lastShot = now;
|
648 |
}
|
|
|
676 |
}
|
677 |
|
678 |
function spawnSpitfires() {
|
679 |
+
// 2์คํ
์ด์ง์ด๊ณ , ์นด์ดํธ๋ค์ด ์ค์ด ์๋๊ณ , ๊ฒ์์ด ์งํ ์ค์ผ ๋๋ง
|
680 |
+
if (currentStage === 2 && !isCountingDown && !gameOver && gameStarted) {
|
681 |
const now = Date.now();
|
682 |
+
|
683 |
+
// lastSpitfireSpawn์ด 0์ด๋ฉด ์ด๊ธฐํ
|
684 |
+
|
685 |
+
|
686 |
+
// 15์ด๋ง๋ค ์คํฐ
|
687 |
+
if (now - lastSpitfireSpawn > 15000) {
|
688 |
+
console.log('Spawning Spitfires...'); // ๋๋ฒ๊น
์ฉ ๋ก๊ทธ
|
689 |
+
|
690 |
const positions = [
|
691 |
canvas.height * 0.2,
|
692 |
canvas.height * 0.5,
|
|
|
700 |
|
701 |
// 2์ด ํ ์คํํ์ด์ด ์์ฑ
|
702 |
setTimeout(() => {
|
703 |
+
if (!isCountingDown && !gameOver) {
|
704 |
+
positions.forEach(y => {
|
705 |
+
spitfires.push(new Spitfire(y));
|
706 |
+
});
|
707 |
+
console.log('Spitfires spawned:', spitfires.length); // ๋๋ฒ๊น
์ฉ ๋ก๊ทธ
|
708 |
+
}
|
709 |
}, 2000);
|
710 |
|
711 |
lastSpitfireSpawn = now;
|
712 |
}
|
713 |
}
|
714 |
}
|
715 |
+
|
716 |
|
717 |
class SupportUnit {
|
718 |
constructor(yPosition) {
|