# More slider math

This topic is 4056 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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.

1. 1
2. 2
3. 3
Rutin
20
4. 4
frob
18
5. 5

• 32
• 13
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
632562
• Total Posts
3007094

×