Draw

From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.


native virtual void Draw(int state, double TicFrac)

Usage

Called at the same rate as the current frame rate. This is used to handle drawing HUD elements. Internally this function handles refreshing the border around the HUD, calling DrawMyPos, drawing the crosshair, and calling DrawAutomapHUD.

Parameters

  • state - The current state of the HUD. This can be one of the following constants:
  • HUD_StatusBar - The status bar is currently visible
  • HUD_Fullscreen - The status bar is currently hidden but the HUD is still being drawn
  • HUD_None - The HUD is completely disabled
  • HUD_AltHud - GZDoom's alternate HUD is being used
  • TicFrac - Since Draw is called between tics, this is the fraction of the way the game is to the next tic. For instance, if the game is running at 140 FPS this value would fluctuate between 0, 0.25, 0.5, and 0.75

Examples

override void Draw(int state, double TicFrac)
{
    super.Draw(state, TicFrac);

    if (state == HUD_StatusBar)
    {
        // If the status bar is visible, draw it
        BeginStatusBar();
        DrawMainBar(TicFrac);
    }
    else if (state == HUD_Fullscreen)
    {
        // If the status bar is hidden, use the simpler fullscreen HUD instead
        BeginHUD();
        DrawFullScreenStuff();
    }
}