Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -1043,13 +1043,13 @@ class Game {
|
|
| 1043 |
// ๊ธฐ๋ณธ ์ฌ ์ค์
|
| 1044 |
this.setupScene();
|
| 1045 |
|
| 1046 |
-
// ์๊ฐ ํจ๊ณผ
|
| 1047 |
-
this.scene.fog = new THREE.FogExp2(
|
| 1048 |
-
this.scene.background = new THREE.Color(
|
| 1049 |
|
| 1050 |
// ์กฐ๋ช
์ค์
|
| 1051 |
// ์ฃผ๋ณ๊ด
|
| 1052 |
-
const ambientLight = new THREE.AmbientLight(0xffffff, 0.
|
| 1053 |
this.scene.add(ambientLight);
|
| 1054 |
|
| 1055 |
// ๋ฉ์ธ ํ์๊ด
|
|
@@ -1072,52 +1072,31 @@ class Game {
|
|
| 1072 |
|
| 1073 |
this.scene.add(mainLight);
|
| 1074 |
|
| 1075 |
-
// ๋ณด์กฐ
|
| 1076 |
-
const secondaryLight = new THREE.DirectionalLight(0xffffff, 0.
|
| 1077 |
secondaryLight.position.set(-50, 50, -50);
|
| 1078 |
this.scene.add(secondaryLight);
|
| 1079 |
|
| 1080 |
-
//
|
| 1081 |
-
|
| 1082 |
-
|
| 1083 |
-
|
| 1084 |
-
|
| 1085 |
-
|
| 1086 |
-
|
| 1087 |
-
|
| 1088 |
-
|
| 1089 |
-
|
| 1090 |
-
|
| 1091 |
-
|
| 1092 |
-
|
| 1093 |
-
|
| 1094 |
-
|
| 1095 |
-
|
| 1096 |
-
|
| 1097 |
-
|
| 1098 |
-
ground.receiveShadow = true;
|
| 1099 |
-
|
| 1100 |
-
// ์งํ ๋์ด ์ค์
|
| 1101 |
-
const vertices = ground.geometry.attributes.position.array;
|
| 1102 |
-
for (let i = 0; i < vertices.length; i += 3) {
|
| 1103 |
-
vertices[i + 2] = 0; // ๋ชจ๋ ๋์ด๋ฅผ 0์ผ๋ก ์ค์
|
| 1104 |
}
|
| 1105 |
-
|
| 1106 |
-
ground.geometry.attributes.position.needsUpdate = true;
|
| 1107 |
-
ground.geometry.computeVertexNormals();
|
| 1108 |
-
this.ground = ground;
|
| 1109 |
-
this.scene.add(ground);
|
| 1110 |
-
|
| 1111 |
-
// ๊ฒฉ์ ํจ๊ณผ ์ถ๊ฐ
|
| 1112 |
-
const gridHelper = new THREE.GridHelper(MAP_SIZE, 50, 0x000000, 0x000000);
|
| 1113 |
-
gridHelper.material.opacity = 0.1;
|
| 1114 |
-
gridHelper.material.transparent = true;
|
| 1115 |
-
gridHelper.position.y = 0.1;
|
| 1116 |
-
this.scene.add(gridHelper);
|
| 1117 |
-
|
| 1118 |
-
// ์ฌ๋ง ์ฅ์ ์ถ๊ฐ
|
| 1119 |
-
await this.addDesertDecorations();
|
| 1120 |
-
|
| 1121 |
// ํฑํฌ ์ด๊ธฐํ
|
| 1122 |
await this.tank.initialize(this.scene, this.loader);
|
| 1123 |
if (!this.tank.isLoaded) {
|
|
@@ -1163,11 +1142,11 @@ class Game {
|
|
| 1163 |
this.spawnEnemies();
|
| 1164 |
this.startGameTimer();
|
| 1165 |
|
| 1166 |
-
|
| 1167 |
-
|
| 1168 |
-
|
| 1169 |
-
|
| 1170 |
-
|
| 1171 |
|
| 1172 |
// ๋ ์ด๋ ์
๋ฐ์ดํธ ๋ฉ์๋ ์ถ๊ฐ
|
| 1173 |
updateRadar() {
|
|
|
|
| 1043 |
// ๊ธฐ๋ณธ ์ฌ ์ค์
|
| 1044 |
this.setupScene();
|
| 1045 |
|
| 1046 |
+
// ์๊ฐ ํจ๊ณผ (๋์ ํ๊ฒฝ์ ๋ง๊ฒ ์กฐ์ )
|
| 1047 |
+
this.scene.fog = new THREE.FogExp2(0x888888, 0.002);
|
| 1048 |
+
this.scene.background = new THREE.Color(0x888888);
|
| 1049 |
|
| 1050 |
// ์กฐ๋ช
์ค์
|
| 1051 |
// ์ฃผ๋ณ๊ด
|
| 1052 |
+
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6); // ๋์ ํ๊ฒฝ์ ์ํด ๋ฐ๊ธฐ ์ฆ๊ฐ
|
| 1053 |
this.scene.add(ambientLight);
|
| 1054 |
|
| 1055 |
// ๋ฉ์ธ ํ์๊ด
|
|
|
|
| 1072 |
|
| 1073 |
this.scene.add(mainLight);
|
| 1074 |
|
| 1075 |
+
// ๋ณด์กฐ ์กฐ๋ช
(๋์ ํ๊ฒฝ์ ๋ง๊ฒ ์กฐ์ )
|
| 1076 |
+
const secondaryLight = new THREE.DirectionalLight(0xffffff, 0.5);
|
| 1077 |
secondaryLight.position.set(-50, 50, -50);
|
| 1078 |
this.scene.add(secondaryLight);
|
| 1079 |
|
| 1080 |
+
// ๋์ ๋งต ๋ก๋
|
| 1081 |
+
try {
|
| 1082 |
+
const cityMap = await this.loader.loadAsync('/models/map.glb');
|
| 1083 |
+
cityMap.scene.traverse((child) => {
|
| 1084 |
+
if (child.isMesh) {
|
| 1085 |
+
child.castShadow = true;
|
| 1086 |
+
child.receiveShadow = true;
|
| 1087 |
+
child.material.needsUpdate = true;
|
| 1088 |
+
|
| 1089 |
+
// ์ถฉ๋ ์ฒ๋ฆฌ๋ฅผ ์ํด obstacles ๋ฐฐ์ด์ ์ถ๊ฐ
|
| 1090 |
+
if (child.geometry) {
|
| 1091 |
+
this.obstacles.push(child);
|
| 1092 |
+
}
|
| 1093 |
+
}
|
| 1094 |
+
});
|
| 1095 |
+
this.scene.add(cityMap.scene);
|
| 1096 |
+
} catch (error) {
|
| 1097 |
+
console.error('Error loading city map:', error);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1098 |
}
|
| 1099 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1100 |
// ํฑํฌ ์ด๊ธฐํ
|
| 1101 |
await this.tank.initialize(this.scene, this.loader);
|
| 1102 |
if (!this.tank.isLoaded) {
|
|
|
|
| 1142 |
this.spawnEnemies();
|
| 1143 |
this.startGameTimer();
|
| 1144 |
|
| 1145 |
+
} catch (error) {
|
| 1146 |
+
console.error('Game initialization error:', error);
|
| 1147 |
+
this.handleLoadingError();
|
| 1148 |
+
}
|
| 1149 |
+
}
|
| 1150 |
|
| 1151 |
// ๋ ์ด๋ ์
๋ฐ์ดํธ ๋ฉ์๋ ์ถ๊ฐ
|
| 1152 |
updateRadar() {
|