UI / HUD
game/ui.py provides two classes: HUD, which renders all in-game heads-up display elements each frame, and TerminalUI, a static helper for drawing bordered UI boxes.
HUD class
__init__(screen_width, screen_height)
Horizontal resolution of the display. Stored for positioning HUD elements and pre-baking the CRT surface.
Vertical resolution of the display. Used for CRT scanline height and scan-bar vertical placement.
pygame.SRCALPHA surface with a semi-transparent black line every 3 pixels:
blit() each frame rather than redrawn.
draw(screen, player, mission_text, scan_progress, level)
The primary HUD render call. Must be called once per frame after all world-space sprites have been drawn.
The active display surface.
The player sprite.
player.health and player.max_health are read for the health bar.Short string describing the current objective. Rendered in 18 pt Consolas in the top-right area.
Integer 0–100 controlling the decryption bar fill. The caller normalises the raw
scan_progress variable (which runs 0–200 across Levels 1 and 4) before passing it in.Current level number (1–4). Controls whether the matrix rain effect is rendered.
Render order
Matrix rain (Level 1 only)
Calls 90% of characters are dim green; 10% are bright green to simulate a flicker.
_draw_matrix(screen), which places 5 random characters from "01ABCDEF!@#$%^&*" at random screen positions per frame:Health bar
A 200×20 px bar at position Label
(20, 20). Gray background (50, 50, 50), green fill (0, 255, 100):"CORE INTEGRITY: {health}%" in 18 pt Consolas (200, 255, 200) at (20, 45).Mission objective panel
"MISSION OBJECTIVE" title in 24 pt bold (0, 255, 200) at (screen_width - 250, 20).
mission_text description in 18 pt (150, 200, 200) at (screen_width - 250, 50).Scan progress bar (conditional)
Only rendered when The fill width is
scan_progress > 0.The bar is 300 px wide, centred horizontally at screen_height - 50:3 * scan_progress, so at scan_progress = 100 the bar is fully filled (300 px).Label "DECRYPTING SYSTEM... {scan_progress}%" in cyan-green at (screen_width // 2 - 80, screen_height - 80).draw_pointer(screen, player_pos, target_pos)
Draws a directional indicator pointing from the player toward an off-screen objective.
The active display surface.
The player’s current position in screen coordinates.
The target’s position in screen coordinates, typically a terminal’s
rect.center.player_pos and target_pos is less than 100 px, the pointer is suppressed and the function returns immediately.
Otherwise, it computes a unit direction vector and places the indicator 60 px ahead of the player:
glow_color cyan-green (0, 255, 200) and rotates continuously to point at the target as the player moves.
TerminalUI class
A purely static utility class for drawing a bordered UI panel with a title label. No instance state.
draw_box(screen, rect, title)
The active display surface to draw on.
A 4-tuple
(x, y, width, height) defining the panel bounds.Text to render in the top-left corner of the box in 20 pt bold Consolas.
(5, 15, 25), a 2-px cyan border (0, 200, 255), and the title string at (rect.x + 10, rect.y + 10) in cyan: