SecondDifference
Introduction
Code example
const int PixelsPerSecond = 100;
MyObject.X += TimeManager.SecondDifference * PixelsPerSecond;Measuring Framerate
float framesPerSecond = 1/TimeManager.SecondDifference;Detailed Discussion
// This code belongs in Update or some other method which is called every frame.
// Assume positionedObject is a valid PositionedObject, and that xVelocity,
// yVelocity, and zVelocity are defined floats which specify velocity in units
// per second.
positionedObject.X += xVelocity * TimeManager.SecondDifference;
positionedObject.Y += zVelocity * TimeManager.SecondDifference;
positionedObject.Z += yVelocity * TimeManager.SecondDifference;Time Based Movement
Last updated
Was this helpful?