This is a discussion on same speed on all machines within the Game Programming forums, part of the General Programming Boards category; How???...
There is a method called tweening, which is kind of complicated...id look it up. Basically it updates the user input part of the program and everything except rendering every number of milliseconds, then, based on how fast the computer is will only render after a certain number of updates, to make the game stay the same speed with different framewrates. Another way is to just wait for a number of milliseconds after each loop, so it basicly limits the framerate from getting too high.
Or make an ugly, inaccurate, menu determining your comp speed.
One thing wrong with this method is it is very inaccurate
Another is, people will laugh at you for a long time.
This actually works quite well if the typical machine is vastly overpowering your game. In this case, they all run at equal speeds. However, if there is a chance the game will run on older hardware, then this will really kill it on many systems that would otherwise have managed OK.Another way is to just wait for a number of milliseconds
The other way dirkduck was referring to is a fair bit more complex, but if you can hammer out the logic once, then it is easily reusable and really quite professional. A slightly less sophisticated but easier to implement approach would be to set up your timing and delay if the frame rate is too high.
mils=0; // Updated with the clock.
while(mils > const_num_you_like)
do nothing but update mils.
That takes care of things pretty nicely. The only disadvantage is that you aren't doing anything in the do_nothing loop at the end, but you could add anything useful there that you like.
Last edited by Justin W; 03-16-2002 at 09:38 AM.
Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/
Last I saw tweening was the process of moving vertexes or linear interpolating between two vertexes to produce animation. The DirectX 8 SDK example is that of a dolphin moving up and down.
Are you sure you are not talking about keyframing or something else?
Bubba - ive never heard of that kind, maybe theres two different things called tweening or something.
It's called vertex-tweening, as far as I know.Last I saw tweening was the process of moving vertexes or linear interpolating between two vertexes to produce animation. The DirectX 8 SDK example is that of a dolphin moving up and down
So did you get MSVC? or you're using Borland's? ( Don't tell me you just downloaded the SDK without having the compiler )
There's an article on gamedev.net about frame-rate independent movement, it uses the following :
Assuming the player needs to move 10 units per second ( a unit can be a metre, a kilometre, whatever ) :
In the middle of the Update() function that updates your application's state
LastFrameTime is the time the Update() function was last called
FrameTime = TheTimeRightNow - LastFrameTime;
This is the time taken by each frame ( we're assuming constant frame rate, which isn't true, but it simplifies things )
FrameRate = 1/FrameTime ( This is the instantaneous frame rate )
If FrameRate is 60, for example, then we need to move 10/60 units per frame in order to move 10 units per second.
That means : we always move by UnitsPerSecond/FrameRate which is exactly equivalent to UnitsPerSecond * FrameTime
Last edited by Coder; 03-20-2002 at 11:36 PM.