If your item is not a powerup and you want to use SBARINFO, you can use
InInventory /
DrawImage. SBARINFO probably has more examples available than the ZScript HUD API does. You can also find an SBARINFO definition of the Doom HUD in gzdoom.pk3:
sbarinfo/doom.txt
ZScript has similar methods (DrawImage, DrawString) but the parameter order is different, and with DrawString you also have to create a HUDFont instance (see the link in the previous post for how to do that).
If you're basing your HUD off of an existing built-in HUD (for example, Doom's), add your extra code to the
Draw override but don't forget to call
BeginHUD() first, otherwise your extra stuff will jump around the screen depending on whether you're in status bar or fullscreen HUD mode. If the user has disabled the HUD (state == HUD_None), you should probably not draw anything. To prevent drawing on the automap, check for
automapactive to prevent that.
Code: Select all
class MyHud : DoomStatusBar
{
override void Draw(int state, double TicFrac)
{
Super.Draw(state, TicFrac);
// Do not draw on the automap and when the HUD is disabled
if (state == HUD_None || automapactive)
{
return;
}
// Initialize the full-screen mode (otherwise the coordinate system will be relative to the status bar area)
BeginHUD();
// TODO: Your code here
}
}
And do not forget to set the HUD class in your MAPINFO:
Code: Select all
gameinfo
{
StatusBarClass = "MyHud"
}
Damn, I really wish I had the time to write a detailed tutorial on ZScript HUDs. I may not have enough expertise though, since I haven't fully explored the entire API yet.