I've just started using MonoGame (which pretty much seems to be an open implementation of XNA) and I'm trying to figure out on how to work with framerate independant calculations. Usually what I found in all the other game engines / libraries I've used before its some kind of field called "delta time" which I only had to multiply to all the values to make them framerate independant.
I understood the logic between that and I'd like to continue working with delta time values. But as I couldn't find something like that in MonoGame I made some kind of workaround myself. Here's what I did:
protected override void Update (GameTime gameTime) {
deltaTime = gameTime.ElapsedGameTime;
float delta = deltaTime.Milliseconds;
delta = delta / 1000;
//(...)
//And now I can use delta to apply movement like this:
position.X += SpeedX*delta;
}
Is that a good workaround? Does it have any overhead I might be overlooking at? Is there a pre-built value for what I'm looking for?
Thank you very much
No comments:
Post a Comment