Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -125,7 +125,7 @@ class TankPlayer {
|
|
| 125 |
expandRing();
|
| 126 |
|
| 127 |
// ํญ๋ฐ์ ํจ๊ณผ
|
| 128 |
-
const explosionSound = new Audio('sounds/
|
| 129 |
explosionSound.volume = 0.4;
|
| 130 |
explosionSound.play();
|
| 131 |
|
|
@@ -633,6 +633,163 @@ class Enemy {
|
|
| 633 |
maxConsecutiveHits: 3
|
| 634 |
};
|
| 635 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 636 |
|
| 637 |
// ์ฅ์ ๋ฌผ ๊ฐ์ง ์์คํ
|
| 638 |
detectObstacles() {
|
|
@@ -2260,6 +2417,7 @@ this.enemies.forEach(enemy => {
|
|
| 2260 |
hitAudio.play();
|
| 2261 |
|
| 2262 |
if (enemy.takeDamage(50)) {
|
|
|
|
| 2263 |
enemy.destroy();
|
| 2264 |
this.enemies.splice(j, 1);
|
| 2265 |
this.score += 100;
|
|
|
|
| 125 |
expandRing();
|
| 126 |
|
| 127 |
// ํญ๋ฐ์ ํจ๊ณผ
|
| 128 |
+
const explosionSound = new Audio('sounds/bang.ogg');
|
| 129 |
explosionSound.volume = 0.4;
|
| 130 |
explosionSound.play();
|
| 131 |
|
|
|
|
| 633 |
maxConsecutiveHits: 3
|
| 634 |
};
|
| 635 |
}
|
| 636 |
+
createMassiveExplosion() {
|
| 637 |
+
// ์ค์ฌ ํญ๋ฐ
|
| 638 |
+
const explosionGroup = new THREE.Group();
|
| 639 |
+
|
| 640 |
+
// ์ฃผ ํญ๋ฐ ํ๋์
|
| 641 |
+
const flashGeometry = new THREE.SphereGeometry(8);
|
| 642 |
+
const flashMaterial = new THREE.MeshBasicMaterial({
|
| 643 |
+
color: 0xffff00,
|
| 644 |
+
transparent: true,
|
| 645 |
+
opacity: 1
|
| 646 |
+
});
|
| 647 |
+
const flash = new THREE.Mesh(flashGeometry, flashMaterial);
|
| 648 |
+
flash.position.copy(this.mesh.position);
|
| 649 |
+
this.scene.add(flash);
|
| 650 |
+
|
| 651 |
+
// ๋ค์ค ํญ๋ฐ ํํฐํด
|
| 652 |
+
for (let i = 0; i < 100; i++) { // ํํฐํด ์ ์ฆ๊ฐ
|
| 653 |
+
const size = Math.random() * 2 + 1;
|
| 654 |
+
const geometry = new THREE.SphereGeometry(size);
|
| 655 |
+
|
| 656 |
+
// ๋ค์ํ ํญ๋ฐ ์์
|
| 657 |
+
const colors = [0xff4500, 0xff8c00, 0xff0000, 0xffd700, 0xff6347];
|
| 658 |
+
const material = new THREE.MeshBasicMaterial({
|
| 659 |
+
color: colors[Math.floor(Math.random() * colors.length)],
|
| 660 |
+
transparent: true,
|
| 661 |
+
opacity: 1
|
| 662 |
+
});
|
| 663 |
+
|
| 664 |
+
const particle = new THREE.Mesh(geometry, material);
|
| 665 |
+
particle.position.copy(this.mesh.position);
|
| 666 |
+
|
| 667 |
+
// ๋ ๊ฐ๋ ฅํ ํญ๋ฐ ํจ๊ณผ๋ฅผ ์ํ ์๋ ์ฆ๊ฐ
|
| 668 |
+
const speed = Math.random() * 2 + 1;
|
| 669 |
+
const angle = Math.random() * Math.PI * 2;
|
| 670 |
+
const elevation = Math.random() * Math.PI - Math.PI / 2;
|
| 671 |
+
|
| 672 |
+
particle.velocity = new THREE.Vector3(
|
| 673 |
+
Math.cos(angle) * Math.cos(elevation) * speed,
|
| 674 |
+
Math.sin(elevation) * speed,
|
| 675 |
+
Math.sin(angle) * Math.cos(elevation) * speed
|
| 676 |
+
);
|
| 677 |
+
|
| 678 |
+
particle.gravity = -0.1;
|
| 679 |
+
particle.life = Math.random() * 60 + 60;
|
| 680 |
+
particle.fadeRate = 0.98;
|
| 681 |
+
|
| 682 |
+
this.scene.add(particle);
|
| 683 |
+
window.gameInstance.particles.push({
|
| 684 |
+
mesh: particle,
|
| 685 |
+
velocity: particle.velocity,
|
| 686 |
+
gravity: particle.gravity,
|
| 687 |
+
life: particle.life,
|
| 688 |
+
fadeRate: particle.fadeRate
|
| 689 |
+
});
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
// ํญ๋ฐ ๋ง ์ดํํธ
|
| 693 |
+
for (let i = 0; i < 3; i++) {
|
| 694 |
+
const ringGeometry = new THREE.RingGeometry(0.1, 4, 32);
|
| 695 |
+
const ringMaterial = new THREE.MeshBasicMaterial({
|
| 696 |
+
color: 0xff8c00,
|
| 697 |
+
transparent: true,
|
| 698 |
+
opacity: 1,
|
| 699 |
+
side: THREE.DoubleSide
|
| 700 |
+
});
|
| 701 |
+
const ring = new THREE.Mesh(ringGeometry, ringMaterial);
|
| 702 |
+
ring.position.copy(this.mesh.position);
|
| 703 |
+
ring.rotation.x = Math.random() * Math.PI;
|
| 704 |
+
ring.rotation.y = Math.random() * Math.PI;
|
| 705 |
+
this.scene.add(ring);
|
| 706 |
+
|
| 707 |
+
// ๋ง ํ์ฅ ์ ๋๋ฉ์ด์
|
| 708 |
+
const expandRing = () => {
|
| 709 |
+
ring.scale.x += 0.3;
|
| 710 |
+
ring.scale.y += 0.3;
|
| 711 |
+
ring.material.opacity *= 0.96;
|
| 712 |
+
|
| 713 |
+
if (ring.material.opacity > 0.01) {
|
| 714 |
+
requestAnimationFrame(expandRing);
|
| 715 |
+
} else {
|
| 716 |
+
this.scene.remove(ring);
|
| 717 |
+
}
|
| 718 |
+
};
|
| 719 |
+
expandRing();
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
// ํ์ผ ๊ธฐ๋ฅ ํจ๊ณผ
|
| 723 |
+
const fireColumn = new THREE.Group();
|
| 724 |
+
for (let i = 0; i < 20; i++) {
|
| 725 |
+
const fireGeometry = new THREE.ConeGeometry(2, 8, 8);
|
| 726 |
+
const fireMaterial = new THREE.MeshBasicMaterial({
|
| 727 |
+
color: 0xff4500,
|
| 728 |
+
transparent: true,
|
| 729 |
+
opacity: 0.8
|
| 730 |
+
});
|
| 731 |
+
const fire = new THREE.Mesh(fireGeometry, fireMaterial);
|
| 732 |
+
fire.position.y = i * 0.5;
|
| 733 |
+
fire.rotation.x = Math.random() * Math.PI;
|
| 734 |
+
fire.rotation.z = Math.random() * Math.PI;
|
| 735 |
+
fireColumn.add(fire);
|
| 736 |
+
}
|
| 737 |
+
fireColumn.position.copy(this.mesh.position);
|
| 738 |
+
this.scene.add(fireColumn);
|
| 739 |
+
|
| 740 |
+
// ํ์ผ ๊ธฐ๋ฅ ์ ๋๋ฉ์ด์
|
| 741 |
+
const animateFireColumn = () => {
|
| 742 |
+
fireColumn.scale.y += 0.1;
|
| 743 |
+
fireColumn.children.forEach(fire => {
|
| 744 |
+
fire.material.opacity *= 0.95;
|
| 745 |
+
});
|
| 746 |
+
|
| 747 |
+
if (fireColumn.children[0].material.opacity > 0.01) {
|
| 748 |
+
requestAnimationFrame(animateFireColumn);
|
| 749 |
+
} else {
|
| 750 |
+
this.scene.remove(fireColumn);
|
| 751 |
+
}
|
| 752 |
+
};
|
| 753 |
+
animateFireColumn();
|
| 754 |
+
|
| 755 |
+
// ํญ๋ฐ ์ฌ์ด๋ ํจ๊ณผ๋ค
|
| 756 |
+
const explosionSounds = [
|
| 757 |
+
new Audio('sounds/explosion.ogg'),
|
| 758 |
+
new Audio('sounds/bang.ogg')
|
| 759 |
+
];
|
| 760 |
+
explosionSounds.forEach(sound => {
|
| 761 |
+
sound.volume = 0.5;
|
| 762 |
+
sound.play();
|
| 763 |
+
});
|
| 764 |
+
|
| 765 |
+
// ์นด๋ฉ๋ผ ํ๋ค๋ฆผ ํจ๊ณผ
|
| 766 |
+
if (window.gameInstance && window.gameInstance.camera) {
|
| 767 |
+
const camera = window.gameInstance.camera;
|
| 768 |
+
const originalPosition = camera.position.clone();
|
| 769 |
+
let shakeTime = 0;
|
| 770 |
+
const shakeIntensity = 1.0;
|
| 771 |
+
const shakeDuration = 1000;
|
| 772 |
+
|
| 773 |
+
const shakeCamera = () => {
|
| 774 |
+
if (shakeTime < shakeDuration) {
|
| 775 |
+
camera.position.x = originalPosition.x + (Math.random() - 0.5) * shakeIntensity;
|
| 776 |
+
camera.position.y = originalPosition.y + (Math.random() - 0.5) * shakeIntensity;
|
| 777 |
+
camera.position.z = originalPosition.z + (Math.random() - 0.5) * shakeIntensity;
|
| 778 |
+
|
| 779 |
+
shakeTime += 16;
|
| 780 |
+
requestAnimationFrame(shakeCamera);
|
| 781 |
+
} else {
|
| 782 |
+
camera.position.copy(originalPosition);
|
| 783 |
+
}
|
| 784 |
+
};
|
| 785 |
+
shakeCamera();
|
| 786 |
+
}
|
| 787 |
+
|
| 788 |
+
// ์ค์ฌ ํ๋์ ์ ๊ฑฐ
|
| 789 |
+
setTimeout(() => {
|
| 790 |
+
this.scene.remove(flash);
|
| 791 |
+
}, 200);
|
| 792 |
+
}
|
| 793 |
|
| 794 |
// ์ฅ์ ๋ฌผ ๊ฐ์ง ์์คํ
|
| 795 |
detectObstacles() {
|
|
|
|
| 2417 |
hitAudio.play();
|
| 2418 |
|
| 2419 |
if (enemy.takeDamage(50)) {
|
| 2420 |
+
enemy.createMassiveExplosion(); // ์ถ๊ฐ
|
| 2421 |
enemy.destroy();
|
| 2422 |
this.enemies.splice(j, 1);
|
| 2423 |
this.score += 100;
|