How do game developers make games run at a certain speed when they have to run on different hardware?

266 views

I’m guessing modern frameworks have this built-in so developers don’t really have to worry so much, but how is it achieved? For example, if I want a character to move at a certain pace no matter what hardware is running, or how much is happening on the screen at the time, how does the code control that?

In: 2

4 Answers

Anonymous 0 Comments

We use a variable named delta. Which is the calculation of how long it took the frame to render. Most of the time it’s 1/60 of a second. We use that in everything movement based. So if your character is moving at 100 pixels a frame but your frame rate is only 1/24 so you multiply your movement by that. The formula normally looks like

Velocity = speed * input _vector * delta

In this speed is what you set your movement speed at. Input vector is what the player is pressing. This is between (-1,-1) and (1,1) and delta again is how long the frame took normally a value of 0.016 but does vary like if you were running at 24 fps your delta would be 0.0416

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