Well that's kinda what I did, but you have to just keep feeding the function your new time along the curve. Which if you take (1.0 / number of seconds you want this to take) * delta time....then it works really good.
Graphics 800,600,0,0
Local sx:Float, sy:Float
Local ex:Float, ey:Float
Local p1x:Float, p1y:Float
Local p2x:Float, p2y:Float
'Start Point
sx = 100
sy = 300
'End Point
ex = 300
ey = 500
'Control Points
p1x = sx
If sy<ey Then p1y = sy-200 Else p1y = ey-200
p2x = ex
p2y = p1y
Local fTimer:Float
While Not KeyHit(KEY_ESCAPE)
Cls
DrawText "S: "+sx+", "+sy,5,5
DrawText "E: "+ex+", "+ey,5,25
DrawText "P1: "+p1x+", "+p1y,5,45
DrawText "P2: "+p2x+", "+p2y,5,65
fTimer :+ (1.0 / 1.0) * 0.0005
If fTimer < 1 Then Bezier(sx,sy,ex,ey,p1x,p1y,p2x,p2y,fTimer)
Flip
Wend
Function Bezier(sx:Float,sy:Float,ex:Float,ey:Float,p1x:Float,p1y:Float,p2x:Float,p2y:Float,t:Float)
Local pointx:Float = sx*(1-t)^3 + 3*p1x*(1-t)^2*t + 3*p2x*(1-t)*t^2 + ex*t^3
Local pointy# = sy*(1-t)^3 + 3*p1y*(1-t)^2*t + 3*p2y*(1-t)*t^2 + ey*t^3
Plot pointx,pointy
End Function
|