Health Bars

Posted on Thursday, October 11, 2007 at 09:17 PM by bfish

So, I got health bars working! It required that I finish implementing my matrix multiplication code, which I was loathe to do. So far anytime I had to multiply matrices, I did it either inside shaders or via the many OpenGL matrix multiplication functions. My rotations and things were all done via quaternions, but I was forced to use matrix multiplication in software to get these looking right.

The width of the health bar is proportional to the width of the unit on the screen. The height, however, is constant...about 4 pixels. This allows you to gauge the health of a unit accurately even when it is far away. With a typical billboard type system, the health bar would get too small to see due to perspective correction. This, however, does a point projection to find out where on the screen the bar should go, and then does the rest in 2D window coordinates (to keep the constant height).

![health-bars]

EDIT: Here's another pic that shows how well the health bars work when you get zoomed out (and this, of course, is what the camera will typically be looking like):

![health-bars-again]

Comments

6 comments:

Braxton says:
Posted on Thu, October 11, 2007 at 09:57 PM

Wow, that is starting to all come together. Very cool.

Irwin1138 says:
Posted on Fri, October 12, 2007 at 02:34 AM

IMO they should be wider (in height) than 4 px. Cuz when youll have much more elements on screen like the base, foliage (on Mars? :D ), particles and such, itll be hard to see those 4 px. I think you should try increasing it at least to 5-6.

Dave Johansen says:
Posted on Fri, October 12, 2007 at 09:07 AM

It's amazing how much a tiny detail like health bars adds to the look of the game. It just really jumps out at you now and screams, "I'm an RTS!"

Brad says:
Posted on Fri, October 12, 2007 at 10:21 AM

Irwin1138 says:

IMO they should be wider (in height) than 4 px. Cuz when youll have much more elements on screen like the base, foliage (on Mars? :D ), particles and such, itll be hard to see those 4 px. I think you should try increasing it at least to 5-6.

I guess I beat you to this idea, because I originally tried 6, then 5 pixels, before settling on 4. It looked junky because the health bars looked "fat". They just took up way too much vertical space. Remember, most of the time you'll be looking down from a far-off view, so the second screenshot above is the most accurate.

As of now, the health bars are shown on top of everything else, including billboards, particles, etc. The only thing that can obscure a health bar is another health bar, so there should be no problem seeing them even with more stuff on screen.

Dave Johansen says:

It's amazing how much a tiny detail like health bars adds to the look of the game. It just really jumps out at you now and screams, "I'm an RTS!"

I definitely agree. It always seems to be the little things that get me more and more excited.

Irwin1138 says:
Posted on Fri, October 12, 2007 at 01:35 PM

Yeah, you really beated me there :) I should say I didnt think about the fact that most of the time camera will be far away from the units, and judged only by the close screenshot.

余俊耀 says:
Posted on Sat, October 13, 2007 at 12:38 AM

我有頭痛!

Post a Comment

Fields marked with * are required.

:

* :
* :
:
:

HTML not allowed. To markup your comment, use Markdown syntax instead.