Spaces:
Running
Running
cutechicken
commited on
Commit
โข
09bf3cb
1
Parent(s):
b9015a6
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 => {
|