ID:270157
Jan 24 2006, 12:03 pm
|
|
I want to put a health bar into my game but have very little knowledge on how to do it. I know that I need an icon with different icon states for it. I got that. Now how do I make the icon show up as the health bar? This brings up another question. How do i incorperate icons into a stat panel? I don't plan on putting the health bar over the character, but having it in a stat panel.
|
In response to Loduwijk
|
|
How do I make a proc that will update the health bar depending on how much health the user has (I want it to check every time the user gets attacked and takes damage).
|
In response to Clark Kent
|
|
Nevermind. I figured it out
|
In response to Clark Kent
|
|
If the icon states for the health meter are numbered 0 or 1 through the number of states, then you can just use a formula to grab the appropriate one. health/max_health*max_state. max_state is, of course, the highest numbered icon state. So, if you use an entire icon and have a meter go up or down by a pixel every time, you would probably have icon states numbered up to 32. In such a case you would do health/max_health*32.
mob/proc/update_meter() Then you could call it wherever health is changed. mob |
In response to Clark Kent
|
|
Now I have a new problem. It seems the way it's set up it's affecting everyone (modifying everyones health bar when someone gets attacked). The code is as follows:
client |
In response to Clark Kent
|
|
The for(var/obj/health_bar/health_meter) is what's doing it to you. Looping through them with a for-loop is going to loop through all of them that exist. What you want in that situation is just client.health_meter.
|
You could set the health_meter's icon_state in the Stat function if you wanted to take the easy way out, but I would suggest you change it after every time the client's mob's health is changed.