Game Development Reference
In-Depth Information
3.
Adding the DrawHUD function is the next step. This is part of the game's main loop
and is called by each frame. We'll be putting any function here for drawing the HUD,
and you'll understand how heavily it is utilized in the coming recipes.
/**********************************************************
* Draws the HUD
**********************************************************/
function DrawHUD()
{
super.DrawHUD();
DrawHealthText();
}
4.
The next function, despite being called DrawHealthText() , actually sets some
variables that we'll need for our health bar, in addition to calling DrawHealthbar() .
/**********************************************************
* Draws the health text bar
**********************************************************/
function DrawHealthText()
{
local Vector2D TextSize, POS, HPTextOffsetPOS;
local int HPAmount, HPAmountMax;
/** Sets the bar position */
POS = CorrectedHudPOS
(HPPosition,BarCoords.UL,BarCoords.VL);
/** Offsets the text from the bar */
HPTextOffsetPOS = HudOffset(POS, HPTextOffset,);
/** Sets the pawn's health amount */
HPAmount = PlayerOwner.Pawn.Health;
HPAmountMax = PlayerOwner.Pawn.HealthMax;
/** Draws health bar */
DrawHealthBar(POS.X, POS.Y, HPAmount, HpAmountMax, 80,
Canvas);
}
You'll also see that we're setting the bar position by using a variable called POS and
setting it to the CorrectedHudPos function. This will be explained shortly. We will
be creating a DrawHealthBar() function which takes an integer as its third and
fourth parameters. We've set our HPAmount and HPAmountMax variables to grab
our pawn's hit points, and we'll use that as our parameter.
 
Search Nedrilad ::




Custom Search