Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm making a game with shot powers (user presses and holds and launches an object)

Distance from the cursor was working for testing but obviously a distance of 1 and 2 pixels is double. I scaled this by 4 to make the difference itself less drastic but they're double of each other.

Is there a common way to smooth the strength of a shot so it's not so great per jump?

share|improve this question
up vote 2 down vote accepted

I would suggest trying a logarithmic scale. This is probably best as a power factor. As they drag further away, the power will increase at a slower rate.

For example:

var maxPower = 300;
var scale = 4;
var distance = (the number of pixels they dragged...);

var power = maxPower * log( distance / scale );

scale image

share|improve this answer
It worked pretty good, thanks! – Vaughan Hilts Mar 20 '13 at 13:52

Easy answer: start from say 10, so your power function goes like 10, 11, 12 ...

Advanced answer: linear functions aren't so great for things like powers, where you're interested in the relative difference between powers. For example, power 100 should be noticeably different to power 99, even though the linear difference is just 1%, barely noticeable. Instead you should start with something like a geometric series, which means a function where every step is a constant factor up or down. You see this crop up in a lot of places, such as exp required for next level up, the amplitude from volume knobs, chance-to-hit formulas etc.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.