group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
HudTypes.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <cstdint>
7#include <glm/glm.hpp>
8#include <span>
9#include <string>
10
11// ── Colors ──────────────────────────────────────────────────────────────────
12
15{
16 float r = 1.f, g = 1.f, b = 1.f, a = 1.f;
17
18 constexpr HudColor() = default;
19 constexpr HudColor(float r_, float g_, float b_, float a_ = 1.f) : r(r_), g(g_), b(b_), a(a_) {}
20
21 static constexpr HudColor white() { return {1, 1, 1, 1}; }
22 static constexpr HudColor black() { return {0, 0, 0, 1}; }
23 static constexpr HudColor red() { return {1, 0, 0, 1}; }
24 static constexpr HudColor green() { return {0, 1, 0, 1}; }
25 static constexpr HudColor yellow() { return {1, 1, 0, 1}; }
26 static constexpr HudColor cyan() { return {0, 1, 1, 1}; }
27 static constexpr HudColor transparent() { return {0, 0, 0, 0}; }
28};
29
30// ── Enums ───────────────────────────────────────────────────────────────────
31
44
45enum class HudAlign
46{
50};
51
53enum class HudIcon : uint8_t
54{
55 // Placeholder — populated when the icon atlas is authored.
56 None = 0,
57};
58
59// ── Vertex ──────────────────────────────────────────────────────────────────
60
63{
64 float position[2];
65 float uv[2];
66 float color[4];
67 float texMode;
68 float shapeData[3];
69};
70
71// ── Crosshair ───────────────────────────────────────────────────────────────
72
75{
76 float gap = 3.f;
77 float length = 6.f;
78 float thickness = 2.f;
79 HudColor color{0.f, 1.f, 0.f, 0.85f};
80 bool dot = true;
81};
82
83// ── Game State Contract ─────────────────────────────────────────────────────
84
87{
88 std::string killerName;
89 std::string victimName;
90 int weaponId = 0;
91 bool isHeadshot = false;
92};
93
96{
97 float angleDeg = 0.f;
98 float amount = 0.f;
99};
100
103{
104 bool isHeadshot = false;
105 bool isKill = false;
106 bool shieldBreak = false;
107};
108
113{
114 float worldX = 0.f, worldY = 0.f, worldZ = 0.f;
115 int damage = 0;
116 bool headshot = false;
117 bool shielded = false;
118};
119
122{
123 int total = 0;
124 HudColor color{1.f, 1.f, 1.f, 1.f};
125};
126
129{
130 std::string name;
131 int health = 100;
132 bool isAlive = true;
133 int kills = 0;
134 int deaths = 0;
135 int ping = 0;
136};
137
140{
141 float worldX = 0.f, worldZ = 0.f;
142};
143
148{
149 int health = 100, maxHealth = 100;
150 int armor = 0, maxArmor = 100;
151 int ammoClip = 30, ammoReserve = 90;
152 int weaponId = 0;
154 bool isAlive = true;
155 bool isBuyPhase = false;
156
157 // Events (valid for this frame only).
158 std::span<const HudKillFeedEntry> killFeedEvents;
159 std::span<const HudDamageEvent> damageEvents;
160 std::span<const HudHitConfirm> hitConfirms;
161 std::span<const HudDamageNumber> damageNumbers;
163
164 // View/projection for world→screen projection (damage numbers).
165 glm::mat4 viewProj{1.f};
166
167 // Team status.
168 std::span<const HudTeamMemberStatus> allies;
169 std::span<const HudTeamMemberStatus> enemies;
170 int allyScore = 0, enemyScore = 0;
171
172 // Minimap.
173 float localPlayerX = 0.f, localPlayerZ = 0.f;
174 float localPlayerYaw = 0.f;
175 std::span<const HudMinimapDot> enemyDots;
176 float minimapWorldRange = 1000.f;
177
178 // Vignette events (set by Game each frame based on health/armor deltas).
179 bool tookDamage = false;
180 float damageIntensity = 0.f;
181 bool armorBroke = false;
182 // isAlive already covers death vignette.
183
184 // Weapon pickup prompt — populated by Game when the local player is in
185 // range of (and looking at) an available weapon spawner. The HUD reads
186 // these to render a "Press F to pick up <Weapon>" hint.
187 bool pickupAvailable = false;
189
190 // Screen dimensions (set by Game each frame).
191 float screenW = 1280.f, screenH = 720.f;
192};
HudAlign
Definition HudTypes.hpp:46
@ Right
Definition HudTypes.hpp:49
@ Left
Definition HudTypes.hpp:47
HudAnchor
Definition HudTypes.hpp:33
@ TopRight
Definition HudTypes.hpp:36
@ Center
Definition HudTypes.hpp:38
@ BottomRight
Definition HudTypes.hpp:42
@ TopCenter
Definition HudTypes.hpp:35
@ BottomLeft
Definition HudTypes.hpp:40
@ CenterLeft
Definition HudTypes.hpp:37
@ CenterRight
Definition HudTypes.hpp:39
@ TopLeft
Definition HudTypes.hpp:34
@ BottomCenter
Definition HudTypes.hpp:41
HudIcon
Icon identifiers for the HUD icon atlas.
Definition HudTypes.hpp:54
@ None
Definition HudTypes.hpp:56
Crosshair appearance parameters.
Definition HudTypes.hpp:75
HudColor color
Default green.
Definition HudTypes.hpp:79
bool dot
Draw center dot.
Definition HudTypes.hpp:80
float length
Length of each crosshair arm (pixels).
Definition HudTypes.hpp:77
float gap
Gap from center to start of each line (pixels).
Definition HudTypes.hpp:76
float thickness
Line thickness (pixels).
Definition HudTypes.hpp:78
RGBA color for HUD elements (linear space, straight alpha).
Definition HudTypes.hpp:15
float r
Definition HudTypes.hpp:16
float g
Definition HudTypes.hpp:16
static constexpr HudColor transparent()
Definition HudTypes.hpp:27
float b
Definition HudTypes.hpp:16
static constexpr HudColor cyan()
Definition HudTypes.hpp:26
static constexpr HudColor red()
Definition HudTypes.hpp:23
static constexpr HudColor white()
Definition HudTypes.hpp:21
static constexpr HudColor black()
Definition HudTypes.hpp:22
float a
Definition HudTypes.hpp:16
constexpr HudColor()=default
static constexpr HudColor yellow()
Definition HudTypes.hpp:25
constexpr HudColor(float r_, float g_, float b_, float a_=1.f)
Definition HudTypes.hpp:19
static constexpr HudColor green()
Definition HudTypes.hpp:24
Current damage accumulator state for the local player.
Definition HudTypes.hpp:122
int total
Accumulated damage to current target.
Definition HudTypes.hpp:123
HudColor color
Color matching the latest hit type.
Definition HudTypes.hpp:124
Damage direction indicator.
Definition HudTypes.hpp:96
float amount
Damage amount (for intensity scaling).
Definition HudTypes.hpp:98
float angleDeg
Direction the damage came from (degrees, 0=front, CW).
Definition HudTypes.hpp:97
Floating damage number spawned at a world-space hit position.
Definition HudTypes.hpp:113
bool headshot
Definition HudTypes.hpp:116
float worldZ
World-space hit position.
Definition HudTypes.hpp:114
float worldX
Definition HudTypes.hpp:114
float worldY
Definition HudTypes.hpp:114
int damage
Damage dealt.
Definition HudTypes.hpp:115
bool shielded
True if target had armor when hit.
Definition HudTypes.hpp:117
Snapshot of game state consumed by the HUD each frame.
Definition HudTypes.hpp:148
bool armorBroke
True the frame armor dropped to zero.
Definition HudTypes.hpp:181
float roundTimeRemaining
Definition HudTypes.hpp:153
float localPlayerYaw
Player facing direction (radians, 0 = +Z, CW).
Definition HudTypes.hpp:174
std::span< const HudHitConfirm > hitConfirms
Definition HudTypes.hpp:160
int armor
Definition HudTypes.hpp:150
float screenH
Definition HudTypes.hpp:191
std::span< const HudTeamMemberStatus > enemies
Definition HudTypes.hpp:169
std::span< const HudDamageEvent > damageEvents
Definition HudTypes.hpp:159
std::span< const HudTeamMemberStatus > allies
Definition HudTypes.hpp:168
HudDamageAccum damageAccum
Running damage total to current target.
Definition HudTypes.hpp:162
bool pickupAvailable
True when a pickup is currently actionable.
Definition HudTypes.hpp:187
int allyScore
Definition HudTypes.hpp:170
float screenW
Definition HudTypes.hpp:191
int maxHealth
Definition HudTypes.hpp:149
int ammoClip
Definition HudTypes.hpp:151
std::span< const HudKillFeedEntry > killFeedEvents
Definition HudTypes.hpp:158
bool isBuyPhase
Definition HudTypes.hpp:155
float localPlayerZ
Definition HudTypes.hpp:173
bool tookDamage
True the frame health or armor decreased.
Definition HudTypes.hpp:179
int maxArmor
Definition HudTypes.hpp:150
int weaponId
Definition HudTypes.hpp:152
glm::mat4 viewProj
Definition HudTypes.hpp:165
std::span< const HudMinimapDot > enemyDots
Definition HudTypes.hpp:175
int health
Definition HudTypes.hpp:149
std::span< const HudDamageNumber > damageNumbers
Floating damage numbers to spawn this frame.
Definition HudTypes.hpp:161
float damageIntensity
0..1 fraction of max-health lost this frame.
Definition HudTypes.hpp:180
int ammoReserve
Definition HudTypes.hpp:151
bool isAlive
Definition HudTypes.hpp:154
float localPlayerX
Definition HudTypes.hpp:173
float minimapWorldRange
World units visible in each direction from center.
Definition HudTypes.hpp:176
int enemyScore
Definition HudTypes.hpp:170
int pickupWeaponId
Mirrors WeaponType: 0=Rifle, 1=Rocket, 2=RailGun, 3=EnergyGun.
Definition HudTypes.hpp:188
Hit confirmation event.
Definition HudTypes.hpp:103
bool isKill
Definition HudTypes.hpp:105
bool shieldBreak
True when this shot depleted the target's armor.
Definition HudTypes.hpp:106
bool isHeadshot
Definition HudTypes.hpp:104
Kill feed entry data.
Definition HudTypes.hpp:87
bool isHeadshot
Definition HudTypes.hpp:91
int weaponId
Definition HudTypes.hpp:90
std::string victimName
Definition HudTypes.hpp:89
std::string killerName
Definition HudTypes.hpp:88
World-space position for minimap display.
Definition HudTypes.hpp:140
float worldX
Definition HudTypes.hpp:141
float worldZ
Definition HudTypes.hpp:141
Per-teammate status (for scoreboard / team bar).
Definition HudTypes.hpp:129
int ping
Definition HudTypes.hpp:135
bool isAlive
Definition HudTypes.hpp:132
int kills
Definition HudTypes.hpp:133
int health
Definition HudTypes.hpp:131
int deaths
Definition HudTypes.hpp:134
std::string name
Definition HudTypes.hpp:130
Per-vertex data for all HUD geometry (48 bytes).
Definition HudTypes.hpp:63
float position[2]
Pixel coordinates, origin top-left.
Definition HudTypes.hpp:64
float uv[2]
Texture coords (atlas UV or local quad pos for shapes).
Definition HudTypes.hpp:65
float texMode
0=solid, 1=SDF text, 2=sprite, 3=SDF rounded rect.
Definition HudTypes.hpp:67
float shapeData[3]
Mode 3 only: [halfWidth, halfHeight, cornerRadius] in pixels.
Definition HudTypes.hpp:68
float color[4]
RGBA, straight alpha.
Definition HudTypes.hpp:66