quake2ts 0.0.442 → 0.0.444

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quake2ts",
3
- "version": "0.0.442",
3
+ "version": "0.0.444",
4
4
  "description": "Quake II re-release port to TypeScript with WebGL renderer - A complete game engine with physics, networking, and BSP rendering",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -95,8 +95,6 @@ var Init_Icons = (cgi3) => {
95
95
  }
96
96
  }
97
97
  };
98
-
99
- // src/hud/damage.ts
100
98
  var damagePics = /* @__PURE__ */ new Map();
101
99
  var DAMAGE_INDICATOR_NAMES = [
102
100
  "d_left",
@@ -115,10 +113,47 @@ var Init_Damage = (cgi3) => {
115
113
  }
116
114
  }
117
115
  };
116
+ var WHITE = { x: 1, y: 1, z: 1 };
118
117
  var Draw_Damage = (cgi3, ps, width, height) => {
119
118
  if ((!ps.damageAlpha || ps.damageAlpha <= 0) && (!ps.damageIndicators || ps.damageIndicators.length === 0)) {
120
119
  return;
121
120
  }
121
+ if (!ps.damageIndicators || ps.damageIndicators.length === 0) {
122
+ return;
123
+ }
124
+ const cx = width * 0.5;
125
+ const cy = height * 0.5;
126
+ const { forward, right } = shared.angleVectors(ps.viewAngles);
127
+ const radius = Math.min(width, height) * 0.25;
128
+ for (const indicator of ps.damageIndicators) {
129
+ const localRight = shared.dotVec3(indicator.direction, right);
130
+ const localForward = shared.dotVec3(indicator.direction, forward);
131
+ const angle2 = Math.atan2(localForward, localRight) * (180 / Math.PI);
132
+ let picName = "";
133
+ let xOff = 0;
134
+ let yOff = 0;
135
+ if (angle2 >= 45 && angle2 < 135) {
136
+ picName = "d_up";
137
+ yOff = -radius;
138
+ } else if (angle2 >= -45 && angle2 < 45) {
139
+ picName = "d_right";
140
+ xOff = radius;
141
+ } else if (angle2 >= -135 && angle2 < -45) {
142
+ picName = "d_down";
143
+ yOff = radius;
144
+ } else {
145
+ picName = "d_left";
146
+ xOff = -radius;
147
+ }
148
+ const pic = damagePics.get(picName);
149
+ if (pic) {
150
+ const size = cgi3.Draw_GetPicSize(pic);
151
+ const x = cx + xOff - size.width * 0.5;
152
+ const y = cy + yOff - size.height * 0.5;
153
+ const alpha = Math.max(0, Math.min(1, indicator.strength));
154
+ cgi3.SCR_DrawColorPic(x, y, pic, WHITE, alpha);
155
+ }
156
+ }
122
157
  };
123
158
 
124
159
  // src/hud/messages.ts