...

View Full Version : Image size dependant on number



ole90
03-25-2007, 11:21 PM
Hey guys,

So i want to create a HP bar for my character. I want it so, that if the HP of my character is half, then the image for of my HP bar will only fill half way.

Any ideas on how i would do this?

Thanks!

iLLin
03-25-2007, 11:27 PM
Hey guys,

So i want to create a HP bar for my character. I want it so, that if the HP of my character is half, then the image for of my HP bar will only fill half way.

Any ideas on how i would do this?

Thanks!

Huh???????

jmitch18
03-25-2007, 11:39 PM
I did this in a little game I played around with.



$percent_health = ($current_hp/$maximum_hp) * 100;

echo "<table bgcolor='green' width='100%' cellspacing='0' cellpadding='0' border='0'>";
echo "<tr>";
echo "<td align='right' width='".$percent_health."%'>";
echo "&nbsp;";
echo "</td>";
echo "<td class='norm'>";
echo "&nbsp;".$percent_health."%";
echo "</td>";
echo "</tr>";
echo "</table>";



something like that

ole90
03-25-2007, 11:40 PM
Okay, maybe i wasn't clear enough.

You know when you play a game and your have your own character with HP and a HP bar like so:

HP: 50/100
[hp bar image]

Well, i want the hp bar image, in this case, to reach on halfway. So the image is size depnds on the hp you the user has.

jmitch18
03-25-2007, 11:45 PM
Try this instead of what I posted above if you want it in that layout. It doesn't actually make an image but makes a table instead. The tables width is equal to the percentage of health you have remaining.



echo "HP: ".$current_hp."/".$maximum_hp;
$percent_health = ($current_hp/$maximum_hp) * 100;

echo "<table bgcolor='green' width='100%' cellspacing='0' cellpadding='0' border='0'>";
echo "<tr>";
echo "<td align='right' width='".$percent_health."%'>";
echo "&nbsp;";
echo "</td>";
echo "</tr>";
echo "</table>";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum