cutechicken commited on
Commit
3bf28e4
โ€ข
1 Parent(s): 2a3c664

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +84 -84
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
- 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() {
 
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() {