Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -58,7 +58,7 @@ class Fighter {
|
|
| 58 |
this.lastShootTime = 0;
|
| 59 |
|
| 60 |
// μΉ΄λ©λΌ μ€μ
|
| 61 |
-
this.cameraDistance =
|
| 62 |
this.cameraHeight = 45;
|
| 63 |
this.cameraLag = 0.1;
|
| 64 |
}
|
|
@@ -542,8 +542,8 @@ class Game {
|
|
| 542 |
// BGM μ¬μ λ‘λ©
|
| 543 |
await this.preloadBGM();
|
| 544 |
|
| 545 |
-
// λͺ¨λ 리μμ€ λ‘λ© μλ£ ν
|
| 546 |
-
this.
|
| 547 |
|
| 548 |
this.animate();
|
| 549 |
|
|
@@ -554,17 +554,28 @@ class Game {
|
|
| 554 |
}
|
| 555 |
}
|
| 556 |
|
| 557 |
-
|
| 558 |
if (this.isLoaded && this.isBGMReady) {
|
| 559 |
-
|
| 560 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 561 |
}
|
| 562 |
}
|
| 563 |
|
| 564 |
async preloadBGM() {
|
| 565 |
console.log('BGM μ¬μ λ‘λ©...');
|
| 566 |
|
| 567 |
-
return new Promise((resolve
|
| 568 |
try {
|
| 569 |
this.bgm = new Audio('sounds/main.ogg');
|
| 570 |
this.bgm.volume = 0.5;
|
|
@@ -586,14 +597,14 @@ class Game {
|
|
| 586 |
// νμΌ μ¬μ λ‘λ©
|
| 587 |
this.bgm.load();
|
| 588 |
|
| 589 |
-
// νμμμ μ€μ (
|
| 590 |
setTimeout(() => {
|
| 591 |
if (!this.isBGMReady) {
|
| 592 |
console.log('BGM λ‘λ© νμμμ - κ²μ μ§ν');
|
| 593 |
this.isBGMReady = true;
|
| 594 |
resolve();
|
| 595 |
}
|
| 596 |
-
},
|
| 597 |
|
| 598 |
} catch (error) {
|
| 599 |
console.log('BGM μ¬μ λ‘λ© μ€ν¨:', error);
|
|
|
|
| 58 |
this.lastShootTime = 0;
|
| 59 |
|
| 60 |
// μΉ΄λ©λΌ μ€μ
|
| 61 |
+
this.cameraDistance = 260;
|
| 62 |
this.cameraHeight = 45;
|
| 63 |
this.cameraLag = 0.1;
|
| 64 |
}
|
|
|
|
| 542 |
// BGM μ¬μ λ‘λ©
|
| 543 |
await this.preloadBGM();
|
| 544 |
|
| 545 |
+
// λͺ¨λ 리μμ€ λ‘λ© μλ£ ν UI μ
λ°μ΄νΈ
|
| 546 |
+
this.showStartScreen();
|
| 547 |
|
| 548 |
this.animate();
|
| 549 |
|
|
|
|
| 554 |
}
|
| 555 |
}
|
| 556 |
|
| 557 |
+
showStartScreen() {
|
| 558 |
if (this.isLoaded && this.isBGMReady) {
|
| 559 |
+
// λ‘λ© νλ©΄ μ¨κΈ°κΈ°
|
| 560 |
+
const loadingElement = document.getElementById('loading');
|
| 561 |
+
if (loadingElement) {
|
| 562 |
+
loadingElement.style.display = 'none';
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
// Start Game νλ©΄ νμ
|
| 566 |
+
const startScreen = document.getElementById('startScreen');
|
| 567 |
+
if (startScreen) {
|
| 568 |
+
startScreen.style.display = 'flex';
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
console.log('λͺ¨λ 리μμ€ μ€λΉ μλ£ - Start Game λ²νΌ νμ');
|
| 572 |
}
|
| 573 |
}
|
| 574 |
|
| 575 |
async preloadBGM() {
|
| 576 |
console.log('BGM μ¬μ λ‘λ©...');
|
| 577 |
|
| 578 |
+
return new Promise((resolve) => {
|
| 579 |
try {
|
| 580 |
this.bgm = new Audio('sounds/main.ogg');
|
| 581 |
this.bgm.volume = 0.5;
|
|
|
|
| 597 |
// νμΌ μ¬μ λ‘λ©
|
| 598 |
this.bgm.load();
|
| 599 |
|
| 600 |
+
// νμμμ μ€μ (3μ΄ νμλ λ‘λ©μ΄ μλλ©΄ κ°μ λ‘ μλ£)
|
| 601 |
setTimeout(() => {
|
| 602 |
if (!this.isBGMReady) {
|
| 603 |
console.log('BGM λ‘λ© νμμμ - κ²μ μ§ν');
|
| 604 |
this.isBGMReady = true;
|
| 605 |
resolve();
|
| 606 |
}
|
| 607 |
+
}, 3000);
|
| 608 |
|
| 609 |
} catch (error) {
|
| 610 |
console.log('BGM μ¬μ λ‘λ© μ€ν¨:', error);
|