Page 1 of 1

Help with min-max

PostPosted: Sun Jul 29, 2012 8:15 pm
by Hblade
I want a variable to add up to 5 slowly but using min and max. I tried
Code: Select all
spd+=min(0, max(spd, 5));


and
Code: Select all
spd+=min(1, max(0, 5));


I can't quite figure it out. I learned it a while back, but forgot it as time passed

Re: Help with min-max

PostPosted: Mon Jul 30, 2012 1:17 am
by SuperSonic
Shouldn't it be:
Code: Select all
spd = min(spd + 0.5, 5);//Replace 0.5 with the speed that you want it to increase
:)

Re: Help with min-max

PostPosted: Tue Jul 31, 2012 1:06 am
by Hblade
Thanks! =D