Spaces:
Running
Running
cutechicken
commited on
Update index.html
Browse files- index.html +57 -97
index.html
CHANGED
@@ -197,107 +197,67 @@
|
|
197 |
countdownEl.textContent = countdownTime > 0 ? countdownTime : 'GO!';
|
198 |
}, 1000);
|
199 |
}
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
this.moveAngle = Math.random() * Math.PI * 2;
|
215 |
-
this.
|
216 |
-
this.weaponSwitchTimer = Date.now(); // 무기 전환 타이머
|
217 |
-
this.weaponType = 'cannon'; // 초기 무기 타입
|
218 |
-
|
219 |
-
if (isBoss) {
|
220 |
-
this.enemyImg = new Image();
|
221 |
-
this.enemyImg.src = 'boss.png';
|
222 |
-
} else if (currentRound >= 7) {
|
223 |
-
this.enemyImg = new Image();
|
224 |
-
this.enemyImg.src = 'enemy3.png';
|
225 |
-
} else if (currentRound >= 4) {
|
226 |
-
this.enemyImg = new Image();
|
227 |
-
this.enemyImg.src = 'enemy2.png';
|
228 |
-
}
|
229 |
-
}
|
230 |
-
|
231 |
-
update() {
|
232 |
-
if (isCountingDown) return;
|
233 |
-
const now = Date.now();
|
234 |
-
|
235 |
-
// 이동 관련 업데이트
|
236 |
-
if (now - this.moveTimer > this.moveInterval) {
|
237 |
-
this.moveAngle = Math.random() * Math.PI * 2;
|
238 |
-
this.moveTimer = now;
|
239 |
-
}
|
240 |
-
this.x += Math.cos(this.moveAngle) * this.speed;
|
241 |
-
this.y += Math.sin(this.moveAngle) * this.speed;
|
242 |
-
this.x = Math.max(this.width / 2, Math.min(canvas.width - this.width / 2, this.x));
|
243 |
-
this.y = Math.max(this.height / 2, Math.min(canvas.height - this.height / 2, this.y));
|
244 |
-
this.angle = Math.atan2(player.y - this.y, player.x - this.x);
|
245 |
-
|
246 |
-
// 무기 전환 논리 (3초마다)
|
247 |
-
if (this.isBoss && now - this.weaponSwitchTimer > 3000) {
|
248 |
-
this.weaponSwitchTimer = now;
|
249 |
-
this.weaponType = this.weaponType === 'cannon' ? 'machinegun' : 'cannon';
|
250 |
-
}
|
251 |
-
|
252 |
-
// 공격
|
253 |
-
if (now - this.lastShot > this.shootInterval && !isCountingDown) {
|
254 |
-
this.shoot();
|
255 |
-
this.lastShot = now;
|
256 |
-
}
|
257 |
-
}
|
258 |
-
|
259 |
-
shoot() {
|
260 |
-
if (this.weaponType === 'cannon') {
|
261 |
-
this.fireCannon();
|
262 |
-
} else if (this.weaponType === 'machinegun') {
|
263 |
-
this.fireMachineGun();
|
264 |
-
}
|
265 |
}
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
speed: this.isBoss ? 10 : 5, // 보스 탄환 속도 증가
|
276 |
-
isEnemy: true,
|
277 |
-
size: this.isBoss ? 5 : 3,
|
278 |
-
damage: this.isBoss ? 300 : 150 // 보스 데미지 강화
|
279 |
-
});
|
280 |
-
}
|
281 |
-
|
282 |
-
fireMachineGun() {
|
283 |
-
const sound = machinegunSound.cloneNode();
|
284 |
-
sound.play();
|
285 |
-
|
286 |
-
for (let i = -2; i <= 2; i++) {
|
287 |
-
const spreadAngle = this.angle + i * 0.1; // 탄환 퍼짐
|
288 |
-
bullets.push({
|
289 |
-
x: this.x + Math.cos(spreadAngle) * 30,
|
290 |
-
y: this.y + Math.sin(spreadAngle) * 30,
|
291 |
-
angle: spreadAngle,
|
292 |
-
speed: 10,
|
293 |
-
isEnemy: true,
|
294 |
-
size: 2,
|
295 |
-
damage: 50 // 머신건 낮은 데미지
|
296 |
-
});
|
297 |
-
}
|
298 |
}
|
299 |
}
|
300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
}
|
302 |
function showShop() {
|
303 |
document.getElementById('shop').style.display = 'block';
|
|
|
197 |
countdownEl.textContent = countdownTime > 0 ? countdownTime : 'GO!';
|
198 |
}, 1000);
|
199 |
}
|
200 |
+
class Enemy {
|
201 |
+
constructor(isBoss = false) {
|
202 |
+
this.x = Math.random() * canvas.width;
|
203 |
+
this.y = Math.random() * canvas.height;
|
204 |
+
this.health = isBoss ? 20000 : 1000;
|
205 |
+
this.maxHealth = this.health;
|
206 |
+
this.speed = isBoss ? 1 : 2;
|
207 |
+
this.lastShot = 0;
|
208 |
+
this.shootInterval = isBoss ? 1000 : 1000;
|
209 |
+
this.angle = 0;
|
210 |
+
this.width = 100;
|
211 |
+
this.height = 45;
|
212 |
+
this.moveTimer = 0;
|
213 |
+
this.moveInterval = Math.random() * 2000 + 1000;
|
214 |
+
this.moveAngle = Math.random() * Math.PI * 2;
|
215 |
+
this.isBoss = isBoss;
|
216 |
+
|
217 |
+
if (isBoss) {
|
218 |
+
this.enemyImg = new Image();
|
219 |
+
this.enemyImg.src = 'boss.png';
|
220 |
+
} else if (currentRound >= 7) {
|
221 |
+
this.enemyImg = new Image();
|
222 |
+
this.enemyImg.src = 'enemy3.png';
|
223 |
+
} else if (currentRound >= 4) {
|
224 |
+
this.enemyImg = new Image();
|
225 |
+
this.enemyImg.src = 'enemy2.png';
|
226 |
+
}
|
227 |
+
}
|
228 |
+
update() {
|
229 |
+
if(isCountingDown) return;
|
230 |
+
const now = Date.now();
|
231 |
+
|
232 |
+
if (now - this.moveTimer > this.moveInterval) {
|
233 |
this.moveAngle = Math.random() * Math.PI * 2;
|
234 |
+
this.moveTimer = now;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
}
|
236 |
+
this.x += Math.cos(this.moveAngle) * this.speed;
|
237 |
+
this.y += Math.sin(this.moveAngle) * this.speed;
|
238 |
+
this.x = Math.max(this.width/2, Math.min(canvas.width - this.width/2, this.x));
|
239 |
+
this.y = Math.max(this.height/2, Math.min(canvas.height - this.height/2, this.y));
|
240 |
+
this.angle = Math.atan2(player.y - this.y, player.x - this.x);
|
241 |
+
|
242 |
+
if (now - this.lastShot > this.shootInterval && !isCountingDown) {
|
243 |
+
this.shoot();
|
244 |
+
this.lastShot = now;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
}
|
246 |
}
|
247 |
+
shoot() {
|
248 |
+
const sound = this.isBoss ? new Audio('firemn.ogg') : enemyFireSound.cloneNode();
|
249 |
+
sound.play();
|
250 |
+
|
251 |
+
bullets.push({
|
252 |
+
x: this.x + Math.cos(this.angle) * 30,
|
253 |
+
y: this.y + Math.sin(this.angle) * 30,
|
254 |
+
angle: this.angle,
|
255 |
+
speed: 5,
|
256 |
+
isEnemy: true,
|
257 |
+
size: this.isBoss ? 5 : 3,
|
258 |
+
damage: this.isBoss ? 300 : 150 // 보스 200 -> 300, 일반 적 100 -> 150으로 강화
|
259 |
+
});
|
260 |
+
}
|
261 |
}
|
262 |
function showShop() {
|
263 |
document.getElementById('shop').style.display = 'block';
|