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 is a separate component that tracks time independent of clock cycles. So you can track the time that passes since the last “Update” and perform logic accordingly. For example, in a game you might have movement speed in units/second, so you multiply the seconds that passed since last update * movement speed to get the displacement.

Anonymous 0 Comments

There was an older game we used to play called Warlords II. I tried booting it up on a modern PC a few years ago and since they were just using the computer clock as a timer, the enemy turns that you used to see what they were doing and strategize went past in the blink of an eye.
So it’s definitely something that’s planned for on newer games that older games didn’t always take into account.

Anonymous 0 Comments

I remember back in the 90’s learning BASIC, we’d program a simple clock -getting timing right on the second hand partly by trial and error.

We were using 486’s, I think dx2 and dx 4 versions.

We then got Pentium 75’s and they were much faster and made the clocks (and other projects) run much faster and we didn’t have any base line data to start from.

Was interesting seeing the benefit of tech advancement first hand (or second hand, if you will – hahahaha).

Anonymous 0 Comments

Computers have a clock that, surprise, measures time. Older games often didn’t implement time checks and used to run as fast as the cpu could cycle. Nowadays, every frame is rendered against a ‘delta’ variable that’s basically the time difference from the previous one

Anonymous 0 Comments

If the original was like asking a group of little kids to draw as fast as they can and they can make one picture every minute, and everybody is about that speed. Then fast forward to a few years later. The fast ones can draw a picture every ten seconds and some take thirty seconds. So instead, you ring a bell every minute and collect whatever they have then.

A long time ago there was that problem. Computers were not very fast or powerful, so programmers skipped the logic that controls the speed because it was extra work for the processor and they couldn’t spare it. And there weren’t as many possible combinations for computer speed, no variations like today a processor might come in multiple speeds. So a game would be tuned to run at the right speed for a given computer because that was the only one. The https://en.wikipedia.org/wiki/Turbo_button was used to force a computer to match the original.

> With the introduction of CPUs which ran faster than the original 4.77 MHz Intel 8088 used in the IBM Personal Computer, programs which relied on the CPU’s frequency for timing were executing faster than intended. Games in particular were often rendered unplayable, due to the reduced time allowed to react to the faster game events. To restore compatibility, the “turbo” button was added.[4] Disengaging turbo mode slows the system down to a state compatible with original 8086/8088 chips.

Once it was clear that that timing shortcut was not workable anymore because of the variation in processors (e.g. you could buy any of multiple i486 models https://en.wikipedia.org/wiki/I486#Models in different speeds) programmers started using a clock. Roughly calculate everything and when the clock hits whatever time, send that to the screen.

This was all before multi-tasking really hit consumer computers.

Anonymous 0 Comments

They have a clock in them, so in game code you can just wait for specific amounts of time.

For old systems that don’t have clocks in them, the processors would run at a known fixed rate, so you would write your program knowing how many processor cycles have passed at any given point, and thus, know the time.

Anonymous 0 Comments

Games do run as fast as the hardware will allow. This is called the “frame rate”

The game engine calculates the time between frame renderings and uses that time to determine how much moving objects should move. Any given moving object will move twice as much per frame at 5 fps compared to 10 fps so that in 1 second the object will have moved the same distance regardless of the frame rate

Fun fact- this can often be exploited to “clip” through walls, if you reduce the frame rate enough the moving objects (like the player character) will move more than the objects width per frame, which might end up on the other side of a wall, bypassing collision checks between the wall and the moving object. This is basically quantum tunnelling in video games

Anonymous 0 Comments

This could be a problem in the past. A game called Grim Fandango had a puzzle you had to complete in an elevator before it reached the ground. Elevator speed was linked to the speed of your processor and left it impossible for me to do back in the day.

Anonymous 0 Comments

Answer: computers follow instructions regardless of their techno-horsepower. An internal clock is running, and the instruction set dictates the pace of play. Many old emulators come with ‘hyperspeed’ or whatever they wanna call it, but it plays the instructions at 2x, 3x, or even 4x speed. It’s not the processing power that determines the speed, it’s the instructions (which are often set to an internal clock)

Anonymous 0 Comments

The computer does things as fast as it can. However, for a video or a game, it might be too fast or too slow.

For video, there are time markings in the stream/file that tell it when to play a frame of video. Sometimes you’ll see a video fast forward to catch up. That’s because our brains are too smart and when we watch a video, our brains would prefer to just skip stuff as long as the time make sense, versus stopping and then starting. For instance, if you are playing a song on the piano or guitar or whatever, and you screw up … it’s much better to carry on and NOT stop and play the part you screwed up.

For video games, it’s similar in that real time-ish games must be played at a reasonable human speed. So games time when things happen. In some games, that doesn’t matter, like if you are playing chess, you want the computer to play as fast as possible and then get back to your turn.

Here’s a fun example of a game not timing properly. Back in the 80s/90s there was an awesome video game series called “Wing Commander” which was a space fighter-pilot sim. At the time, the game needed everything your computer could give it. At the time, computer models were well known. Like a Commodore 64 ran at a certain clock rate. An IBM PC ran at like 8 Mhz so at that clock speed, the game played at a pretty decent speed. As computers got faster, especailly IBM PCs and clones…the code just simply ran faster and faster. Not only the clock rate, but the CPUs did things faster per clock tick.

So try running Wing Commander today with a DOS emulator. It’s hilarious. It was meant to run at 8 Mhz (roughly 8,000,000 instructions per second), and todays computers are typically around 3,500 Mhz, but pipeline more so it’s more like effectively 8,000 Mhz. So try running Wing Commander at 1000x speed. LOL. So to make it useable the DOS Emulator actually has to waste cpu cycles doing nothing.

So that brings us back to modern games and computers. You CAN’T run a game at full speed because everyone has a different computer, and therefore the speeds are all different.

Now what you CAN do with your extra computing power (and graphics computing power) is … allow the computer to add fancy effects, or run at higher resolutions. When you turn on the “extras” you WILL tax your hardware to the max.

However, the most important thing for modern computer games is how smoothly they play, and less so how pretty they look.