1. Better way to time a game?

Ok, currently, I'm using a method to keep track of the clock ticks, each
tick is one frame. If the frame goes over one tick, then that frame takes up
two ticks, and the game slows down. Speeding up tick_rate() to 30 would mean
30 frames per second, and the game would run about twice as fast.

What I want to do now is, either let the game run as many frames per second
as allowed, but still run at the same speed. (This is what all the new games
do.) If the game slows down, less frames are drawn, but 3 seconds of game
time is still 3 seconds in the game. smile

I know of one game that does that, but once the framerate hits about 250,
the game breaks and the physics go all screwy. If there has to be a limit,
then maybe another method would be to set the max framerate to 60 (60 and 72
are common monitor refresh speeds, and you won't notice a difference if the
framerate is above the monitor refresh.)

Also, what I need is collision detection that doesn't skip if the framerate
drops. Ie, if you fire, and then the framerate drops to 3, and that causes
your shot to skip over the enemy, that's bad. (Because each frame the shot
is drawn further apart from the last frame than at higher framerates.) I've
seen in the same game above (Descent 2), where a framerate drop doesn't
cause collision detection problems.

I'm hoping to use this to make a space combat game that uses Newtonian
physics, so there isn't any maximum speed. So when things get real fast, I
don't want everything jumping around strangely, I want the shots to hit.

Any ideas? I'd rather get information on how to do it than straight code, so
I understand what I am doing. But both at once would be more appreciated.
smile I have the Descent 1 source code, but it's in C. With it, I may be able
to do what I want, but it'll probably mean the end result is in C, not
Euphoria.

PS. Ralf, I was wondering why you were referring to Euphoria's way of doing
things as a bloodsucking parasite. blink 'Leash' makes much more sense. And
Obi-Wan Kenobi is a reference to the Star Wars movies. (Although IMO Jiri
would be more like Darth Vader: If he's smiling, you wouldn't know, and as
Luke said: "There is good in him, I can feel it." smile [Jiri, that's supposed
to be a compliment, I know you may not want to accept that you can smile and
that there is good in you, but it's true. blink ]) Oh, and I didn't get any
private e-mails from you, Ralf... :/

new topic     » topic index » view message » categorize

2. Re: Better way to time a game?

If you are hooked into interrupt 1cH which is a hardware interrupt that
that automatically occurs 18.2 times per second you can't change that.

There may be away to use the PC 8253 programmable timer. This generates
1,193,180 impulse a second. This is timer used for making tones in the
speaker.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu