Original Post
I have an RPG that will have a health bar along with a readout of how much health you have out of the maximum. I am using allegro. My code for drawing this bar is as follows: You can see that this is flawed right away. It works, but the rightmost position of the bar only moves every half of the bar, basically, it does this: It does work with any 2 non-negative values like I thought it would. It works correctly near the end, but how can I make it display the proper percentage on a bar the entire time?
healthpercent = playermaxhealth / playerhealth;
for(int i = 0; i < 16; i++)
{
line(buffer, 66, i + 271, 66 + 890 / healthpercent, i + 271, makecol(255, 0, 0));
}
textprintf_ex(buffer, font, 350, 276, makecol(255, 255, 255),
-1, "Health: %d \\ %d", playerhealth, playermaxhealth);
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
]]]]]]]]]]]]]]]]]]]]]]]]]
]]]]]]]]]]]]]]
]]]]]]
]]]
]