Step

This function will update the time with an elasped time of 1/60. This will cause the application speed and UPS to behave as though the application is running at exactly 60 frame per second, regardless of the real frame rate.

Syntax

Remarks

Whereas Leadwerks::Time::Update will handle framerates that fall below 60 hz and interpolate between physics frames smoothly, Leadwerks::Time::Step makes the application run at a constant logical framerate. If the framerate is faster than 60 hz, this function will make a call to Time;:Delay() to slow it down. The only problem arises if the framerate falls below 60 hz. In that case, the logical frame rate will still run at a constant speed and the application will appear slower. For this reason, it is recommended the user call Leadwerks::Time::Update() in most cases instead.

Example

#include "Leadwerks.h"

using namespace Leadwerks;

Model* model = NULL;
bool paused = false;

int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
World* world = World::Create();
Camera* camera = Camera::Create();
camera->Move(0,0,-3);
Light* light = DirectionalLight::Create();
light->SetRotation(35,35,0);

model = Model::Box();
model->SetColor(0.0,0.0,1.0);

while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

//Press the space key pause and resume timing
if (window->KeyHit(Key::Space))
{
paused = !paused;
if (paused)
{
Leadwerks::Time::Pause();
}
else
{
Leadwerks::Time::Resume();
}
}

model->Turn(0,Leadwerks::Time::GetSpeed(),0);

Leadwerks::Time::Update();
world->Update();
world->Render();

context->SetBlendMode(Blend::Alpha);
context->DrawText("Time: "+String(Leadwerks::Time::GetCurrent()),2,2);
context->DrawText("Millisecs: "+String(Leadwerks::Time::Millisecs()),2,22);

context->Sync();
}
return 0;
}