====== HUD coordinate system ======
ZDoom uses a special coordinate system for [[zdoom>HudMessage]]s. In 4:3 resolutions, the coordinate system's rectangle matches that of the screen. In aspect ratios other than that, a 4:3 rectangle is put at the center of the screen and the remaining screen space is out of its boundaries.
The HUD coordinate system's rectangle width and height are specified in [[zdoom>SetHudSize]].
ACSUtils provides functions to correctly work with the HUD coordinate system.
All functions here work with fixed-point numbers. The restriction on integers in ZDoom is completely arbitrary.
===== Retrieve aspect ratio =====
[[functions:GetAspectRatio]] returns the aspect ratio that ZDoom assumes the screen is. ZDoom uses tricky code for that.
===== Actual screen boundaries =====
[[functions:HudLeftFor]], [[functions:HudRightFor]], [[functions:HudTopFor]] and [[functions:HudBottomFor]] return actual screen boundaries in the HUD coordinate system for the specified width and height of the HUD coordinate system, taking the current aspect ratio into account.
To avoid specifying a width or height every time, you can call [[functions:HudSetVirtualSize]] once and then call [[functions:HudLeft]], [[functions:HudRight]], [[functions:HudTop]] and [[functions:HudBottom]].
===== HUD borders =====
Borders are the areas of the screen that are not covered by the aforementioned rectangle. Horizontal and vertical border width can be retrieved using [[functions:HudBorderXFor]] and [[functions:HudBorderYFor]].
As with screen boundaries, you can just call [[functions:HudSetVirtualSize]] once and then use [[functions:HudBorderX]] and [[functions:HudBorderY]] without specifying the size of the HUD coordinate system every time.
===== Examples =====
Put a message in the top left corner of the screen:
HudSetVirtualSize(640.0, 480.0);
x = HudLeft(); // This will be negative in widescreen.
y = 0.0;