Skip to content

Instantly share code, notes, and snippets.

@Pharap
Created May 6, 2018 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pharap/a64bbd8390a934e066da629b8da117bb to your computer and use it in GitHub Desktop.
Save Pharap/a64bbd8390a934e066da629b8da117bb to your computer and use it in GitHub Desktop.
int previousFrameTime = millis();
while(Pokitto::Core::isRunning)
{
if(Pokitto::Core::update())
{
int currentFrameTime = millis();
int difference = currentFrameTime - previousFrameTime;
previousFrameTime = currentFrameTime;
float deltaTime = difference / 1000.0f; // 1000 ms per second
// Framerate independent motion
object.position.x += object.velocity.x * deltaTime;
object.position.y += object.velocity.y * deltaTime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment