# More slider math

## Recommended Posts

Hi. Recently I wrote a thread in this sub-forum about a volume slider here. I've completed that feature of my game successfully, but now I'm doing a similar thing which involves the speed of the computer. I would have taken the formula from the previous slider, but in this case it's different. The slowest speed is 10 seconds or 10000 milliseconds and the fastest speed is 0 (takes the computer 0 seconds to react). I was wondering how I'd go about doing this? Cheers. Edit: This is the basic idea of the slider.

##### Share on other sites
The easiest way to calculate value (speed) from slider position is to do linear interpolation:

speed = value_min+( value_max-value_min )*( slider_pos/slider_width )

##### Share on other sites
Oh, no I've already got a formula that works for me fine, but I'd like to make it so that if the user slides the slider to the right to value gets smaller, and if they slide it to the left it gets bigger.

##### Share on other sites
I've decided I'll go with radio buttons instead. Cheers enmaniac for helping!

##### Share on other sites
Switch max value and min value in the above equation to flip the direction.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627665
• Total Posts
2978524

• 10
• 10
• 12
• 22
• 13