I'm trying to make a Super Mario World kind of copy myself in C# using the game library AGATELib (http://agatelib.org/). The thing is that it's FPS is changing between like 200 to 1000, but I want to have the animation speed to be constant(different between each block in this case) and the code I currently have updates the animation for example once every 10 frames, and if the fps change, the animation speed does too.
I'm not very experienced with making games like this and need help with it. Basically I need some kind of equation or something that makes me able to have the same animation speed.
This is the animation update method that all blocks use: ShowHide Variables are:
private Sprite sprite;
private double animationSpeed;
private double frames = 0;
public void MainUpdate()
{
if (frames > animationSpeed)
{
sprite.AdvanceFrame();
frames = 0;
}
frames++;
}
What can I do to make this work?
Regards
Stripe103
You should be able to access how much time has passed since the last frame has been rendered. Check their API reference. Multiply that time with your animation speed and your animations should have a constant speed regardless of frame rate.
Seems to have worked. I tried with the DeltaTime before, but I put it in the wrong place.
Anyway, I'll send you a PM or something if it don't work as it should, but for now, Thank you!