Spaces:
Running
Running
cutechicken
commited on
Commit
β’
27969e9
1
Parent(s):
f8f064d
Update game.js
Browse files
game.js
CHANGED
@@ -847,6 +847,8 @@ class Particle {
|
|
847 |
// Game ν΄λμ€
|
848 |
class Game {
|
849 |
constructor() {
|
|
|
|
|
850 |
// μ€λμ€ κ΄λ ¨ μμ± μΆκ°
|
851 |
this.engineSound = null;
|
852 |
this.engineStopSound = null;
|
@@ -1790,6 +1792,11 @@ class Game {
|
|
1790 |
}
|
1791 |
|
1792 |
this.animationFrameId = requestAnimationFrame(() => this.animate());
|
|
|
|
|
|
|
|
|
|
|
1793 |
|
1794 |
const currentTime = performance.now();
|
1795 |
const deltaTime = (currentTime - this.lastTime) / 1000;
|
@@ -1820,16 +1827,27 @@ class Game {
|
|
1820 |
|
1821 |
// Start game
|
1822 |
window.startGame = function() {
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
|
|
|
|
|
|
1830 |
};
|
1831 |
|
1832 |
// Initialize game
|
1833 |
document.addEventListener('DOMContentLoaded', () => {
|
1834 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1835 |
});
|
|
|
847 |
// Game ν΄λμ€
|
848 |
class Game {
|
849 |
constructor() {
|
850 |
+
// κ²μ μμ μ¬λΆλ₯Ό μΆμ νλ νλκ·Έ μΆκ°
|
851 |
+
this.isStarted = false;
|
852 |
// μ€λμ€ κ΄λ ¨ μμ± μΆκ°
|
853 |
this.engineSound = null;
|
854 |
this.engineStopSound = null;
|
|
|
1792 |
}
|
1793 |
|
1794 |
this.animationFrameId = requestAnimationFrame(() => this.animate());
|
1795 |
+
// κ²μμ΄ μμλμ§ μμμΌλ©΄ λ λλ§λ§ μν
|
1796 |
+
if (!this.isStarted) {
|
1797 |
+
this.renderer.render(this.scene, this.camera);
|
1798 |
+
return;
|
1799 |
+
}
|
1800 |
|
1801 |
const currentTime = performance.now();
|
1802 |
const deltaTime = (currentTime - this.lastTime) / 1000;
|
|
|
1827 |
|
1828 |
// Start game
|
1829 |
window.startGame = function() {
|
1830 |
+
document.getElementById('startScreen').style.display = 'none';
|
1831 |
+
document.body.requestPointerLock();
|
1832 |
+
|
1833 |
+
if (!window.gameInstance) {
|
1834 |
+
window.gameInstance = new Game();
|
1835 |
+
}
|
1836 |
+
|
1837 |
+
// κ²μ μμ μ€μ
|
1838 |
+
window.gameInstance.isStarted = true;
|
1839 |
+
window.gameInstance.initialize();
|
1840 |
};
|
1841 |
|
1842 |
// Initialize game
|
1843 |
document.addEventListener('DOMContentLoaded', () => {
|
1844 |
+
// κ²μ μΈμ€ν΄μ€λ§ μμ±νκ³ μ΄κΈ°νλ νμ§ μμ
|
1845 |
+
window.gameInstance = new Game();
|
1846 |
+
|
1847 |
+
// κΈ°λ³Έμ μΈ μ¬ μ€μ λ§ μν
|
1848 |
+
window.gameInstance.setupScene();
|
1849 |
+
window.gameInstance.animate(); // λ λλ§ μμ
|
1850 |
+
|
1851 |
+
// μμ νλ©΄ νμ
|
1852 |
+
document.getElementById('startScreen').style.display = 'block';
|
1853 |
});
|