GuangyuanSD commited on
Commit
90a70e3
·
verified ·
1 Parent(s): 8909058

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +51 -10
index.html CHANGED
@@ -172,6 +172,16 @@
172
  animation: hitMarker 1s forwards;
173
  z-index: 4;
174
  }
 
 
 
 
 
 
 
 
 
 
175
 
176
  @keyframes hitMarker {
177
  0% { transform: scale(0.5); opacity: 0; }
@@ -750,16 +760,47 @@
750
  });
751
  }
752
 
753
- function handleCenterHit() {
754
- if (state.health > 0) {
755
- state.health--;
756
- updateHealth();
757
-
758
- if (state.health <= 0) {
759
- gameOver();
760
- }
761
- }
762
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
763
 
764
  function handleHit(target, projectile) {
765
  // Play hit sound
 
172
  animation: hitMarker 1s forwards;
173
  z-index: 4;
174
  }
175
+
176
+ .hit-flash {
177
+ animation: flash 0.3s;
178
+ }
179
+
180
+ @keyframes flash {
181
+ 0% { opacity: 1; }
182
+ 50% { opacity: 0.3; }
183
+ 100% { opacity: 1; }
184
+ }
185
 
186
  @keyframes hitMarker {
187
  0% { transform: scale(0.5); opacity: 0; }
 
760
  });
761
  }
762
 
763
+ // 修改handleCenterHit函数
764
+ function handleCenterHit() {
765
+ if (state.health > 0) {
766
+ state.health--;
767
+ updateHealth();
768
+
769
+ // 将所有目标弹出到画面边缘
770
+ state.targets.forEach(target => {
771
+ // 计算从中心到目标的向量
772
+ const centerX = window.innerWidth / 2;
773
+ const centerY = window.innerHeight / 2;
774
+ const targetCenterX = target.x + 125;
775
+ const targetCenterY = target.y + 125;
776
+
777
+ let dx = targetCenterX - centerX;
778
+ let dy = targetCenterY - centerY;
779
+
780
+ // 标准化向量并放大(弹出效果)
781
+ const distance = Math.sqrt(dx * dx + dy * dy);
782
+ dx /= distance;
783
+ dy /= distance;
784
+
785
+ // 设置很大的速度向边缘移动
786
+ target.vx = dx * 20; // 20是弹出速度,可以根据需要调整
787
+ target.vy = dy * 20;
788
+
789
+ // 添加闪烁效果
790
+ target.element.classList.add('hit-flash');
791
+ setTimeout(() => {
792
+ target.element.classList.remove('hit-flash');
793
+ }, 300);
794
+ });
795
+
796
+ if (state.health <= 0) {
797
+ // 延迟游戏结束,让玩家看到所有目标被弹出的效果
798
+ setTimeout(() => {
799
+ gameOver();
800
+ }, 500);
801
+ }
802
+ }
803
+ }
804
 
805
  function handleHit(target, projectile) {
806
  // Play hit sound