cutechicken commited on
Commit
27969e9
β€’
1 Parent(s): f8f064d

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +26 -8
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
- document.getElementById('startScreen').style.display = 'none';
1824
- document.body.requestPointerLock();
1825
-
1826
- // Create new game instance or restart existing one
1827
- if (!window.gameInstance) {
1828
- window.gameInstance = new Game();
1829
- }
 
 
 
1830
  };
1831
 
1832
  // Initialize game
1833
  document.addEventListener('DOMContentLoaded', () => {
1834
- const game = new Game();
 
 
 
 
 
 
 
 
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
  });