Time Based Framework/Engine

Started by
1 comment, last by Captain P 13 years, 6 months ago
I wanted to know the difference between frame and time based Game Engines..and how do i make a time based game engine..
Advertisement
Assuming definitions something like -

frame-based: "executing code dependent on the number of frames"

time-based: "executing code dependent on the current time"

A frame-based system executes code each frame, regardless of when the last frame was rendered. A time-based system executes code depending on how much time has elapsed since the last frame was rendered.

For instance, a frame-based system would move a character the same amount each frame - position += delta_move;

A time-based system would move a character an amount that's dependent on the time that has elapsed - position += speed*delta_time.

Problems occur when a frame-based application is run on a faster or slower machine. I.e., the player will move faster or slower just because the frames are being rendered at a different rate.

To make the application run on machines with different speeds, either control the frame rate, or update positions, rotations, etc., based on time elapsed since the last frame.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Time-based systems aren't always as simple as just factoring in a time delta. Fix your Timestep! is a good article that deals with some of the more subtle issues you may encounter. It's possible that you don't need that kind of reliability, but it's still good to know.

At the very least, cap your time delta to sane values - you don't want things flying through the roof (or falling through the floor) if a frame happens to take a couple of seconds due to who-knows-what.
Create-ivity - a game development blog Mouseover for more information.

This topic is closed to new replies.

Advertisement