Refactored HUD logic into hud.c