cutechicken commited on
Commit
37ab5ab
โ€ข
1 Parent(s): 7a85bf9

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +0 -78
game.js CHANGED
@@ -19,85 +19,7 @@ const ENEMY_CONFIG = {
19
  BULLET_SPEED: 2
20
  };
21
 
22
- // TankPlayer ํด๋ž˜์Šค ์ •์˜
23
- class TankPlayer {
24
- constructor() {
25
- this.body = null;
26
- this.turret = null;
27
- this.position = new THREE.Vector3(0, 0, 0);
28
- this.rotation = new THREE.Euler(0, 0, 0);
29
- this.turretRotation = 0;
30
- this.moveSpeed = 0.5;
31
- this.turnSpeed = 0.03;
32
- this.turretGroup = new THREE.Group(); // ํฌํƒ‘ ๊ทธ๋ฃน ์ถ”๊ฐ€
33
- }
34
-
35
- async initialize(scene, loader) {
36
- try {
37
- // ๋ชธ์ฒด ๋กœ๋“œ
38
- const bodyResult = await loader.loadAsync('/models/abramslow.glb');
39
- this.body = bodyResult.scene;
40
- this.body.position.copy(this.position);
41
-
42
- // ํฌํƒ‘ ๋กœ๋“œ
43
- const turretResult = await loader.loadAsync('/models/abramsTlow.glb');
44
- this.turret = turretResult.scene;
45
-
46
- // ํฌํƒ‘ ๊ทธ๋ฃน ์„ค์ •
47
- this.turretGroup.position.y = TANK_HEIGHT;
48
- this.turretGroup.add(this.turret);
49
- this.body.add(this.turretGroup);
50
-
51
- // ๊ทธ๋ฆผ์ž ์„ค์ •
52
- this.body.traverse((child) => {
53
- if (child.isMesh) {
54
- child.castShadow = true;
55
- child.receiveShadow = true;
56
- }
57
- });
58
-
59
- this.turret.traverse((child) => {
60
- if (child.isMesh) {
61
- child.castShadow = true;
62
- child.receiveShadow = true;
63
- }
64
- });
65
-
66
- scene.add(this.body);
67
-
68
- } catch (error) {
69
- console.error('Error loading tank models:', error);
70
- }
71
- }
72
-
73
- update(mouseX, mouseY) {
74
- if (!this.body || !this.turretGroup) return;
75
-
76
- // ๋งˆ์šฐ์Šค ์œ„์น˜๋ฅผ ์ด์šฉํ•œ ํฌํƒ‘ ํšŒ์ „ ๊ณ„์‚ฐ
77
- const targetAngle = Math.atan2(mouseX, mouseY);
78
-
79
- // ํฌํƒ‘ ๋ถ€๋“œ๋Ÿฌ์šด ํšŒ์ „
80
- const currentRotation = this.turretGroup.rotation.y;
81
- const rotationDiff = targetAngle - currentRotation;
82
- this.turretGroup.rotation.y += rotationDiff * 0.1;
83
- }
84
 
85
- move(direction) {
86
- if (!this.body) return;
87
-
88
- const moveVector = new THREE.Vector3();
89
- moveVector.x = direction.x * this.moveSpeed;
90
- moveVector.z = direction.z * this.moveSpeed;
91
-
92
- moveVector.applyEuler(this.body.rotation);
93
- this.body.position.add(moveVector);
94
- }
95
-
96
- rotate(angle) {
97
- if (!this.body) return;
98
- this.body.rotation.y += angle * this.turnSpeed;
99
- }
100
- }
101
  // TankPlayer ํด๋ž˜์Šค ์ˆ˜์ •
102
  class TankPlayer {
103
  constructor() {
 
19
  BULLET_SPEED: 2
20
  };
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  // TankPlayer ํด๋ž˜์Šค ์ˆ˜์ •
24
  class TankPlayer {
25
  constructor() {