# Player Movement

I started developing games recently, teaching myself using a german book about C++ and Direct3D 9.

The author states, player movement should be implemented using a time delta, like this

player.position.x += time.delta * movementFactor


as opposed to an implementation without incorporating the time passed since last frame; i.e like this

player.position.x += movementFactor


Latter solution would cause other players to move faster, since the expression above would be executed more often on faster CPUs. (More explanation on Tayacan's answer below)

Is there any other solution to this problem?

Old, poorly phrased question I wrote when I was young:

I'm reading on a Book that's about Gamedevelopment with C++ and DirectX 9.

There is something that interrests me: It says that playermovements are increasing with the power of the CPU. Becouse a faster CPU will move the player with every frame ( better CPU = better FPS ) To bypass it, it says you have just to multiplicate time*movementfactor .

I'd like to know is there an another way to bypass it ?

• Do you mean player movement alone, or whole logic? You can fix your FPS (limit it so some max value) Nov 6, 2012 at 21:50
• It is an old question, but just want to mention based on Markus comment that limiting FPS with max value won't fix this. You will still have a difference if FPS drop for a player, it will move slower. A good solution is to use the delta time. Nov 12, 2021 at 11:48

The problem is this: In (most) games you have a main loop. This loop runs as fast as the hardware allows. However, people use different hardware, so on some computers, this will be faster than on others. So in order to make an object in a game move with the same speed on any hardware, you multiply the movement vector with the time, in seconds, since last time the loop was run. This also has the benefit that if you're moving the object, say, 5 * time units in some direction, that's the same as saying "move it 5 units/seconds".