Help with min-max

Non-platform specific questions.

Help with min-max

Postby Hblade » Sun Jul 29, 2012 8:15 pm

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
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Help with min-max

Postby SuperSonic » Mon Jul 30, 2012 1:17 am

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
:)
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: Help with min-max

Postby Hblade » Tue Jul 31, 2012 1:06 am

Thanks! =D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron