Update index.html
Browse files- index.html +9 -21
index.html
CHANGED
@@ -470,15 +470,11 @@ const defaultPlayerStats = {
|
|
470 |
}
|
471 |
|
472 |
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
return true; // ์ถฉ๋ ๋ฐ์
|
479 |
-
}
|
480 |
-
}
|
481 |
-
return false; // ์ถฉ๋ ์์
|
482 |
}
|
483 |
|
484 |
shoot() {
|
@@ -508,23 +504,21 @@ const defaultPlayerStats = {
|
|
508 |
});
|
509 |
}
|
510 |
|
511 |
-
|
512 |
const centerX = canvas.width / 2;
|
513 |
const centerY = canvas.height / 2;
|
514 |
this.angle = Math.atan2(centerY - this.y, centerX - this.x);
|
515 |
const dist = Math.hypot(centerX - this.x, centerY - this.y);
|
516 |
|
517 |
if (dist > 10) {
|
518 |
-
|
519 |
-
|
520 |
-
this.x += Math.cos(this.angle) * moveSpeed;
|
521 |
-
this.y += Math.sin(this.angle) * moveSpeed;
|
522 |
return false;
|
523 |
}
|
524 |
return true;
|
525 |
}
|
526 |
|
527 |
-
|
528 |
if (!this.hasPlayedSound) {
|
529 |
const sirenSound = new Audio('ju87siren.ogg');
|
530 |
sirenSound.volume = 1.0;
|
@@ -532,12 +526,6 @@ const defaultPlayerStats = {
|
|
532 |
this.hasPlayedSound = true;
|
533 |
}
|
534 |
|
535 |
-
// ์ถฉ๋ ๊ฐ์ง ๋จผ์ ์ํ
|
536 |
-
if (this.checkCollision()) {
|
537 |
-
this.returningToCenter = true;
|
538 |
-
this.target = null;
|
539 |
-
}
|
540 |
-
|
541 |
const timeSinceSpawn = Date.now() - this.spawnTime;
|
542 |
|
543 |
// ์๊ฐ ์ด๊ณผ์์๋ง ๊ทํ
|
|
|
470 |
}
|
471 |
|
472 |
|
473 |
+
checkCollision() {
|
474 |
+
if (!this.target) return false;
|
475 |
+
|
476 |
+
const dist = Math.hypot(this.target.x - this.x, this.target.y - this.y);
|
477 |
+
return dist < (this.width + this.target.width) / 2;
|
|
|
|
|
|
|
|
|
478 |
}
|
479 |
|
480 |
shoot() {
|
|
|
504 |
});
|
505 |
}
|
506 |
|
507 |
+
moveToCenter() {
|
508 |
const centerX = canvas.width / 2;
|
509 |
const centerY = canvas.height / 2;
|
510 |
this.angle = Math.atan2(centerY - this.y, centerX - this.x);
|
511 |
const dist = Math.hypot(centerX - this.x, centerY - this.y);
|
512 |
|
513 |
if (dist > 10) {
|
514 |
+
this.x += Math.cos(this.angle) * this.speed;
|
515 |
+
this.y += Math.sin(this.angle) * this.speed;
|
|
|
|
|
516 |
return false;
|
517 |
}
|
518 |
return true;
|
519 |
}
|
520 |
|
521 |
+
update() {
|
522 |
if (!this.hasPlayedSound) {
|
523 |
const sirenSound = new Audio('ju87siren.ogg');
|
524 |
sirenSound.volume = 1.0;
|
|
|
526 |
this.hasPlayedSound = true;
|
527 |
}
|
528 |
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
const timeSinceSpawn = Date.now() - this.spawnTime;
|
530 |
|
531 |
// ์๊ฐ ์ด๊ณผ์์๋ง ๊ทํ
|