UnrealScript Game Programming Cookbook
Weapons 188 We've changed a few values here from the explosive barrel. Most notably, we use a different static mesh, and instead ...
7 HUD In this chapter, we will cover: f Displaying a bar for the player's health f Drawing text for the player's health f Displa ...
HUD 190 We'll be sticking with Canvas for our purposes, as it suits our needs well and only requires knowledge of UnrealScript. ...
Chapter 7 191 /** Texture for HP bar*/ var const Texture2D BarTexture; /** Current owner of the HUD */ var Pawn PawnOwner; /** S ...
HUD 192 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 b ...
Chapter 7 193 Now we need to draw the actual bar graph to represent our health. We'll be using the same function to draw a bar ...
HUD 194 // Set default color to white DrawColor = Default.WhiteColor; DrawColor.B = 16; // If our HP is > 80%, decrease the a ...
Chapter 7 195 With all of our drawing functions for the bar in place, we need a way to align it on screen. /** Returns correcte ...
HUD 196 We now have a fully functioning HUD that displays our health bar in the top-left corner! There's still one last step, h ...
Chapter 7 197 How it works... We start off by defining the size of our screen based on resolution. Our PostRender() function dyn ...
HUD 198 How to do it... For this recipe, we'll take what we learned in our previous recipe and add more functionality onto it. A ...
Chapter 7 199 /** Sets the bar position */ POS = CorrectedHudPOS (HPPosition,BarCoords.UL,BarCoords.VL); /** Offsets the text fr ...
HUD 200 FinalPos.Y = (Offset.Y < 0 && Height != 0)? HUDPosition.Y - (Height * ResScaleY) + (Offset.Y * ResScaleY) : H ...
Chapter 7 201 Our current health is displayed on the top-right corner of our health bar. Let's take a look at how it changes as ...
HUD 202 Getting ready Open your IDE and have it ready to edit our TutorialHUD class again. We're only going to make changes to t ...
Chapter 7 203 We offset the bar's position again by using the CorrectedHudPOS() function we used in the last recipe as well. Thi ...
HUD 204 This should look identical to our DrawHealthBar() function, except we've changed the parameters for health and turned th ...
Chapter 7 205 How it works... The process is done in the same manner as our health bar. We start off by adding a function to dra ...
HUD 206 **********************************************************/ function DrawAmmoText() { local Vector2D TextSize, AmmoTextO ...
Chapter 7 207 /** Draws Ammo Bar */ DrawAmmoBar (POS.X, POS.Y, AmmoCount, MaxAmmo, 80, Canvas); } This should look very similar ...
«
5
6
7
8
9
10
11
12
13
14
»
Free download pdf