Update game.js
Browse files
game.js
CHANGED
|
@@ -38,6 +38,7 @@ class TankPlayer {
|
|
| 38 |
this.reloadTime = 3000; // ์ถ๊ฐ: 3์ด ์ฌ์ฅ์ ์๊ฐ
|
| 39 |
this.lastShootTime = 0;
|
| 40 |
this.bullets = [];
|
|
|
|
| 41 |
}
|
| 42 |
// ๋ณ๋์ ๋ฉ์๋๋ก ๋ถ๋ฆฌ
|
| 43 |
createExplosionEffect(scene, position) {
|
|
@@ -1011,48 +1012,53 @@ this.scene.add(ground);
|
|
| 1011 |
for (let i = 0; i < 100; i++) {
|
| 1012 |
const rockGeometry = rockGeometries[Math.floor(Math.random() * rockGeometries.length)];
|
| 1013 |
const rock = new THREE.Mesh(rockGeometry, rockMaterial);
|
| 1014 |
-
|
| 1015 |
-
|
| 1016 |
-
|
| 1017 |
-
|
| 1018 |
-
|
| 1019 |
-
|
| 1020 |
-
|
| 1021 |
-
|
| 1022 |
-
|
| 1023 |
-
|
| 1024 |
-
|
| 1025 |
-
|
| 1026 |
-
|
| 1027 |
-
|
| 1028 |
-
|
| 1029 |
-
|
| 1030 |
-
|
| 1031 |
-
|
| 1032 |
-
|
| 1033 |
-
|
| 1034 |
-
|
| 1035 |
-
|
|
|
|
|
|
|
| 1036 |
|
| 1037 |
-
|
| 1038 |
-
|
| 1039 |
-
|
| 1040 |
-
|
| 1041 |
-
|
| 1042 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1043 |
|
| 1044 |
-
for (let i = 0; i < 50; i++) {
|
| 1045 |
-
const cactus = new THREE.Mesh(cactusGeometry, cactusMaterial);
|
| 1046 |
-
cactus.position.set(
|
| 1047 |
-
(Math.random() - 0.5) * MAP_SIZE * 0.8,
|
| 1048 |
-
2,
|
| 1049 |
-
(Math.random() - 0.5) * MAP_SIZE * 0.8
|
| 1050 |
-
);
|
| 1051 |
-
cactus.castShadow = true;
|
| 1052 |
-
cactus.receiveShadow = true;
|
| 1053 |
-
this.scene.add(cactus);
|
| 1054 |
-
}
|
| 1055 |
-
}
|
| 1056 |
|
| 1057 |
getHeightAtPosition(x, z) {
|
| 1058 |
return 0; // ํญ์ ๋์ด 0 ๋ฐํ
|
|
@@ -1437,8 +1443,13 @@ this.scene.add(ground);
|
|
| 1437 |
|
| 1438 |
// ํผ๊ฒฉ ์ฌ์ด๋ ๋ฐฐ์ด ์ ์
|
| 1439 |
const beatSounds = ['sounds/beat1.ogg', 'sounds/beat2.ogg', 'sounds/beat3.ogg'];
|
| 1440 |
-
|
| 1441 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1442 |
// ์ ์ด์๊ณผ ํ๋ ์ด์ด ํฑํฌ ์ถฉ๋ ์ฒดํฌ
|
| 1443 |
this.enemies.forEach(enemy => {
|
| 1444 |
if (!enemy.mesh || !enemy.isLoaded) return;
|
|
|
|
| 38 |
this.reloadTime = 3000; // ์ถ๊ฐ: 3์ด ์ฌ์ฅ์ ์๊ฐ
|
| 39 |
this.lastShootTime = 0;
|
| 40 |
this.bullets = [];
|
| 41 |
+
this.obstacles = [];
|
| 42 |
}
|
| 43 |
// ๋ณ๋์ ๋ฉ์๋๋ก ๋ถ๋ฆฌ
|
| 44 |
createExplosionEffect(scene, position) {
|
|
|
|
| 1012 |
for (let i = 0; i < 100; i++) {
|
| 1013 |
const rockGeometry = rockGeometries[Math.floor(Math.random() * rockGeometries.length)];
|
| 1014 |
const rock = new THREE.Mesh(rockGeometry, rockMaterial);
|
| 1015 |
+
rock.position.set(
|
| 1016 |
+
(Math.random() - 0.5) * MAP_SIZE * 0.9,
|
| 1017 |
+
Math.random() * 2,
|
| 1018 |
+
(Math.random() - 0.5) * MAP_SIZE * 0.9
|
| 1019 |
+
);
|
| 1020 |
+
|
| 1021 |
+
rock.rotation.set(
|
| 1022 |
+
Math.random() * Math.PI,
|
| 1023 |
+
Math.random() * Math.PI,
|
| 1024 |
+
Math.random() * Math.PI
|
| 1025 |
+
);
|
| 1026 |
+
|
| 1027 |
+
rock.scale.set(
|
| 1028 |
+
1 + Math.random() * 0.5,
|
| 1029 |
+
1 + Math.random() * 0.5,
|
| 1030 |
+
1 + Math.random() * 0.5
|
| 1031 |
+
);
|
| 1032 |
+
|
| 1033 |
+
rock.castShadow = true;
|
| 1034 |
+
rock.receiveShadow = true;
|
| 1035 |
+
rock.userData.type = 'rock'; // ์ฅ์ ๋ฌผ ํ์
์ง์
|
| 1036 |
+
this.obstacles.push(rock);
|
| 1037 |
+
this.scene.add(rock);
|
| 1038 |
+
}
|
| 1039 |
|
| 1040 |
+
// ์ ์ธ์ฅ ์ถ๊ฐ
|
| 1041 |
+
const cactusGeometry = new THREE.CylinderGeometry(0.5, 0.7, 4, 8);
|
| 1042 |
+
const cactusMaterial = new THREE.MeshStandardMaterial({
|
| 1043 |
+
color: 0x2F4F2F,
|
| 1044 |
+
roughness: 0.8
|
| 1045 |
+
});
|
| 1046 |
+
|
| 1047 |
+
for (let i = 0; i < 50; i++) {
|
| 1048 |
+
const cactus = new THREE.Mesh(cactusGeometry, cactusMaterial);
|
| 1049 |
+
cactus.position.set(
|
| 1050 |
+
(Math.random() - 0.5) * MAP_SIZE * 0.8,
|
| 1051 |
+
2,
|
| 1052 |
+
(Math.random() - 0.5) * MAP_SIZE * 0.8
|
| 1053 |
+
);
|
| 1054 |
+
cactus.castShadow = true;
|
| 1055 |
+
cactus.receiveShadow = true;
|
| 1056 |
+
cactus.userData.type = 'cactus'; // ์ฅ์ ๋ฌผ ํ์
์ง์
|
| 1057 |
+
this.obstacles.push(cactus);
|
| 1058 |
+
this.scene.add(cactus);
|
| 1059 |
+
}
|
| 1060 |
+
}
|
| 1061 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1062 |
|
| 1063 |
getHeightAtPosition(x, z) {
|
| 1064 |
return 0; // ํญ์ ๋์ด 0 ๋ฐํ
|
|
|
|
| 1443 |
|
| 1444 |
// ํผ๊ฒฉ ์ฌ์ด๋ ๋ฐฐ์ด ์ ์
|
| 1445 |
const beatSounds = ['sounds/beat1.ogg', 'sounds/beat2.ogg', 'sounds/beat3.ogg'];
|
| 1446 |
+
// ํฑํฌ์ ์ฅ์ ๋ฌผ ์ถฉ๋ ์ฒดํฌ
|
| 1447 |
+
const tankBoundingBox = new THREE.Box3().setFromObject(this.tank.body);
|
| 1448 |
+
this.obstacles.forEach(obstacle => {
|
| 1449 |
+
const obstacleBoundingBox = new THREE.Box3().setFromObject(obstacle);
|
| 1450 |
+
if (tankBoundingBox.intersectsBox(obstacleBoundingBox)) {
|
| 1451 |
+
const tankPosition = this.tank.getPosition();
|
| 1452 |
+
//
|
| 1453 |
// ์ ์ด์๊ณผ ํ๋ ์ด์ด ํฑํฌ ์ถฉ๋ ์ฒดํฌ
|
| 1454 |
this.enemies.forEach(enemy => {
|
| 1455 |
if (!enemy.mesh || !enemy.isLoaded) return;
|