|
|
| FPS: how to calculate & limit |
|
Joseph lastname
Member #1,581
October 2001
|
Hey, I'm at the point now where my engine needs to have a constant FPS. I haven't used the allegro timer routines yet, and I'm not sure where to start with this... How do I set up a timer to calculate FPS, and then, how do I limit the FPS to a constant rate? ie: 30fps. Thanks |
|
23yrold3yrold
Member #1,134
March 2001
|
Click on the FAQ in my sig and look for "How can I make my game run at the same speed on any computer?" in the General section. Also click on Pixelate and look in issue 8 for a timer tutorial that might also help. -- |
|
Joseph lastname
Member #1,581
October 2001
|
OK, thanks... I got that working. but now I have another question: I want to be able to load the defualt FPS from a file. I already have a cfg file set up, but when I use a varible in BPS(), my program crashs. ie: load_cfg(); sys.fps is a part of a global type. and also, what varible holds the actual FPS? thanks |
|
SystemDown
Member #663
September 2000
|
Have you checked if the variable you're passing in is zero? the BPS_TO_TIMER() macro divides a long value by the number you give it, so a divide by zero error might be happening. To store the FPS, I have used this method before and it works fine for me (sorry about lack of comments, but I think it's pretty straightforward)
--- |
|
Joseph lastname
Member #1,581
October 2001
|
hmm.... It's not dividing by zero.. but it's still crashing.... I can't figure this out.. I got the FPS though... thanks.. |
|
Johnny13
Member #805
October 2000
|
Why need a defualt FPS? and load from file?::) Alg3D Praise my Games!!<code>#define SPAMMER (post>=666&&postperday>=6)</code><Mr.spellcaster>What post? <Mr.spellcaster>A useful post by me. |
|
|