I have this as my lerp function:
Vec2f lerp(float t, Vec2f a, Vec2f b){
return (1-t)*a + t*b;
}
And I have the following code below, which I was hoping that would result in a "tween":
Vec2f a(0,0);
Vec2f b(3,4);
Vec2f c(5,4);
Vec2f d(5,0);
if( i < 100 ){
if(i <= 30){
ball.pos = lerp(i, a, b);
}
else if(i > 30 && i < 80){
ball.pos = lerp(i, b, c);
}
else {
ball.pos = lerp(i, a, d);
}
} i += 1;
But what I get is a "discontinuous tween", that is instead of starting at the last point where the lerp from A to B ends, it starts somewhere else, and some goes for the other lerps. What am I doing wrong?