geronimo
|
I am rewriting a classic SNES game and it is very important that it go through the main loop as close as possible to once every 1/60 second. Currently I have it going at 50fps by using:
delay=systemtime+2;
the main loop stuff, then
while(systemtime<delay) ShowPage();
It will do if it's the best I can get out of V3 (I'm not giving up on V3 for any reason, not for this beaut ^^), but I fear it will make single-frame maneuvers quite easier than they should be (and the game is tightly built around the one iteration every 60th of a second concept so I can't really use any cheap tricks). What are my options?
Posted on 2004-04-16 15:41:41
|
vecna
|
Augh. Great question. I've been meaning to write a mini tutorial/article on timing code as, for whatever reason, this seems to be something that a lot of VC coders have a lot of trouble with, and it really is quite important in VERGE because, as a 'retrogaming' platform, the users really tend to vary between people with 3+ghz machines, and people running on 500mhz celerons, so there is an enormous gap in processing power on the machines that will ultimately end up running VERGE games.
But you seem to have a pretty good grasp on timing in general, this is a more advanced question. First of all, I tend to discourage that type of thinking because there is simply no way you can ever guarantee 60fps; you can cap to 60fps, but the fps could always drop, and if your game logic demands 1tick/frame, then the game will simply run literally slower for people with slower computers. Additionally, because V3's assorted graphics routines vary from quite speedy to rather slow, the framerate can vary on a given machine a lot with a 1-tick/1frame paradigm. Consoles did the same thing, the 'slowdown' you encountered with shooters and such; but at least on a console, the speed of the machine was always fixed and you could test your game to make sure the slowdown was bearable.
So, all that said, I discourage 'fixed framerate' thinking, but I also recognize that sometimes the advantages outweigh the disadvantages.
The only real solution I can offer with the current VERGE is that you could use fixed-point math to give you 60fps, however, since it would be fixed-point integer math with a root timer of 100hz, the frames would have inconsistent duration.
Honestly that would probably be acceptable, and I can give you specific code to do that if you want, but I suspect what you're getting at, and since you're not the first person to ask about this, I CAN add something like, a verge.cfg option, that would let you specify the root timer rate. I can add in code to adjust the entity thinking so that the entity speed remains pixels-per-second, however, vc code timing adjustments would be up to the VC programmer. Then you could set it to 60 and it'd be a pretty easy fix. I can probably do that for this weekend's upcoming build.
... Hi, my name's Tycho, and I like words.
Posted on 2004-04-16 21:48:40
|
mcgrue
|
It was intended for the weekend. vecna, however, decided that heroin was more important than coding he wanted to pay bills and clean his apartment instead.
The build should be soon. Don't worry, I've been harassing him about it.
Posted on 2004-04-21 06:32:38
|