cutechicken commited on
Commit
32e8615
Β·
verified Β·
1 Parent(s): c4e294f

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +252 -174
game.js CHANGED
@@ -658,8 +658,6 @@ class Fighter {
658
  const bulletGeometry = new THREE.CylinderGeometry(1.0, 1.0, 16, 8); // λ°˜μ§€λ¦„ 0.75β†’1.0, 길이 12β†’16
659
  const bulletMaterial = new THREE.MeshBasicMaterial({
660
  color: 0xffff00,
661
- emissive: 0xffff00,
662
- emissiveIntensity: 1.0
663
  });
664
  const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
665
 
@@ -1372,8 +1370,6 @@ class EnemyFighter {
1372
  const bulletGeometry = new THREE.CylinderGeometry(1.0, 1.0, 16, 8);
1373
  const bulletMaterial = new THREE.MeshBasicMaterial({
1374
  color: 0xff0000,
1375
- emissive: 0xff0000,
1376
- emissiveIntensity: 1.0
1377
  });
1378
  const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
1379
 
@@ -2331,8 +2327,6 @@ class Game {
2331
  const flashGeometry = new THREE.SphereGeometry(3, 8, 8);
2332
  const flashMaterial = new THREE.MeshBasicMaterial({
2333
  color: 0xffaa00,
2334
- emissive: 0xffaa00,
2335
- emissiveIntensity: 2.0,
2336
  transparent: true,
2337
  opacity: 0.8
2338
  });
@@ -2351,8 +2345,6 @@ class Game {
2351
  const particleGeometry = new THREE.SphereGeometry(0.3 + Math.random() * 0.3, 4, 4);
2352
  const particleMaterial = new THREE.MeshBasicMaterial({
2353
  color: Math.random() > 0.5 ? 0xffaa00 : 0xff6600,
2354
- emissive: 0xffaa00,
2355
- emissiveIntensity: 1.5,
2356
  transparent: true,
2357
  opacity: 1.0
2358
  });
@@ -2578,189 +2570,275 @@ class Game {
2578
  });
2579
  }
2580
 
2581
- // createExplosionEffect λ©”μ„œλ“œ κ°œμ„ 
2582
- createExplosionEffect(position) {
2583
- // μœ„μΉ˜ μœ νš¨μ„± 검사
2584
- if (!position || !position.x === undefined) {
2585
- console.error('Invalid position for explosion effect');
2586
- return;
2587
- }
2588
-
2589
- console.log('Creating explosion effect at position:', position);
2590
-
2591
- // ν­λ°œμŒμ„ κ°€μž₯ λ¨Όμ € μž¬μƒ (μ‹œκ°νš¨κ³Όλ³΄λ‹€ μš°μ„ )
2592
- try {
2593
- const explosionSound = new Audio('sounds/bang.ogg');
2594
- explosionSound.volume = 1.0; // μ΅œλŒ€ μŒλŸ‰
2595
 
2596
- // μ¦‰μ‹œ μž¬μƒ μ‹œλ„
2597
- const playPromise = explosionSound.play();
2598
- if (playPromise !== undefined) {
2599
- playPromise.then(() => {
2600
- console.log('Explosion sound played successfully');
2601
- }).catch(e => {
2602
- console.error('Explosion sound failed:', e);
2603
- // μ˜€λ””μ˜€ μ»¨ν…μŠ€νŠΈ 문제일 수 μžˆμœΌλ―€λ‘œ μ‚¬μš©μž μƒν˜Έμž‘μš© ν›„ μž¬μ‹œλ„
2604
- document.addEventListener('click', () => {
2605
- explosionSound.play().catch(err => console.error('Retry failed:', err));
2606
- }, { once: true });
2607
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2608
  }
2609
- } catch (e) {
2610
- console.error('Explosion sound error:', e);
2611
- }
2612
-
2613
- // 메인 폭발 ν”Œλž˜μ‹œ
2614
- const explosionGeometry = new THREE.SphereGeometry(50, 16, 16);
2615
- const explosionMaterial = new THREE.MeshBasicMaterial({
2616
- color: 0xffaa00,
2617
- emissive: 0xffaa00,
2618
- emissiveIntensity: 3.0,
2619
- transparent: true,
2620
- opacity: 1.0
2621
- });
2622
-
2623
- const explosion = new THREE.Mesh(explosionGeometry, explosionMaterial);
2624
- explosion.position.copy(position);
2625
- this.scene.add(explosion);
2626
-
2627
- // 폭발 νŒŒνŽΈλ“€
2628
- const debrisCount = 30;
2629
- const debris = [];
2630
-
2631
- for (let i = 0; i < debrisCount; i++) {
2632
- const debrisGeometry = new THREE.BoxGeometry(
2633
- 2 + Math.random() * 4,
2634
- 2 + Math.random() * 4,
2635
- 2 + Math.random() * 4
2636
- );
2637
- const debrisMaterial = new THREE.MeshBasicMaterial({
2638
- color: Math.random() > 0.5 ? 0xff6600 : 0x333333,
2639
  transparent: true,
2640
- opacity: 1.0
2641
  });
2642
 
2643
- const debrisPiece = new THREE.Mesh(debrisGeometry, debrisMaterial);
2644
- debrisPiece.position.copy(position);
 
2645
 
2646
- // 랜덀 속도와 νšŒμ „
2647
- debrisPiece.velocity = new THREE.Vector3(
2648
- (Math.random() - 0.5) * 200,
2649
- (Math.random() - 0.5) * 200,
2650
- (Math.random() - 0.5) * 200
2651
- );
2652
- debrisPiece.rotationSpeed = new THREE.Vector3(
2653
- Math.random() * 10,
2654
- Math.random() * 10,
2655
- Math.random() * 10
2656
- );
2657
- debrisPiece.life = 2.0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2658
 
2659
- this.scene.add(debrisPiece);
2660
- debris.push(debrisPiece);
 
 
 
 
 
 
 
 
 
 
2661
  }
2662
-
2663
- // μ—°κΈ° 효과
2664
- const smokeCount = 10;
2665
- const smoke = [];
2666
-
2667
- for (let i = 0; i < smokeCount; i++) {
2668
- const smokeGeometry = new THREE.SphereGeometry(10 + Math.random() * 20, 8, 8);
2669
- const smokeMaterial = new THREE.MeshBasicMaterial({
2670
- color: 0x222222,
2671
- transparent: true,
2672
- opacity: 0.8
2673
- });
2674
 
2675
- const smokePuff = new THREE.Mesh(smokeGeometry, smokeMaterial);
2676
- smokePuff.position.copy(position);
2677
- smokePuff.position.add(new THREE.Vector3(
2678
- (Math.random() - 0.5) * 20,
2679
- (Math.random() - 0.5) * 20,
2680
- (Math.random() - 0.5) * 20
2681
- ));
2682
-
2683
- smokePuff.velocity = new THREE.Vector3(
2684
- (Math.random() - 0.5) * 50,
2685
- Math.random() * 50 + 20,
2686
- (Math.random() - 0.5) * 50
2687
- );
2688
- smokePuff.life = 3.0;
2689
 
2690
- this.scene.add(smokePuff);
2691
- smoke.push(smokePuff);
2692
- }
2693
-
2694
- console.log('Explosion visual effects created');
2695
-
2696
- // μ• λ‹ˆλ©”μ΄μ…˜
2697
- const animateExplosion = () => {
2698
- let allDead = true;
2699
-
2700
- // 메인 폭발 μ• λ‹ˆλ©”μ΄μ…˜
2701
- if (explosion.material.opacity > 0) {
2702
- explosion.material.opacity -= 0.02;
2703
- explosion.scale.multiplyScalar(1.08);
2704
- allDead = false;
2705
- } else if (explosion.parent) {
2706
- this.scene.remove(explosion);
2707
- }
2708
-
2709
- // 파편 μ• λ‹ˆλ©”μ΄μ…˜
2710
- debris.forEach(piece => {
2711
- if (piece.life > 0) {
2712
- allDead = false;
2713
- piece.life -= 0.02;
2714
-
2715
- // μœ„μΉ˜ μ—…λ°μ΄νŠΈ
2716
- piece.position.add(piece.velocity.clone().multiplyScalar(0.02));
2717
-
2718
- // 쀑λ ₯
2719
- piece.velocity.y -= 3;
2720
-
2721
- // νšŒμ „
2722
- piece.rotation.x += piece.rotationSpeed.x * 0.02;
2723
- piece.rotation.y += piece.rotationSpeed.y * 0.02;
2724
- piece.rotation.z += piece.rotationSpeed.z * 0.02;
2725
-
2726
- // νŽ˜μ΄λ“œ 아웃
2727
- piece.material.opacity = piece.life / 2;
2728
- } else if (piece.parent) {
2729
- this.scene.remove(piece);
2730
  }
 
 
 
 
 
 
 
 
 
 
2731
  });
2732
 
2733
- // μ—°κΈ° μ• λ‹ˆλ©”μ΄μ…˜
2734
- smoke.forEach(puff => {
2735
- if (puff.life > 0) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2736
  allDead = false;
2737
- puff.life -= 0.02;
2738
-
2739
- // μœ„μΉ˜ μ—…λ°μ΄νŠΈ
2740
- puff.position.add(puff.velocity.clone().multiplyScalar(0.02));
2741
-
2742
- // μƒμŠΉ 감속
2743
- puff.velocity.y *= 0.98;
2744
- puff.velocity.x *= 0.98;
2745
- puff.velocity.z *= 0.98;
2746
-
2747
- // ν™•μ‚°
2748
- puff.scale.multiplyScalar(1.02);
2749
-
2750
- // νŽ˜μ΄λ“œ 아웃
2751
- puff.material.opacity = (puff.life / 3) * 0.8;
2752
- } else if (puff.parent) {
2753
- this.scene.remove(puff);
2754
  }
2755
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2756
 
2757
- if (!allDead) {
2758
- requestAnimationFrame(animateExplosion);
2759
- }
2760
- };
2761
-
2762
- animateExplosion();
2763
- }
2764
 
2765
  showHitMarker(position) {
2766
  // 히트 마컀 div 생성
 
658
  const bulletGeometry = new THREE.CylinderGeometry(1.0, 1.0, 16, 8); // λ°˜μ§€λ¦„ 0.75β†’1.0, 길이 12β†’16
659
  const bulletMaterial = new THREE.MeshBasicMaterial({
660
  color: 0xffff00,
 
 
661
  });
662
  const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
663
 
 
1370
  const bulletGeometry = new THREE.CylinderGeometry(1.0, 1.0, 16, 8);
1371
  const bulletMaterial = new THREE.MeshBasicMaterial({
1372
  color: 0xff0000,
 
 
1373
  });
1374
  const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
1375
 
 
2327
  const flashGeometry = new THREE.SphereGeometry(3, 8, 8);
2328
  const flashMaterial = new THREE.MeshBasicMaterial({
2329
  color: 0xffaa00,
 
 
2330
  transparent: true,
2331
  opacity: 0.8
2332
  });
 
2345
  const particleGeometry = new THREE.SphereGeometry(0.3 + Math.random() * 0.3, 4, 4);
2346
  const particleMaterial = new THREE.MeshBasicMaterial({
2347
  color: Math.random() > 0.5 ? 0xffaa00 : 0xff6600,
 
 
2348
  transparent: true,
2349
  opacity: 1.0
2350
  });
 
2570
  });
2571
  }
2572
 
2573
+ createHitEffect(position) {
2574
+ // 피격 νŒŒν‹°ν΄ 효과 생성
2575
+ const particleCount = 15;
2576
+ const particles = [];
 
 
 
 
 
 
 
 
 
 
2577
 
2578
+ for (let i = 0; i < particleCount; i++) {
2579
+ const particleGeometry = new THREE.SphereGeometry(0.5, 4, 4);
2580
+ const particleMaterial = new THREE.MeshBasicMaterial({
2581
+ color: Math.random() > 0.5 ? 0xffaa00 : 0xff6600,
2582
+ transparent: true,
2583
+ opacity: 1.0
 
 
 
 
 
2584
  });
2585
+
2586
+ const particle = new THREE.Mesh(particleGeometry, particleMaterial);
2587
+ particle.position.copy(position);
2588
+
2589
+ // 랜덀 속도 μ„€μ •
2590
+ particle.velocity = new THREE.Vector3(
2591
+ (Math.random() - 0.5) * 100,
2592
+ (Math.random() - 0.5) * 100,
2593
+ (Math.random() - 0.5) * 100
2594
+ );
2595
+
2596
+ particle.life = 1.0; // 1초 λ™μ•ˆ 지속
2597
+
2598
+ this.scene.add(particle);
2599
+ particles.push(particle);
2600
  }
2601
+
2602
+ // 쀑앙 폭발 ν”Œλž˜μ‹œ
2603
+ const flashGeometry = new THREE.SphereGeometry(5, 8, 8);
2604
+ const flashMaterial = new THREE.MeshBasicMaterial({
2605
+ color: 0xffff00,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2606
  transparent: true,
2607
+ opacity: 0.8
2608
  });
2609
 
2610
+ const flash = new THREE.Mesh(flashGeometry, flashMaterial);
2611
+ flash.position.copy(position);
2612
+ this.scene.add(flash);
2613
 
2614
+ // νŒŒν‹°ν΄ μ• λ‹ˆλ©”μ΄μ…˜
2615
+ const animateParticles = () => {
2616
+ let allDead = true;
2617
+
2618
+ particles.forEach(particle => {
2619
+ if (particle.life > 0) {
2620
+ allDead = false;
2621
+ particle.life -= 0.02;
2622
+
2623
+ // μœ„μΉ˜ μ—…λ°μ΄νŠΈ
2624
+ particle.position.add(particle.velocity.clone().multiplyScalar(0.02));
2625
+
2626
+ // 쀑λ ₯ 효과
2627
+ particle.velocity.y -= 2;
2628
+
2629
+ // νŽ˜μ΄λ“œ 아웃
2630
+ particle.material.opacity = particle.life;
2631
+
2632
+ // 크기 κ°μ†Œ
2633
+ const scale = particle.life;
2634
+ particle.scale.set(scale, scale, scale);
2635
+ } else if (particle.parent) {
2636
+ this.scene.remove(particle);
2637
+ }
2638
+ });
2639
+
2640
+ // ν”Œλž˜μ‹œ 효과
2641
+ if (flash.material.opacity > 0) {
2642
+ flash.material.opacity -= 0.05;
2643
+ flash.scale.multiplyScalar(1.1);
2644
+ } else if (flash.parent) {
2645
+ this.scene.remove(flash);
2646
+ }
2647
+
2648
+ if (!allDead || flash.material.opacity > 0) {
2649
+ requestAnimationFrame(animateParticles);
2650
+ }
2651
+ };
2652
 
2653
+ animateParticles();
2654
+
2655
+ // 피격 μ‚¬μš΄λ“œ μž¬μƒ
2656
+ try {
2657
+ const hitSound = new Audio('sounds/hit.ogg');
2658
+ hitSound.volume = 0.3;
2659
+ hitSound.play().catch(e => {
2660
+ console.log('Hit sound not found or failed to play');
2661
+ });
2662
+ } catch (e) {
2663
+ console.log('Hit sound error:', e);
2664
+ }
2665
  }
2666
+
2667
+ // 2. createExplosionEffect μˆ˜μ • - emissive 속성 제거
2668
+ createExplosionEffect(position) {
2669
+ // μœ„μΉ˜ μœ νš¨μ„± 검사
2670
+ if (!position || position.x === undefined) {
2671
+ console.error('Invalid position for explosion effect');
2672
+ return;
2673
+ }
 
 
 
 
2674
 
2675
+ console.log('Creating explosion effect at position:', position);
 
 
 
 
 
 
 
 
 
 
 
 
 
2676
 
2677
+ // ν­λ°œμŒμ„ κ°€μž₯ λ¨Όμ € μž¬μƒ (μ‹œκ°νš¨κ³Όλ³΄λ‹€ μš°μ„ )
2678
+ try {
2679
+ const explosionSound = new Audio('sounds/bang.ogg');
2680
+ explosionSound.volume = 1.0; // μ΅œλŒ€ μŒλŸ‰
2681
+
2682
+ // μ¦‰μ‹œ μž¬μƒ μ‹œλ„
2683
+ const playPromise = explosionSound.play();
2684
+ if (playPromise !== undefined) {
2685
+ playPromise.then(() => {
2686
+ console.log('Explosion sound played successfully');
2687
+ }).catch(e => {
2688
+ console.error('Explosion sound failed:', e);
2689
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2690
  }
2691
+ } catch (e) {
2692
+ console.error('Explosion sound error:', e);
2693
+ }
2694
+
2695
+ // 메인 폭발 ν”Œλž˜μ‹œ
2696
+ const explosionGeometry = new THREE.SphereGeometry(50, 16, 16);
2697
+ const explosionMaterial = new THREE.MeshBasicMaterial({
2698
+ color: 0xffaa00,
2699
+ transparent: true,
2700
+ opacity: 1.0
2701
  });
2702
 
2703
+ const explosion = new THREE.Mesh(explosionGeometry, explosionMaterial);
2704
+ explosion.position.copy(position);
2705
+ this.scene.add(explosion);
2706
+
2707
+ // 폭발 νŒŒνŽΈλ“€
2708
+ const debrisCount = 30;
2709
+ const debris = [];
2710
+
2711
+ for (let i = 0; i < debrisCount; i++) {
2712
+ const debrisGeometry = new THREE.BoxGeometry(
2713
+ 2 + Math.random() * 4,
2714
+ 2 + Math.random() * 4,
2715
+ 2 + Math.random() * 4
2716
+ );
2717
+ const debrisMaterial = new THREE.MeshBasicMaterial({
2718
+ color: Math.random() > 0.5 ? 0xff6600 : 0x333333,
2719
+ transparent: true,
2720
+ opacity: 1.0
2721
+ });
2722
+
2723
+ const debrisPiece = new THREE.Mesh(debrisGeometry, debrisMaterial);
2724
+ debrisPiece.position.copy(position);
2725
+
2726
+ // 랜덀 속도와 νšŒμ „
2727
+ debrisPiece.velocity = new THREE.Vector3(
2728
+ (Math.random() - 0.5) * 200,
2729
+ (Math.random() - 0.5) * 200,
2730
+ (Math.random() - 0.5) * 200
2731
+ );
2732
+ debrisPiece.rotationSpeed = new THREE.Vector3(
2733
+ Math.random() * 10,
2734
+ Math.random() * 10,
2735
+ Math.random() * 10
2736
+ );
2737
+ debrisPiece.life = 2.0;
2738
+
2739
+ this.scene.add(debrisPiece);
2740
+ debris.push(debrisPiece);
2741
+ }
2742
+
2743
+ // μ—°κΈ° 효과
2744
+ const smokeCount = 10;
2745
+ const smoke = [];
2746
+
2747
+ for (let i = 0; i < smokeCount; i++) {
2748
+ const smokeGeometry = new THREE.SphereGeometry(10 + Math.random() * 20, 8, 8);
2749
+ const smokeMaterial = new THREE.MeshBasicMaterial({
2750
+ color: 0x222222,
2751
+ transparent: true,
2752
+ opacity: 0.8
2753
+ });
2754
+
2755
+ const smokePuff = new THREE.Mesh(smokeGeometry, smokeMaterial);
2756
+ smokePuff.position.copy(position);
2757
+ smokePuff.position.add(new THREE.Vector3(
2758
+ (Math.random() - 0.5) * 20,
2759
+ (Math.random() - 0.5) * 20,
2760
+ (Math.random() - 0.5) * 20
2761
+ ));
2762
+
2763
+ smokePuff.velocity = new THREE.Vector3(
2764
+ (Math.random() - 0.5) * 50,
2765
+ Math.random() * 50 + 20,
2766
+ (Math.random() - 0.5) * 50
2767
+ );
2768
+ smokePuff.life = 3.0;
2769
+
2770
+ this.scene.add(smokePuff);
2771
+ smoke.push(smokePuff);
2772
+ }
2773
+
2774
+ // μ• λ‹ˆλ©”μ΄μ…˜
2775
+ const animateExplosion = () => {
2776
+ let allDead = true;
2777
+
2778
+ // 메인 폭발 μ• λ‹ˆλ©”μ΄μ…˜
2779
+ if (explosion.material.opacity > 0) {
2780
+ explosion.material.opacity -= 0.02;
2781
+ explosion.scale.multiplyScalar(1.08);
2782
  allDead = false;
2783
+ } else if (explosion.parent) {
2784
+ this.scene.remove(explosion);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2785
  }
2786
+
2787
+ // 파편 μ• λ‹ˆλ©”μ΄μ…˜
2788
+ debris.forEach(piece => {
2789
+ if (piece.life > 0) {
2790
+ allDead = false;
2791
+ piece.life -= 0.02;
2792
+
2793
+ // μœ„μΉ˜ μ—…λ°μ΄νŠΈ
2794
+ piece.position.add(piece.velocity.clone().multiplyScalar(0.02));
2795
+
2796
+ // 쀑λ ₯
2797
+ piece.velocity.y -= 3;
2798
+
2799
+ // νšŒμ „
2800
+ piece.rotation.x += piece.rotationSpeed.x * 0.02;
2801
+ piece.rotation.y += piece.rotationSpeed.y * 0.02;
2802
+ piece.rotation.z += piece.rotationSpeed.z * 0.02;
2803
+
2804
+ // νŽ˜μ΄λ“œ 아웃
2805
+ piece.material.opacity = piece.life / 2;
2806
+ } else if (piece.parent) {
2807
+ this.scene.remove(piece);
2808
+ }
2809
+ });
2810
+
2811
+ // μ—°κΈ° μ• λ‹ˆλ©”μ΄μ…˜
2812
+ smoke.forEach(puff => {
2813
+ if (puff.life > 0) {
2814
+ allDead = false;
2815
+ puff.life -= 0.02;
2816
+
2817
+ // μœ„μΉ˜ μ—…λ°μ΄νŠΈ
2818
+ puff.position.add(puff.velocity.clone().multiplyScalar(0.02));
2819
+
2820
+ // μƒμŠΉ 감속
2821
+ puff.velocity.y *= 0.98;
2822
+ puff.velocity.x *= 0.98;
2823
+ puff.velocity.z *= 0.98;
2824
+
2825
+ // ν™•μ‚°
2826
+ puff.scale.multiplyScalar(1.02);
2827
+
2828
+ // νŽ˜μ΄λ“œ 아웃
2829
+ puff.material.opacity = (puff.life / 3) * 0.8;
2830
+ } else if (puff.parent) {
2831
+ this.scene.remove(puff);
2832
+ }
2833
+ });
2834
+
2835
+ if (!allDead) {
2836
+ requestAnimationFrame(animateExplosion);
2837
+ }
2838
+ };
2839
 
2840
+ animateExplosion();
2841
+ }
 
 
 
 
 
2842
 
2843
  showHitMarker(position) {
2844
  // 히트 마컀 div 생성