Drawing Health and Armour as Vertical Bars
by The Apeman
Someone asked how to do this in the Coding area of the BeyondUnreal forums, and I decided that it might be nice to have a tutorial on this subject. If you're that person, I took the liberty of changing your idea a bit, but you should be able to understand what to do. I assume that you already have UClasses (or some other way to compile your code outside of UnrealEd) up and running. You won't be able to follow this tutorial precisely if you don't use "UCC -make" to compile your code, as you'll be importing some graphics as well. (If you're not sure what UCC is, it generally means you're not using UnrealEd) I also assume that you have a basic understanding of the C++ like syntax unrealscript uses.
| class HUDwithHPbars expands ChallengeHUD; defaultproperties { } |
| simulated function DrawStatus(Canvas
Canvas) { } |
| simulated function DrawStatus(Canvas
Canvas) { if ( !bHideStatus ) // we wouldn't want our bars to show up if the player doesn't want them { Canvas.Style = ERenderStyle.STY_Normal; // So you won't be able to see through the bars Canvas.SetPos(Canvas.ClipX - 32, 0); // The first thing to do is setting drawing offset at the right place, // and since the placeholder graphic is 32 pixels wide, we want it to be 32 pixels from the right side of the screen (ClipX) Canvas.DrawTile(Texture'BarsTutorial.TwoBars', 32, 144, 32, 0, 32.0, 144.0); Canvas.SetPos(Canvas.ClipX - 64, 0); // 32 pixels more to the right. Canvas.DrawTile(Texture'BarsTutorial.TwoBars', 32, 144, 32, 0, 32.0, 144.0); } } |
| class DeathMatchPlusBars expands DeathMatchPlus;
defaultproperties |
| class HUDwithHPbars expands ChallengeHUD;
#exec TEXTURE IMPORT NAME=TwoBars FILE=Textures\Bars.pcx MIPS=OFF simulated function DrawStatus(Canvas
Canvas) POwner = TournamentPlayer(Owner); // We need to make sure we're dealing with a player here, because not all Owners have health // The following code (until !bhidestatus) was copied
from ChallengeHUD, and figures out how much armour the player
has if ( !bHideStatus ) // we wouldn't want our bars to
show up if the player doesn't want
them // Let's add the bars themselves
now. defaultproperties |