Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

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
add comment

Your Answer

 
discard

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.