It's often simpler to have a fixed frame rate in a game. Then you don't have to multiply everything by a time factor. In this case, you do not have to lower the frame rate to the lowest value that all computers can handle. You can for example let the position updates run at 200Hz and update the graphics at the highest speed the computer can handle (which may be lower than 200Hz).
If the updates can easily run at a fixed speed on all hardware you want it to run on, this can work well. It is a good way to get consistent behaviour in physics simulations, and for simple games, updating at a much higher speed than needed for the graphics is not a problem.
On the other hand, if the position updates are complicated, you may not be able to run them at top speed, and you'll have to handle varying time deltas (as in your code). This is often more difficult. The "jumping around in case of lag" problem has a simple (but not perfect) solution: just put a cap on the time delta, so you'll never do calculations on a time delta bigger than say 50 ms.
I guess this part of the question would fit better at gamedev.stackexchange.com, where there probably already are discussions about it.
EDIT: Sure is, have a look at http://gamedev.stackexchange.com/questions/1589/fixed-time-step-vs-variable-time-step https://gamedev.stackexchange.com/questions/1589/fixed-time-step-vs-variable-time-step
It's often simpler to have a fixed frame rate in a game. Then you don't have to multiply everything by a time factor. In this case, you do not have to lower the frame rate to the lowest value that all computers can handle. You can for example let the position updates run at 200Hz and update the graphics at the highest speed the computer can handle (which may be lower than 200Hz).
If the updates can easily run at a fixed speed on all hardware you want it to run on, this can work well. It is a good way to get consistent behaviour in physics simulations, and for simple games, updating at a much higher speed than needed for the graphics is not a problem.
On the other hand, if the position updates are complicated, you may not be able to run them at top speed, and you'll have to handle varying time deltas (as in your code). This is often more difficult. The "jumping around in case of lag" problem has a simple (but not perfect) solution: just put a cap on the time delta, so you'll never do calculations on a time delta bigger than say 50 ms.
I guess this part of the question would fit better at gamedev.stackexchange.com, where there probably already are discussions about it.
EDIT: Sure is, have a look at http://gamedev.stackexchange.com/questions/1589/fixed-time-step-vs-variable-time-step
It's often simpler to have a fixed frame rate in a game. Then you don't have to multiply everything by a time factor. In this case, you do not have to lower the frame rate to the lowest value that all computers can handle. You can for example let the position updates run at 200Hz and update the graphics at the highest speed the computer can handle (which may be lower than 200Hz).
If the updates can easily run at a fixed speed on all hardware you want it to run on, this can work well. It is a good way to get consistent behaviour in physics simulations, and for simple games, updating at a much higher speed than needed for the graphics is not a problem.
On the other hand, if the position updates are complicated, you may not be able to run them at top speed, and you'll have to handle varying time deltas (as in your code). This is often more difficult. The "jumping around in case of lag" problem has a simple (but not perfect) solution: just put a cap on the time delta, so you'll never do calculations on a time delta bigger than say 50 ms.
I guess this part of the question would fit better at gamedev.stackexchange.com, where there probably already are discussions about it.
EDIT: Sure is, have a look at https://gamedev.stackexchange.com/questions/1589/fixed-time-step-vs-variable-time-step
It's often simpler to have a fixed frame rate in a game. Then you don't have to multiply everything by a time factor. In this case, you do not have to lower the frame rate to the lowest value that all computers can handle. You can for example let the position updates run at 200Hz and update the graphics at the highest speed the computer can handle (which may be lower than 200Hz).
If the updates can easily run at a fixed speed on all hardware you want it to run on, this can work well. It is a good way to get consistent behaviour in physics simulations, and for simple games, updating at a much higher speed than needed for the graphics is not a problem.
On the other hand, if the position updates are complicated, you may not be able to run them at top speed, and you'll have to handle varying time deltas (as in your code). This is often more difficult. The "jumping around in case of lag" problem has a simple (but not perfect) solution: just put a cap on the time delta, so you'll never do calculations on a time delta bigger than say 50 ms.
I guess this part of the question would fit better at gamedev.stackexchange.com, where there probably already are discussions about it.
EDIT: Sure is, have a look at http://gamedev.stackexchange.com/questions/1589/fixed-time-step-vs-variable-time-step
It's often simpler to have a fixed frame rate in a game. Then you don't have to multiply everything by a time factor. In this case, you do not have to lower the frame rate to the lowest value that all computers can handle. You can for example let the position updates run at 200Hz and update the graphics at the highest speed the computer can handle (which may be lower than 200Hz).
If the updates can easily run at a fixed speed on all hardware you want it to run on, this can work well. It is a good way to get consistent behaviour in physics simulations, and for simple games, updating at a much higher speed than needed for the graphics is not a problem.
On the other hand, if the position updates are complicated, you may not be able to run them at top speed, and you'll have to handle varying time deltas (as in your code). This is often more difficult. The "jumping around in case of lag" problem has a simple (but not perfect) solution: just put a cap on the time delta, so you'll never do calculations on a time delta bigger than say 50 ms.
I guess this part of the question would fit better at gamedev.stackexchange.com, where there probably already are discussions about it.
It's often simpler to have a fixed frame rate in a game. Then you don't have to multiply everything by a time factor. In this case, you do not have to lower the frame rate to the lowest value that all computers can handle. You can for example let the position updates run at 200Hz and update the graphics at the highest speed the computer can handle (which may be lower than 200Hz).
If the updates can easily run at a fixed speed on all hardware you want it to run on, this can work well. It is a good way to get consistent behaviour in physics simulations, and for simple games, updating at a much higher speed than needed for the graphics is not a problem.
On the other hand, if the position updates are complicated, you may not be able to run them at top speed, and you'll have to handle varying time deltas (as in your code). This is often more difficult. The "jumping around in case of lag" problem has a simple (but not perfect) solution: just put a cap on the time delta, so you'll never do calculations on a time delta bigger than say 50 ms.
I guess this part of the question would fit better at gamedev.stackexchange.com, where there probably already are discussions about it.
EDIT: Sure is, have a look at http://gamedev.stackexchange.com/questions/1589/fixed-time-step-vs-variable-time-step
It's often simpler to have a fixed frame rate in a game. Then you don't have to multiply everything by a time factor. In this case, you do not have to lower the frame rate to the lowest value that all computers can handle. You can for example let the position updates run at 200Hz and update the graphics at the highest speed the computer can handle (which may be lower than 200Hz).
If the updates can easily run at a fixed speed on all hardware you want it to run on, this can work well. It is a good way to get consistent behaviour in physics simulations, and for simple games, updating at a much higher speed than needed for the graphics is not a problem.
On the other hand, if the position updates are complicated, you may not be able to run them at top speed, and you'll have to handle varying time deltas (as in your code). This is often more difficult. The "jumping around in case of lag" problem has a simple (but not perfect) solution: just put a cap on the time delta, so you'll never do calculations on a time delta bigger than say 50 ms.
I guess this part of the question would fit better at gamedev.stackexchange.com, where there probably already are discussions about it.