Spaces:
Running
Running
cutechicken
commited on
Commit
β’
3c42859
1
Parent(s):
a6cfeb9
Update game.js
Browse files
game.js
CHANGED
@@ -12,7 +12,7 @@ const MAX_HEALTH = 1000;
|
|
12 |
const ENEMY_MOVE_SPEED = 0.1;
|
13 |
const ENEMY_COUNT_MAX = 3;
|
14 |
const PARTICLE_COUNT = 15;
|
15 |
-
const BUILDING_COUNT =
|
16 |
const ENEMY_CONFIG = {
|
17 |
ATTACK_RANGE: 100,
|
18 |
ATTACK_INTERVAL: 2000,
|
@@ -590,7 +590,6 @@ class Enemy {
|
|
590 |
this.lastPathUpdateTime = 0;
|
591 |
this.pathUpdateInterval = 3000; // 3μ΄λ§λ€ κ²½λ‘ μ
λ°μ΄νΈ
|
592 |
this.moveSpeed = type === 'tank' ? ENEMY_MOVE_SPEED : ENEMY_MOVE_SPEED * 0.7;
|
593 |
-
this.hasPlayedWarning = false; // κ²½κ³ μ μ¬μ μ¬λΆ μΆμ
|
594 |
|
595 |
// AI μν κ΄λ¦¬
|
596 |
this.aiState = {
|
@@ -740,15 +739,6 @@ class Enemy {
|
|
740 |
update(playerPosition) {
|
741 |
if (!this.mesh || !this.isLoaded) return;
|
742 |
|
743 |
-
// νλ μ΄μ΄μμ 거리 μ²΄ν¬ λ° κ²½κ³ μ μ¬μ
|
744 |
-
const distanceToPlayer = this.mesh.position.distanceTo(playerPosition);
|
745 |
-
if (!this.hasPlayedWarning && distanceToPlayer <= ENEMY_CONFIG.ATTACK_RANGE) {
|
746 |
-
const warningSound = new Audio('sounds/warning.ogg');
|
747 |
-
warningSound.volume = 0.5;
|
748 |
-
warningSound.play();
|
749 |
-
this.hasPlayedWarning = true;
|
750 |
-
}
|
751 |
-
|
752 |
// AI μν μ
λ°μ΄νΈ
|
753 |
this.updateAIState(playerPosition);
|
754 |
|
@@ -1773,7 +1763,7 @@ class Game {
|
|
1773 |
this.obstacles = [];
|
1774 |
}
|
1775 |
|
1776 |
-
const BUILDING_COUNT =
|
1777 |
const buildingModels = [
|
1778 |
'models/house1.glb',
|
1779 |
'models/house2.glb',
|
@@ -2549,9 +2539,6 @@ updateCrosshair() {
|
|
2549 |
const raycasterDirection = new THREE.Vector2();
|
2550 |
this.raycaster.setFromCamera(raycasterDirection, this.camera);
|
2551 |
|
2552 |
-
// detected μμ κ°μ Έμ€κΈ°
|
2553 |
-
const detectedText = document.getElementById('detected');
|
2554 |
-
|
2555 |
// μ μ μ°¨μ λ°μ΄λ© λ°μ€λ ν¬ν¨νμ¬ κ²μ¬
|
2556 |
const detectEnemy = this.enemies.some(enemy => {
|
2557 |
if (!enemy.mesh || !enemy.isLoaded) return false;
|
@@ -2559,20 +2546,15 @@ updateCrosshair() {
|
|
2559 |
// μ μ μ°¨μ λ°μ΄λ© λ°μ€ μμ±
|
2560 |
const boundingBox = new THREE.Box3().setFromObject(enemy.mesh);
|
2561 |
const intersects = this.raycaster.ray.intersectsBox(boundingBox);
|
2562 |
-
|
2563 |
-
// 곡격 λ²μ λ΄μ μλμ§ νμΈ
|
2564 |
-
const inRange = enemy.mesh.position.distanceTo(this.tank.getPosition()) <= ENEMY_CONFIG.ATTACK_RANGE;
|
2565 |
|
2566 |
-
// λ°μ΄λ© λ°μ€μμ κ΅μ°¨
|
2567 |
-
return intersects
|
2568 |
});
|
2569 |
|
2570 |
if (detectEnemy) {
|
2571 |
this.crosshair.classList.add('target-detected');
|
2572 |
-
detectedText.style.display = 'block'; // DETECTED ν
μ€νΈ νμ
|
2573 |
} else {
|
2574 |
this.crosshair.classList.remove('target-detected');
|
2575 |
-
detectedText.style.display = 'none'; // DETECTED ν
μ€νΈ μ¨κΈ°κΈ°
|
2576 |
}
|
2577 |
}
|
2578 |
updateEnemyLabels() {
|
|
|
12 |
const ENEMY_MOVE_SPEED = 0.1;
|
13 |
const ENEMY_COUNT_MAX = 3;
|
14 |
const PARTICLE_COUNT = 15;
|
15 |
+
const BUILDING_COUNT = 50;
|
16 |
const ENEMY_CONFIG = {
|
17 |
ATTACK_RANGE: 100,
|
18 |
ATTACK_INTERVAL: 2000,
|
|
|
590 |
this.lastPathUpdateTime = 0;
|
591 |
this.pathUpdateInterval = 3000; // 3μ΄λ§λ€ κ²½λ‘ μ
λ°μ΄νΈ
|
592 |
this.moveSpeed = type === 'tank' ? ENEMY_MOVE_SPEED : ENEMY_MOVE_SPEED * 0.7;
|
|
|
593 |
|
594 |
// AI μν κ΄λ¦¬
|
595 |
this.aiState = {
|
|
|
739 |
update(playerPosition) {
|
740 |
if (!this.mesh || !this.isLoaded) return;
|
741 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
742 |
// AI μν μ
λ°μ΄νΈ
|
743 |
this.updateAIState(playerPosition);
|
744 |
|
|
|
1763 |
this.obstacles = [];
|
1764 |
}
|
1765 |
|
1766 |
+
const BUILDING_COUNT = 50;
|
1767 |
const buildingModels = [
|
1768 |
'models/house1.glb',
|
1769 |
'models/house2.glb',
|
|
|
2539 |
const raycasterDirection = new THREE.Vector2();
|
2540 |
this.raycaster.setFromCamera(raycasterDirection, this.camera);
|
2541 |
|
|
|
|
|
|
|
2542 |
// μ μ μ°¨μ λ°μ΄λ© λ°μ€λ ν¬ν¨νμ¬ κ²μ¬
|
2543 |
const detectEnemy = this.enemies.some(enemy => {
|
2544 |
if (!enemy.mesh || !enemy.isLoaded) return false;
|
|
|
2546 |
// μ μ μ°¨μ λ°μ΄λ© λ°μ€ μμ±
|
2547 |
const boundingBox = new THREE.Box3().setFromObject(enemy.mesh);
|
2548 |
const intersects = this.raycaster.ray.intersectsBox(boundingBox);
|
|
|
|
|
|
|
2549 |
|
2550 |
+
// λ°μ΄λ© λ°μ€μμ κ΅μ°¨ μ¬λΆλ‘ νλ¨
|
2551 |
+
return intersects;
|
2552 |
});
|
2553 |
|
2554 |
if (detectEnemy) {
|
2555 |
this.crosshair.classList.add('target-detected');
|
|
|
2556 |
} else {
|
2557 |
this.crosshair.classList.remove('target-detected');
|
|
|
2558 |
}
|
2559 |
}
|
2560 |
updateEnemyLabels() {
|