Time Based Framework/Engine
I wanted to know the difference between frame and time based Game Engines..and how do i make a time based game engine..
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement