cutechicken
commited on
Update index.html
Browse files- index.html +16 -29
index.html
CHANGED
@@ -246,15 +246,15 @@
|
|
246 |
return Date.now() - this.startTime > this.duration;
|
247 |
}
|
248 |
}
|
249 |
-
|
250 |
constructor(yPosition) {
|
251 |
this.x = 0;
|
252 |
this.y = yPosition;
|
253 |
-
this.speed = 5;
|
254 |
this.lastShot = 0;
|
255 |
this.width = 100;
|
256 |
this.height = 100;
|
257 |
-
this.angle = 0;
|
258 |
this.img = new Image();
|
259 |
this.img.src = 'bf109.png';
|
260 |
}
|
@@ -265,27 +265,12 @@
|
|
265 |
|
266 |
// ๋ฐ์ฌ (1์ด์ 5๋ฐ)
|
267 |
const now = Date.now();
|
268 |
-
if (now - this.lastShot > 200) {
|
269 |
this.shoot();
|
270 |
this.lastShot = now;
|
271 |
}
|
272 |
|
273 |
-
|
274 |
-
let nearestEnemy = null;
|
275 |
-
let minDist = Infinity;
|
276 |
-
enemies.forEach(enemy => {
|
277 |
-
const dist = Math.hypot(enemy.x - this.x, enemy.y - this.y);
|
278 |
-
if (dist < minDist) {
|
279 |
-
minDist = dist;
|
280 |
-
nearestEnemy = enemy;
|
281 |
-
}
|
282 |
-
});
|
283 |
-
|
284 |
-
if (nearestEnemy) {
|
285 |
-
this.angle = Math.atan2(nearestEnemy.y - this.y, nearestEnemy.x - this.x);
|
286 |
-
}
|
287 |
-
|
288 |
-
return this.x < canvas.width; // ํ๋ฉด ๋ด์ ์์ผ๋ฉด true ๋ฐํ
|
289 |
}
|
290 |
|
291 |
shoot() {
|
@@ -422,16 +407,18 @@ function buyTank(tankImg, cost, tankId) {
|
|
422 |
document.getElementById('shop').style.display = 'none';
|
423 |
}
|
424 |
}
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
}
|
430 |
-
player.health = player.maxHealth;
|
431 |
-
bullets = [];
|
432 |
-
items = [];
|
433 |
-
startCountdown();
|
434 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
function startBossStage() {
|
436 |
isBossStage = true;
|
437 |
enemies = [];
|
|
|
246 |
return Date.now() - this.startTime > this.duration;
|
247 |
}
|
248 |
}
|
249 |
+
class SupportUnit {
|
250 |
constructor(yPosition) {
|
251 |
this.x = 0;
|
252 |
this.y = yPosition;
|
253 |
+
this.speed = 5;
|
254 |
this.lastShot = 0;
|
255 |
this.width = 100;
|
256 |
this.height = 100;
|
257 |
+
this.angle = 0; // ํญ์ ์ค๋ฅธ์ชฝ์ ํฅํจ
|
258 |
this.img = new Image();
|
259 |
this.img.src = 'bf109.png';
|
260 |
}
|
|
|
265 |
|
266 |
// ๋ฐ์ฌ (1์ด์ 5๋ฐ)
|
267 |
const now = Date.now();
|
268 |
+
if (now - this.lastShot > 200) {
|
269 |
this.shoot();
|
270 |
this.lastShot = now;
|
271 |
}
|
272 |
|
273 |
+
return this.x < canvas.width;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
}
|
275 |
|
276 |
shoot() {
|
|
|
407 |
document.getElementById('shop').style.display = 'none';
|
408 |
}
|
409 |
}
|
410 |
+
function initRound() {
|
411 |
+
enemies = [];
|
412 |
+
for(let i = 0; i < 1 * currentRound; i++) {
|
413 |
+
enemies.push(new Enemy());
|
|
|
|
|
|
|
|
|
|
|
414 |
}
|
415 |
+
player.health = player.maxHealth;
|
416 |
+
bullets = [];
|
417 |
+
items = [];
|
418 |
+
supportUnits = []; // ์ง์ ์ ๋ ์ด๊ธฐํ
|
419 |
+
lastSupportSpawn = 0; // ์คํฐ ํ์ด๋จธ ์ด๊ธฐํ
|
420 |
+
startCountdown();
|
421 |
+
}
|
422 |
function startBossStage() {
|
423 |
isBossStage = true;
|
424 |
enemies = [];
|