# TimeDelta, part two.

### » Fri Apr 16, 2010 8:06 am

[quote="Steven":2jt20yi9]+ Every Tick
> Add 500 * TimeDelta to 'Y Speed' (the acceleration)
> Set Y to .Y + 'Y Speed' * TimeDelta (the speed)

That there is from the Timedelta article, is it not multiplying by Timedelta twice?[/quote:2jt20yi9]
We are talking about different approaches here. In your example it was all about a constant movement, whereas the above example generates a variable (accelerating) movement. The latter is what I wanted to show with the simplified comparison of your approach and mine a few posts above.

Remember the formula?
AmountPerTick = TimeDelta * DesiredAmountPerSecond

If DesiredAmountPerSecond is a constant value you only apply TimeDelta once. If you want it to change over time, you force another TimeDelta calculation. Let's say, DesiredAmountPerSecond shall raise by a constant value per second, then the formula is:

DesiredAmountPerSecond = DesiredAmountPerSecond + TimeDelta * DesiredRaisePerSecond

putting this into the first formula:
AmountPerTick = TimeDelta * (DesiredAmountPerSecond + TimeDelta * DesiredRaisePerSecond)

This can be stacked endlessly. Maybe DesiredRaisePerSecond shall lower over time. That would be:

DesiredRaisePerSecond = DesiredRaisePerSecond - TimeDelta * DesiredLoweringPerSecond

putting this into the first formula:
AmountPerTick = TimeDelta * (DesiredAmountPerSecond + TimeDelta * (DesiredRaisePerSecond - TimeDelta * DesiredLoweringPerSecond))

There are easier ways for acceleration or deceleration or smoothing, etc., this is just to show the "straight forwardness" of using TimeDelta
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

### » Fri Apr 16, 2010 8:19 am

I see where i steered you wrong, Tulamide. I am trying to make a variable movement. I simplified my example so i could understand it and well, threw off all the help right from the start.

I have constant movement down. It is very simple and works great. Variable is not working, but i will study your post and try to amend my way of doing things.

Edit-I am thinking that i am not using large enough numbers for Timedelta to work correctly/visibly in my current thinking.
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

### » Fri Apr 16, 2010 9:31 am

I've done another cap, showing three different movements. Maybe it is of help. Covers only the basics of course, there are way to many possibilities to get sprites moved

B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

### » Sun Apr 18, 2010 7:24 am

Thanks for the example Tulamide, It's all over my head though:P I will hold onto it. Perhaps one day in the future it will be less foreign to me, but for now all your help has gotten me to a point where i can glodge together what i need.

Cheers to everyone
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Previous