Frame Rate rants

shouzama

Freshman
Joined
Jan 20, 2003
Messages
38
Location
Another World
Ok, maybe it's a VERY STUPID question, but still I have some trouble figuring how to achieve a fixed framerate...

Let's suppose I write my own dx engine and finally managed to render a tile-based map.
Now I'd like to place my "main character" on this map (rendered for simplicity's sake with the Sprite object).
When my char moves, it should animate. I can very simply change the "drawing frame" of my character everytime I do a BeginScene.
However, running on a fast computer this should result in a faster-than-light animation, when on a slow machine it can be painfully sloooooooooow.

What I am asking in this useless rant is some hint, link or pseudo code (I use VB.NET, but my problem is more a "conceptual" one than a "code-syntax" one) on how to handle a "fixed frame rate" animation or something similar.

Thanks anyone!
 
Firstly, I'd like to point out that I have never done this, or anything remotely like it, so I could be way off base.

Is it possible to choose which frame from the animation based upon the system clock (or some other timer)? That way, no matter how fast the frame rate is the animation will be fixed.
 
Direct3D is incredibly fast if you do things right, if you post the rendering code someone can see if anything is wrong
 
TechnoTone said:
Is it possible to choose which frame from the animation based upon the system clock (or some other timer)? That way, no matter how fast the frame rate is the animation will be fixed. [/B]

Yes, that was the first thing I thought about.
However, I cannot figure not even pseudo-code based on a "timer-sync". :(

For instance, if I want to move the character from one tile to another, I'll need to sync BOTH the animation AND the position of the character on the screen.
I don't know, it's a lot of work, and I think the solution is REALLY simple...

Originally posted by AndreRyan
Direct3D is incredibly fast if you do things right, if you post the rendering code someone can see if anything is wrong

I don't have any rendering code. :) It's more a "conceptual" problem than a "technical" one...
 
Thanks!

Thanks Mutant, that's quite exactly what I was looking for!
I suggest everyone has my own problem to read the thread linked above! :)

Oddly enogh, I figured also how to perform a sort of "frameskip" on lower-end machines. Simply achieved by skipping the entire "rendering" procedure if the machine is taking too much time.

[EDIT: Look at these links, they may prove useful]
http://www.visualbasicforum.com/showthread.php?t=88872
http://www.visualbasicforum.com/showthread.php?t=81033
http://members.xoom.virgilio.it/robydx/main.htm

The last one is Roberto Zero page, an Italian guy who wrote (and still writes) a LONG serie of tutorials on DX8 and DX9(managed).
Unfortunately the entire page is in Italian only (I'm Italian too, btw), but I think the source code can be VERY useful.
 
Last edited:
Back
Top