experience bar with static size

Non-platform specific questions.

experience bar with static size

Postby LowDefFTW » Fri Mar 09, 2012 3:53 pm

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);
LowDefFTW
 
Posts: 5
Joined: Sun Mar 04, 2012 3:23 am
Score: 0 Give a positive score

Re: experience bar with static size

Postby LowDefFTW » Fri Mar 09, 2012 5:08 pm

help? ;_;
LowDefFTW
 
Posts: 5
Joined: Sun Mar 04, 2012 3:23 am
Score: 0 Give a positive score

Re: experience bar with static size

Postby SuperSonic » Fri Mar 09, 2012 6:07 pm

Could you upload the functions you're using please? :)
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: experience bar with static size

Postby LowDefFTW » Sat Mar 10, 2012 1:10 am

what do you mean? Im using the same code of Hblade tutorial for bars
LowDefFTW
 
Posts: 5
Joined: Sun Mar 04, 2012 3:23 am
Score: 0 Give a positive score

Re: experience bar with static size

Postby skydereign » Sat Mar 10, 2012 3:04 am

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);
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest