Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -884,90 +884,90 @@ class Game {
|
|
| 884 |
0.3
|
| 885 |
);
|
| 886 |
this.scene.add(hemisphereLight);
|
| 887 |
-
// ์งํ ์์ฑ
|
| 888 |
-
const groundGeometry = new THREE.PlaneGeometry(MAP_SIZE, MAP_SIZE, 100, 100);
|
| 889 |
-
const groundMaterial = new THREE.MeshStandardMaterial({
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
});
|
| 895 |
-
|
| 896 |
-
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
|
| 897 |
-
ground.rotation.x = -Math.PI / 2;
|
| 898 |
-
ground.receiveShadow = true;
|
| 899 |
-
|
| 900 |
-
// ์งํ ๋์ด ์ค์
|
| 901 |
-
const vertices = ground.geometry.attributes.position.array;
|
| 902 |
-
for (let i = 0; i < vertices.length; i += 3) {
|
| 903 |
-
|
| 904 |
-
}
|
| 905 |
-
|
| 906 |
-
ground.geometry.attributes.position.needsUpdate = true;
|
| 907 |
-
ground.geometry.computeVertexNormals();
|
| 908 |
-
this.ground = ground;
|
| 909 |
-
this.scene.add(ground);
|
| 910 |
-
|
| 911 |
-
// ๊ฒฉ์ ํจ๊ณผ ์ถ๊ฐ
|
| 912 |
-
const gridHelper = new THREE.GridHelper(MAP_SIZE, 50, 0x000000, 0x000000);
|
| 913 |
-
gridHelper.material.opacity = 0.1;
|
| 914 |
-
gridHelper.material.transparent = true;
|
| 915 |
-
gridHelper.position.y = 0.1;
|
| 916 |
-
this.scene.add(gridHelper);
|
| 917 |
-
|
| 918 |
-
// ์ฌ๋ง ์ฅ์ ์ถ๊ฐ
|
| 919 |
-
await this.addDesertDecorations();
|
| 920 |
-
|
| 921 |
-
// ํฑํฌ ์ด๊ธฐํ
|
| 922 |
-
await this.tank.initialize(this.scene, this.loader);
|
| 923 |
-
if (!this.tank.isLoaded) {
|
| 924 |
-
|
| 925 |
-
}
|
| 926 |
-
|
| 927 |
-
// ์คํฐ ์์น ๊ฒ์ฆ
|
| 928 |
-
const spawnPos = this.findValidSpawnPosition();
|
| 929 |
-
const heightAtSpawn = this.getHeightAtPosition(spawnPos.x, spawnPos.z);
|
| 930 |
-
const slopeCheckPoints = [
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
|
| 934 |
-
|
| 935 |
-
];
|
| 936 |
-
|
| 937 |
-
const slopes = slopeCheckPoints.map(point => {
|
| 938 |
-
|
| 939 |
-
|
| 940 |
-
});
|
| 941 |
-
|
| 942 |
-
const maxSlope = Math.max(...slopes);
|
| 943 |
-
if (maxSlope > 0.3) {
|
| 944 |
-
|
| 945 |
-
|
| 946 |
-
}
|
| 947 |
-
|
| 948 |
-
// ์นด๋ฉ๋ผ ์ด๊ธฐ ์ค์
|
| 949 |
-
const tankPosition = this.tank.getPosition();
|
| 950 |
-
this.camera.position.set(
|
| 951 |
-
|
| 952 |
-
|
| 953 |
-
|
| 954 |
-
);
|
| 955 |
-
this.camera.lookAt(tankPosition);
|
| 956 |
-
|
| 957 |
-
// ๋ก๋ฉ ์๋ฃ ์ฒ๋ฆฌ
|
| 958 |
-
this.isLoading = false;
|
| 959 |
-
document.getElementById('loading').style.display = 'none';
|
| 960 |
-
|
| 961 |
-
// ๊ฒ์ ์์
|
| 962 |
-
this.animate();
|
| 963 |
-
this.spawnEnemies();
|
| 964 |
-
this.startGameTimer();
|
| 965 |
-
|
| 966 |
-
} catch (error) {
|
| 967 |
-
|
| 968 |
-
|
| 969 |
-
}
|
| 970 |
-
|
| 971 |
|
| 972 |
// ๋ ์ด๋ ์
๋ฐ์ดํธ ๋ฉ์๋ ์ถ๊ฐ
|
| 973 |
updateRadar() {
|
|
|
|
| 884 |
0.3
|
| 885 |
);
|
| 886 |
this.scene.add(hemisphereLight);
|
| 887 |
+
// ์งํ ์์ฑ
|
| 888 |
+
const groundGeometry = new THREE.PlaneGeometry(MAP_SIZE, MAP_SIZE, 100, 100);
|
| 889 |
+
const groundMaterial = new THREE.MeshStandardMaterial({
|
| 890 |
+
color: 0xD2B48C,
|
| 891 |
+
roughness: 0.8,
|
| 892 |
+
metalness: 0.2,
|
| 893 |
+
envMapIntensity: 1.0
|
| 894 |
+
});
|
| 895 |
+
|
| 896 |
+
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
|
| 897 |
+
ground.rotation.x = -Math.PI / 2;
|
| 898 |
+
ground.receiveShadow = true;
|
| 899 |
+
|
| 900 |
+
// ์งํ ๋์ด ์ค์
|
| 901 |
+
const vertices = ground.geometry.attributes.position.array;
|
| 902 |
+
for (let i = 0; i < vertices.length; i += 3) {
|
| 903 |
+
vertices[i + 2] = 0; // ๋ชจ๋ ๋์ด๋ฅผ 0์ผ๋ก ์ค์
|
| 904 |
+
}
|
| 905 |
+
|
| 906 |
+
ground.geometry.attributes.position.needsUpdate = true;
|
| 907 |
+
ground.geometry.computeVertexNormals();
|
| 908 |
+
this.ground = ground;
|
| 909 |
+
this.scene.add(ground);
|
| 910 |
+
|
| 911 |
+
// ๊ฒฉ์ ํจ๊ณผ ์ถ๊ฐ
|
| 912 |
+
const gridHelper = new THREE.GridHelper(MAP_SIZE, 50, 0x000000, 0x000000);
|
| 913 |
+
gridHelper.material.opacity = 0.1;
|
| 914 |
+
gridHelper.material.transparent = true;
|
| 915 |
+
gridHelper.position.y = 0.1;
|
| 916 |
+
this.scene.add(gridHelper);
|
| 917 |
+
|
| 918 |
+
// ์ฌ๋ง ์ฅ์ ์ถ๊ฐ
|
| 919 |
+
await this.addDesertDecorations();
|
| 920 |
+
|
| 921 |
+
// ํฑํฌ ์ด๊ธฐํ
|
| 922 |
+
await this.tank.initialize(this.scene, this.loader);
|
| 923 |
+
if (!this.tank.isLoaded) {
|
| 924 |
+
throw new Error('Tank loading failed');
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
// ์คํฐ ์์น ๊ฒ์ฆ
|
| 928 |
+
const spawnPos = this.findValidSpawnPosition();
|
| 929 |
+
const heightAtSpawn = this.getHeightAtPosition(spawnPos.x, spawnPos.z);
|
| 930 |
+
const slopeCheckPoints = [
|
| 931 |
+
{ x: spawnPos.x + 2, z: spawnPos.z },
|
| 932 |
+
{ x: spawnPos.x - 2, z: spawnPos.z },
|
| 933 |
+
{ x: spawnPos.x, z: spawnPos.z + 2 },
|
| 934 |
+
{ x: spawnPos.x, z: spawnPos.z - 2 }
|
| 935 |
+
];
|
| 936 |
+
|
| 937 |
+
const slopes = slopeCheckPoints.map(point => {
|
| 938 |
+
const pointHeight = this.getHeightAtPosition(point.x, point.z);
|
| 939 |
+
return Math.abs(pointHeight - heightAtSpawn) / 2;
|
| 940 |
+
});
|
| 941 |
+
|
| 942 |
+
const maxSlope = Math.max(...slopes);
|
| 943 |
+
if (maxSlope > 0.3) {
|
| 944 |
+
location.reload();
|
| 945 |
+
return;
|
| 946 |
+
}
|
| 947 |
+
|
| 948 |
+
// ์นด๋ฉ๋ผ ์ด๊ธฐ ์ค์
|
| 949 |
+
const tankPosition = this.tank.getPosition();
|
| 950 |
+
this.camera.position.set(
|
| 951 |
+
tankPosition.x,
|
| 952 |
+
tankPosition.y + 15,
|
| 953 |
+
tankPosition.z - 30
|
| 954 |
+
);
|
| 955 |
+
this.camera.lookAt(tankPosition);
|
| 956 |
+
|
| 957 |
+
// ๋ก๋ฉ ์๋ฃ ์ฒ๋ฆฌ
|
| 958 |
+
this.isLoading = false;
|
| 959 |
+
document.getElementById('loading').style.display = 'none';
|
| 960 |
+
|
| 961 |
+
// ๊ฒ์ ์์
|
| 962 |
+
this.animate();
|
| 963 |
+
this.spawnEnemies();
|
| 964 |
+
this.startGameTimer();
|
| 965 |
+
|
| 966 |
+
} catch (error) {
|
| 967 |
+
console.error('Game initialization error:', error);
|
| 968 |
+
this.handleLoadingError();
|
| 969 |
+
}
|
| 970 |
+
}
|
| 971 |
|
| 972 |
// ๋ ์ด๋ ์
๋ฐ์ดํธ ๋ฉ์๋ ์ถ๊ฐ
|
| 973 |
updateRadar() {
|