Page 1 of 1

experience bar with static size

PostPosted: Fri Mar 09, 2012 3:53 pm
by LowDefFTW
Im having problems implementing a bar with static size, for some reason its always empty and never fills (but the experience value does changes), this is my code

maxexper=(level*level)*50;
SetSecondColor(255, 255, 255);
DrawBar(0, 500/3, 255, 0, 0);
bartmp=(exper/maxexper)*(500/3);
if(bartmp>maxexper)
{
bartmp=500;
}
SetBackColor(194,194,194);

Re: experience bar with static size

PostPosted: Fri Mar 09, 2012 5:08 pm
by LowDefFTW
help? ;_;

Re: experience bar with static size

PostPosted: Fri Mar 09, 2012 6:07 pm
by SuperSonic
Could you upload the functions you're using please? :)

Re: experience bar with static size

PostPosted: Sat Mar 10, 2012 1:10 am
by LowDefFTW
what do you mean? Im using the same code of Hblade tutorial for bars

Re: experience bar with static size

PostPosted: Sat Mar 10, 2012 3:04 am
by skydereign
I wouldn't recommend using that system, just because its use of bartmp makes little sense. It really should have a variable pass into it, holding the same value as bartmp. But, I believe the problem you are having is that you are using integers. An integer/integer is also an integer (with the floating point removed).

150/1000 * (500/3)
The 150/1000 resolves to 0 because of how C handles integers.
0 * (500/3)
And that will always equal zero. To fix this, cast the operation to a float, so it preserves the floating point.
Code: Select all
bartmp = (float)(exper/maxexper)*(500/3);