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.
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()
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 */
// Coordinates of ammo bar
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