Author Topic: health bar  (Read 3566 times)

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
health bar
« on: October 21, 2010, 06:37:23 pm »
This is looking ahead, because I'm still working out re-scaling my program, but I'm thinking of ways to do a billboarded health bar.  So far, the idea I have is to have 10 health bars like for 10%, 20%, etc and switch them because I don't know how I could move the texture.  Any other ideas on that?
click here->Fireside 7 Games<-

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: health bar
« Reply #1 on: October 21, 2010, 07:51:44 pm »
having one healt-bar object and 10 textures and instead of switching object, switch texture might be a better alternative

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: health bar
« Reply #2 on: October 21, 2010, 08:11:20 pm »
I would simply blit the health bar as a scaled blit on top of the entity (did this in Paradroidz for example). It doesn't have to be a real object nor part of the world IMHO.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: health bar
« Reply #3 on: October 22, 2010, 12:09:04 am »
Quote
having one healt-bar object and 10 textures and instead of switching object, switch texture might be a better alternative

My thoughts on that is there is a 256x256 minimum texture, and I could put all the textures on one panel, but that would mean different texture coordinates, so changing textures wouldn't work, unless you know some way to do that.  If you did, I could just move the texture coordinates on one health bar on a transparent background.  It possible to use smaller textures, but something gets done and it's kicking up errors once in a while for me, though not fatal.

Quote
I would simply blit the health bar as a scaled blit on top of the entity (did this in Paradroidz for example). It doesn't have to be a real object nor part of the world IMHO

I'm printing damage stats right now that way, and it's really hard to tell which character they apply to when they are close together.  I'm not sure if it would be any better with a billboard or not.  I just have a feeling it would as the character further away would have a smaller bar.  I guess I'll experiment with the two methods.

Thanks for the suggestions.



« Last Edit: October 22, 2010, 12:14:39 am by fireside »
click here->Fireside 7 Games<-

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: health bar
« Reply #4 on: October 22, 2010, 12:39:06 am »
Another couple options if blitting doesn't work for you, if it is just a 2-color bar you could make a texture twice the width of the bar with the health color on the left half and the no-health color on the right.  Then just change the u/v coordinates to the right to lose health and to the left to gain health.  For more complicated graphics I would use frames tiled on a single "mosaic" texture and switch the uv coordinates as necessary (see my GIF texture project for an example).  This is what I'm doing for the HUD and shield strength pannels for the game I'm working on.  If you need help figuring out the uv switching code or setting up the texture let me know.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: health bar
« Reply #5 on: October 22, 2010, 12:50:54 am »
Quote
If you need help figuring out the uv switching code or setting up the texture let me know.

Yes, I need help with that.  I was trying to find some way of doing it but couldn't find any.  I had thought of having one side transparent and one side red.

edit: Just noticed your reference to the GIF project, I'll check that out first, thanks.
« Last Edit: October 22, 2010, 01:34:37 am by fireside »
click here->Fireside 7 Games<-