Finding out the speed to get to certain point at the right moment

Started by Laskiapina, November 22, 2010, 10:45:05 AM

Previous topic - Next topic

Laskiapina

This is more of a math problem than programming but anyway...

Okay, so I have 430 milliseconds and I want to move object from x-coordinate 175 to 50 in exactly that time. Of course these variables change all the time so I need to learn an equation to find out how fast the object should move so it reaches that x-coordinate 50 in 430 milliseconds.

I hope someone gets what I mean. This is driving me nuts.
Finished projects so far: Kumiankka, Meals of the Dragon, Fisut, Draw Old, Reikäkopio, Blindage, Escape from Millmier

Homepage: Not yet named project

kevin

 You need to flip the problem around, so try  Timer Based Movement

eg,



Duration=2500

StartX=100
StartY=100

EndX=200
EndY=200

StartTime=Timer()
EndTime=StartTime+Duration#


Do
Cls 0
CurrentTime=Timer()

TimePast#=CurrentTime-StartTime
Scaler#=TimePast#/Duration
IF scaler#>1 then Scaler#=1

x=STartX+(EndX-STartX)*Scaler#
y=STartY+(EndY-STartY)*Scaler#

Circle X,y,20,true


Sync
loop