|
@@ -421,49 +421,8 @@ bool Entity::tick(double time)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- double t = MIN(totalTime, currentFrame.duration);
|
|
|
- speed = { 0, 0, speed.z };
|
|
|
- if ((currentFrame.movementFlags | 1) == currentFrame.movementFlags)
|
|
|
- {
|
|
|
- speed += {currentFrame.direction.x, currentFrame.direction.y, 0};
|
|
|
- }
|
|
|
- if ((currentFrame.movementFlags | 2) == currentFrame.movementFlags)
|
|
|
- {
|
|
|
- Vec2<float> norm = { currentFrame.direction.x, currentFrame.direction.y };
|
|
|
- norm.CCW90().normalize();
|
|
|
- speed += {norm.x, norm.y, 0};
|
|
|
- }
|
|
|
- if ((currentFrame.movementFlags | 4) == currentFrame.movementFlags)
|
|
|
- {
|
|
|
- speed += {-currentFrame.direction.x, -currentFrame.direction.y, 0};
|
|
|
- }
|
|
|
- if ((currentFrame.movementFlags | 8) == currentFrame.movementFlags)
|
|
|
- {
|
|
|
- Vec2<float> norm = { currentFrame.direction.x, currentFrame.direction.y };
|
|
|
- norm.CW90().normalize();
|
|
|
- speed += {norm.x, norm.y, 0};
|
|
|
- }
|
|
|
- if ((currentFrame.movementFlags | 16) == currentFrame.movementFlags)
|
|
|
- {
|
|
|
- speed.z = -maxMovementSpeed;
|
|
|
- }
|
|
|
- else if ((currentFrame.movementFlags | 32) == currentFrame.movementFlags)
|
|
|
- {
|
|
|
- speed.z = maxMovementSpeed;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- speed.z = 0.f;
|
|
|
- }
|
|
|
- Vec2<float> norm = { speed.x, speed.y };
|
|
|
- if (norm.getLengthSq() != 0)
|
|
|
- {
|
|
|
- norm.normalize();
|
|
|
- speed.x = norm.x * maxMovementSpeed;
|
|
|
- speed.y = norm.y * maxMovementSpeed;
|
|
|
- }
|
|
|
- // TODO: collision check
|
|
|
- pos += speed * (float)t;
|
|
|
+ double t = min(currentFrame.duration, totalTime);
|
|
|
+ pos += (currentFrame.targetPosition - pos) * (float)(t / currentFrame.duration);
|
|
|
currentFrame.duration -= t;
|
|
|
totalTime -= t;
|
|
|
if (currentFrame.duration <= 0)
|
|
@@ -472,7 +431,6 @@ bool Entity::tick(double time)
|
|
|
}
|
|
|
rend = 1;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return Model3D::tick(time);
|
|
|
}
|