Spaces:
Running
Running
Update index.html
Browse files- index.html +54 -30
index.html
CHANGED
@@ -190,22 +190,24 @@
|
|
190 |
}, 1000);
|
191 |
}
|
192 |
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
|
|
209 |
|
210 |
if (isBoss) {
|
211 |
this.enemyImg = new Image();
|
@@ -239,21 +241,43 @@
|
|
239 |
}
|
240 |
}
|
241 |
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
|
258 |
function showShop() {
|
259 |
document.getElementById('shop').style.display = 'block';
|
|
|
190 |
}, 1000);
|
191 |
}
|
192 |
|
193 |
+
class Enemy {
|
194 |
+
constructor(isBoss = false) {
|
195 |
+
this.x = Math.random() * canvas.width;
|
196 |
+
this.y = Math.random() * canvas.height;
|
197 |
+
this.health = isBoss ? 20000 : 1000; // 보스 체력 4배로 증가
|
198 |
+
this.maxHealth = this.health;
|
199 |
+
this.speed = isBoss ? 1 : 2;
|
200 |
+
this.lastShot = 0;
|
201 |
+
this.shootInterval = isBoss ? 1000 : 1000;
|
202 |
+
this.angle = 0;
|
203 |
+
this.width = 100;
|
204 |
+
this.height = 45;
|
205 |
+
this.moveTimer = 0;
|
206 |
+
this.moveInterval = Math.random() * 2000 + 1000;
|
207 |
+
this.moveAngle = Math.random() * Math.PI * 2;
|
208 |
+
this.isBoss = isBoss;
|
209 |
+
}
|
210 |
+
}
|
211 |
|
212 |
if (isBoss) {
|
213 |
this.enemyImg = new Image();
|
|
|
241 |
}
|
242 |
}
|
243 |
|
244 |
+
shoot() {
|
245 |
+
const now = Date.now();
|
246 |
+
|
247 |
+
// 기관총을 특정 간격마다 섞어서 발사
|
248 |
+
if (this.isBoss && now % 3 === 0) { // 조건: 3초마다 기관총 공격
|
249 |
+
const sound = new Audio('firemg.ogg'); // 기관총 소리
|
250 |
+
sound.play();
|
251 |
+
|
252 |
+
// 기관총 탄환 5발 발사
|
253 |
+
for (let i = -2; i <= 2; i++) { // 총 5발: -2, -1, 0, 1, 2
|
254 |
+
const spreadAngle = this.angle + i * 0.1; // 각도 차이를 적용
|
255 |
+
bullets.push({
|
256 |
+
x: this.x + Math.cos(spreadAngle) * 30,
|
257 |
+
y: this.y + Math.sin(spreadAngle) * 30,
|
258 |
+
angle: spreadAngle,
|
259 |
+
speed: 8, // 기관총 탄환 속도
|
260 |
+
isEnemy: true,
|
261 |
+
size: 2, // 작은 크기의 탄환
|
262 |
+
damage: 50 // 기관총 탄환 피해량
|
263 |
+
});
|
264 |
}
|
265 |
+
} else {
|
266 |
+
// 기존의 기본 공격
|
267 |
+
const sound = this.isBoss ? new Audio('firemn.ogg') : enemyFireSound.cloneNode();
|
268 |
+
sound.play();
|
269 |
+
|
270 |
+
bullets.push({
|
271 |
+
x: this.x + Math.cos(this.angle) * 30,
|
272 |
+
y: this.y + Math.sin(this.angle) * 30,
|
273 |
+
angle: this.angle,
|
274 |
+
speed: 5,
|
275 |
+
isEnemy: true,
|
276 |
+
size: this.isBoss ? 5 : 3,
|
277 |
+
damage: this.isBoss ? 300 : 150 // 기본 공격 피해량
|
278 |
+
});
|
279 |
+
}
|
280 |
+
}
|
281 |
|
282 |
function showShop() {
|
283 |
document.getElementById('shop').style.display = 'block';
|