Chapter 7
199
/** 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 text */
Canvas.Font = TutFont;
Canvas.SetDrawColorStruct(WhiteColor);
Canvas.SetPos(HPTextOffsetPOS.X,HPTextOffsetPOS.Y);
Canvas.DrawText
(HPAmount,,TextScale * ResScaleY,TextScale * ResScaleY);
Canvas.TextSize(HPAmount, TextSize.X, TextSize.Y);
/** Draws health bar */
DrawHealthBar
(POS.X, POS.Y, HPAmount, HpAmountMax, 80, Canvas);
}
- One more function is necessary to offset the text from our bar, and looks nearly
identical to our CorrectedHudPos() function. It takes CorrectedHudPos
and offsets it by a value defined in the DefaultProperties block.
/**
- Offsets HUD and places the bottom/right portion of image
- at coords if. If offset is great than 0, & if width /
- height are supplied @Param Position Default position
- based on 1024x768 res
- @Param Offset Value to offset the text from the texture
- @returns FinalPOS
**/
function Vector2D HudOffset(vector2D HUDPosition, vector2D
Offset, optional float Width, optional float Height)
{
local vector2D FinalPos;
FinalPos.X = (Offset.X < 0 && Width != 0)?
HUDPosition.X - (Width * ResScaleY) +
(Offset.X * ResScaleY) :
HUDPosition.X + (Offset.X * ResScaleY);