The Daily Click ::. Forums ::. Klik Coding Help ::. Slowmotion jump
 

Post Reply  Post Oekaki 
 

Posted By Message

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
28th November, 2006 at 16:53:31 -

I'm trying to develop a kind of slowmotion effect with my custom movement.

I have an adjusting ratio, which is basically a percentage, which is being used to slow the thing down.

The main purpose is to slow the game down if the user chooses to increase the framerate higher than the one I developed it in. The slow-motion effect is offset by the increased framerate, so things appear to be going at the same speed as before (just smoother).

The adjusting ratio is being retrieved this way:

adjusting ratio = original fps / new fps

So if I designed the game in 50fps, but the user runs it in 100fps, the adjusting ratio will be 0.5 (50%)

This means that if the user was travelling 2px per frame, at 50ps he would have gone 100px in one second. To go at the same speed in 100fps, it needs to travel only 1px per frame.

So the adjustment ratio is used like this:

step value * adjustment ratio = adjusted step value

...or in our case:

2px per frame * 0.5 = 1px per frame


That's all well and good, but I'm having trouble implementing it with gravity and jumps.

The jump is a one-off value, so I don't think it needs to be adjusted (the player puts an upward thrust of 20px, which is then countered by gravity in subsequent loops). The adjustment should hopefully live in the gravity calculation.


At the moment, my unadjusted gravity calculation is as follows:

Current Y Speed + ( Terminal Velocity - Current Y Speed ) * 0.05

[the 0.05 is the rate of acceleration]

I'm using this formula to try and act a bit more like real life, where a falling object accelerates rapidly at first, then slower and slower until it reaches terminal velocity.

So where the heck does my adjusting figure go?

I'm guessing I need to adjust Terminal Velocity, since this is basically a pixels-per-frame value. Anything else?

Is there a better formula which might be easier to marry up with the slowmotion engine?



 
191 / 9999 * 7 + 191 * 7

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
29th November, 2006 at 12:50:14 -

Try adjusting the rate of acceleration with the step value, maybe.
The terminal velocity would just alter the max speed he can achieve, not how quickly he can achieve it.
So the lower the terminal velocity, the quicker he reaches max speed.
If you adjust the gravity ratio, this would affect how quickly he reaches this speed.

Maybe.

 
My signature is never too big!!!

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
29th November, 2006 at 15:57:53 -

It's a bit trickier than that.

For terminal velocity, although it's just the maximum speed, it's a speed that's measured in pixels per frame. So 30px/f is 1,500px/s at 50fps, but 2,100px/s at 70fps.

I'm wondering if there's something to do with the percentage (the 0.05) that's stopping it working?

 
191 / 9999 * 7 + 191 * 7

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
29th November, 2006 at 17:53:00 -

Velocity/Frame rate = number of pixels moved per frame

You've probably already mentioned it somewhere.

Might be useful somewhere in your calculations if you havent used it already.

 
My signature is never too big!!!

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
30th November, 2006 at 18:37:43 -

I've reworked it so the whole thing runs using velocities in pixels-per-second rather than pixels-per-frame, and it works just the same as before.

I'm pretty certain the problem lies in the way I'm reducing the acceleration as it approaches terminal velocity.

I may try working on a system to use sin/cos to reduce it instead, since that should keep the curve.

 
191 / 9999 * 7 + 191 * 7
   

Post Reply



 



Advertisement

Worth A Click