I am rendering cards that are being dealt. Player cards are at the bottom of the screen, dealer cards are more at the top. Cards are dealt from "offscreen" at the top. Thus the distance between cards starting position and player hand is longer than the distance between starting position and dealer hand.
I am calculating the cards current position using the interpolated_position value which is between 0.0 and 1.0. Because of the different distances, the animations have different animation speed though.
/// Updates the first animation in the queue then deletes it
void Update(float delta_time)
{
if (pause == false && !animation_confs.empty())
{
interpolated_position += delta_time * (animation_confs[0].speed); // animation speed is 1.3 here
if (interpolated_position >= 1.0f) // Finished animation reset values
{
interpolated_position = 0.0f;
if (!animation_confs.empty())
{
animation_confs.erase(animation_confs.begin());
return;
}
}
InterpolateFrame();
}
}
// Interpolates card position between two points based on interpolation factor
void InterpolateFrame()
{
if (!animation_confs.empty())
{
float t = interpolated_position;
float x1 = animation_confs[0].start.x;
float x2 = animation_confs[0].goal.x;
position.x = x1 + t * (x2 - x1);
float y1 = animation_confs[0].start.y;
float y2 = animation_confs[0].goal.y;
position.y = y1 + t * (y2 - y1);
}
}
What might be the reason for this behaviour? I thought that applying delta_time to the interpolation would keep the speed constant.