-
-
Save Pharap/a64bbd8390a934e066da629b8da117bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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