cutechicken commited on
Commit
2ea558f
โ€ข
1 Parent(s): cd5ec46

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +5 -21
game.js CHANGED
@@ -43,21 +43,21 @@ class TankPlayer {
43
  const bodyResult = await loader.loadAsync('/models/abramsBody.glb');
44
  this.body = bodyResult.scene;
45
  this.body.position.copy(this.position);
46
-
47
  const turretResult = await loader.loadAsync('/models/abramsTurret.glb');
48
  this.turret = turretResult.scene;
49
-
50
  this.turretGroup.position.y = 0.2;
51
  this.turretGroup.add(this.turret);
52
  this.body.add(this.turretGroup);
53
-
54
  this.body.traverse((child) => {
55
  if (child.isMesh) {
56
  child.castShadow = true;
57
  child.receiveShadow = true;
58
  }
59
  });
60
-
61
  this.turret.traverse((child) => {
62
  if (child.isMesh) {
63
  child.castShadow = true;
@@ -67,29 +67,13 @@ class TankPlayer {
67
 
68
  scene.add(this.body);
69
  this.isLoaded = true;
 
70
  } catch (error) {
71
  console.error('Error loading tank models:', error);
72
  this.isLoaded = false;
73
  }
74
  }
75
 
76
- reload() {
77
- if (this.ammo < 10) {
78
- const reloadTime = 2000; // 2์ดˆ ๋™์•ˆ ์žฌ์žฅ์ „
79
- document.getElementById('reloadButton').disabled = true; // ๋ฒ„ํŠผ ๋น„ํ™œ์„ฑํ™”
80
- document.getElementById('reloadButton').textContent = 'Reloading...';
81
-
82
- setTimeout(() => {
83
- this.ammo = 10; // ํƒ„์•ฝ ์ถฉ์ „
84
- document.getElementById('ammo').textContent = `${this.ammo}/10`; // UI ์—…๋ฐ์ดํŠธ
85
- document.getElementById('reloadButton').disabled = false; // ๋ฒ„ํŠผ ํ™œ์„ฑํ™”
86
- document.getElementById('reloadButton').textContent = 'Reload'; // ๋ฒ„ํŠผ ํ…์ŠคํŠธ ๋ณต๊ตฌ
87
- }, reloadTime);
88
- }
89
- }
90
- }
91
-
92
-
93
  shoot(scene) {
94
  const currentTime = Date.now();
95
  if (currentTime - this.lastShootTime < this.shootInterval || this.ammo <= 0) return null;
 
43
  const bodyResult = await loader.loadAsync('/models/abramsBody.glb');
44
  this.body = bodyResult.scene;
45
  this.body.position.copy(this.position);
46
+
47
  const turretResult = await loader.loadAsync('/models/abramsTurret.glb');
48
  this.turret = turretResult.scene;
49
+
50
  this.turretGroup.position.y = 0.2;
51
  this.turretGroup.add(this.turret);
52
  this.body.add(this.turretGroup);
53
+
54
  this.body.traverse((child) => {
55
  if (child.isMesh) {
56
  child.castShadow = true;
57
  child.receiveShadow = true;
58
  }
59
  });
60
+
61
  this.turret.traverse((child) => {
62
  if (child.isMesh) {
63
  child.castShadow = true;
 
67
 
68
  scene.add(this.body);
69
  this.isLoaded = true;
70
+
71
  } catch (error) {
72
  console.error('Error loading tank models:', error);
73
  this.isLoaded = false;
74
  }
75
  }
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  shoot(scene) {
78
  const currentTime = Date.now();
79
  if (currentTime - this.lastShootTime < this.shootInterval || this.ammo <= 0) return null;