You may have noticed that your game runs faster or slower than what's being displayed within the course's videos. This is due to differences within a monitors refresh rate.
Monitors refresh their screen at a particular rate so we can see smooth, interpolated movement as we type, move our mouse, or watch a video. Depending on how fast this refresh rate is, your mouse movement (or game in this case) will seem either choppy or very smooth. The higher a refresh rate, the smoother your game will be.
Most monitors in the world run at a rate of 60hz as of the time of this post, but there are a few out there that run at 120hz or even 30hz. As a result, monitors that run our game at 120hz will make our game seem super fast, while monitors that run at 30hz will make our game seem snail-speed slow.
We want to fix this!
To fix this issue, we will use what's commonly known in the game industry as "delta time." Delta time is the amount of time that has passed since two consecutive frames were rendered. It's typically a very small value like .009
but the smaller your monitor's refresh rate, the larger this value will be.
Using this value, we can assign dynamic velocities to our player's movement that'll ensure they move at the correct rate no matter the refresh rate of a user's monitor.
Here I'll go over that in-depth so you can see how to implement this effect correctly into your game.