cutechicken commited on
Commit
13fc40a
·
verified ·
1 Parent(s): 2ecc8f4

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +39 -1
game.js CHANGED
@@ -37,6 +37,11 @@ class TankPlayer {
37
  this.shootInterval = 1000;
38
  this.bullets = [];
39
  }
 
 
 
 
 
40
 
41
  async initialize(scene, loader) {
42
  try {
@@ -105,8 +110,9 @@ class TankPlayer {
105
  // UI 업데이트
106
  document.getElementById('ammo').textContent = `${this.ammo}/10`;
107
 
108
- // 연기 효과 생성
109
  this.createSmokeEffect(scene, bulletOffset);
 
110
 
111
  // 발사 소리 재생
112
  this.playRandomFireSound();
@@ -114,6 +120,37 @@ class TankPlayer {
114
  return bullet;
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  // 연기 효과 생성 메서드
118
  createSmokeEffect(scene, position) {
119
  const particleCount = 10;
@@ -157,6 +194,7 @@ playRandomFireSound() {
157
  ];
158
  const randomSound = sounds[Math.floor(Math.random() * sounds.length)];
159
  const audio = new Audio(randomSound);
 
160
  audio.play();
161
  }
162
 
 
37
  this.shootInterval = 1000;
38
  this.bullets = [];
39
  }
40
+ createMuzzleFlashEffect(scene, position) {
41
+
42
+ }
43
+ }
44
+
45
 
46
  async initialize(scene, loader) {
47
  try {
 
110
  // UI 업데이트
111
  document.getElementById('ammo').textContent = `${this.ammo}/10`;
112
 
113
+ // 연기 및 불꽃 효과 생성
114
  this.createSmokeEffect(scene, bulletOffset);
115
+ this.createMuzzleFlashEffect(scene, bulletOffset);
116
 
117
  // 발사 소리 재생
118
  this.playRandomFireSound();
 
120
  return bullet;
121
  }
122
 
123
+
124
+ createMuzzleFlashEffect(scene, position) {
125
+ // 빛 효과
126
+ const flashLight = new THREE.PointLight(0xffaa00, 2, 10);
127
+ flashLight.position.copy(this.body.position.clone().add(position));
128
+ scene.add(flashLight);
129
+
130
+ // 불꽃 구체
131
+ const flashGeometry = new THREE.SphereGeometry(0.3, 16, 16);
132
+ const flashMaterial = new THREE.MeshBasicMaterial({ color: 0xffaa00 });
133
+ const flashMesh = new THREE.Mesh(flashGeometry, flashMaterial);
134
+ flashMesh.position.copy(this.body.position.clone().add(position));
135
+ scene.add(flashMesh);
136
+
137
+ // 불꽃 효과 업데이트
138
+ let lifetime = 10;
139
+ const updateFlash = () => {
140
+ if (lifetime <= 0) {
141
+ scene.remove(flashMesh);
142
+ scene.remove(flashLight);
143
+ return;
144
+ }
145
+ lifetime--;
146
+ flashMesh.scale.multiplyScalar(0.9);
147
+ flashLight.intensity *= 0.9;
148
+ requestAnimationFrame(updateFlash);
149
+ };
150
+ updateFlash();
151
+ }
152
+
153
+
154
  // 연기 효과 생성 메서드
155
  createSmokeEffect(scene, position) {
156
  const particleCount = 10;
 
194
  ];
195
  const randomSound = sounds[Math.floor(Math.random() * sounds.length)];
196
  const audio = new Audio(randomSound);
197
+ audio.volume = 0.5; // 소리 크기를 50%로 줄임
198
  audio.play();
199
  }
200