If a computer is powerful enough, how does it know not to play videos or perform logic for games at a faster speed?

1.15K views

I don’t know if I’m explaining this right…
A computer can run logic at some speed based on how powerful the components of it are, so if it can perform the logic of something, for example, movement in a game, how does it know how much should be done based on its power, instead of essentially running in “fast-forward” or conversely in slow motion?

In: 1307

40 Answers

Anonymous 0 Comments

There’s a thing called the game loop.

Every loop, it does all the logic for the game and drawing onto the screen.

Faster computers will call this loop quicker because they can, slower computers will call it slower.

If you look at how much time has passed since the last time the loop happened, you know how much to move things on the screen.

So if your character moves 60 steps per second and half a second has occurred since the last loop, you should move the character 30 steps (half of 60).

This will keep fast and slow computers running at the same speed.

You are viewing 1 out of 40 answers, click here to view all answers.