Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
@@ -1728,7 +1728,24 @@ class Game {
|
|
1728 |
const beatSounds = ['sounds/beat1.ogg', 'sounds/beat2.ogg', 'sounds/beat3.ogg'];
|
1729 |
|
1730 |
const tankPosition = this.tank.getPosition();
|
|
|
1731 |
const tankBoundingBox = new THREE.Box3().setFromObject(this.tank.body);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1732 |
|
1733 |
// 탱크와 장애물 충돌 체크 (개선)
|
1734 |
this.obstacles.forEach(obstacle => {
|
|
|
1728 |
const beatSounds = ['sounds/beat1.ogg', 'sounds/beat2.ogg', 'sounds/beat3.ogg'];
|
1729 |
|
1730 |
const tankPosition = this.tank.getPosition();
|
1731 |
+
// 전체 탱크 모델에 대한 바운딩 박스 생성
|
1732 |
const tankBoundingBox = new THREE.Box3().setFromObject(this.tank.body);
|
1733 |
+
// 여유 공간을 주기 위해 바운딩 박스 확장
|
1734 |
+
tankBoundingBox.expandByScalar(1); // 모든 방향으로 1유닛 확장
|
1735 |
+
// 적 탱크들의 충돌 검사
|
1736 |
+
this.enemies.forEach(enemy => {
|
1737 |
+
if (!enemy.mesh || !enemy.isLoaded) return;
|
1738 |
+
|
1739 |
+
// 적 탱크의 전체 모델에 대한 바운딩 박스 생성
|
1740 |
+
const enemyBoundingBox = new THREE.Box3().setFromObject(enemy.mesh);
|
1741 |
+
enemyBoundingBox.expandByScalar(1); // 여유 공간
|
1742 |
+
|
1743 |
+
// 탱크와 적 탱크 간의 충돌 체크
|
1744 |
+
if (tankBoundingBox.intersectsBox(enemyBoundingBox)) {
|
1745 |
+
// 충돌 시 이전 위치로 복귀
|
1746 |
+
this.tank.body.position.copy(this.previousTankPosition);
|
1747 |
+
}
|
1748 |
+
});
|
1749 |
|
1750 |
// 탱크와 장애물 충돌 체크 (개선)
|
1751 |
this.obstacles.forEach(obstacle => {
|