Game Development Reference
In-Depth Information
This should look identical to our DrawHealthBar() function, except we've changed
the parameters for health and turned them into ammo. Our ammo bar will now
change color as we continue to drain our ammo supply.
4.
Let's make our DrawHud() function call DrawHealthText() , which will put
everything in motion. The whole function should now look like this:
/*********************************************************
* Draws the HUD
**********************************************************/
function DrawHUD()
{
super.DrawHUD();
DrawHealthText();
DrawAmmoText();
}
5.
Finally, let's add the default properties as shown in the following code snippet:
/** Ammo */
/** Corner position of bar. + / - to X / Y changes which
corner it appears in */
AmmoPosition=(X=-1,Y=1)
// Coordinates of ammo bar
AmmoCoords=(U=277,V=494,UL=76,VL=126)
6.
Compile the code and test it out for yourself. You'll see that the ammo bar is located
in the top-right corner. Remember, changing the X value for the AmmoPosition
parameter from -1 to 1 will adjust which corner the bar sits in.
You'll also notice that our bar starts half full and is colored yellow. That's fine. Our
weapon's default ammo is half of its maximum capacity, so it will continue to look this
way until we locate more ammo.
 
Search Nedrilad ::




Custom Search