Thread: same speed on all machines

  1. #1
    muttski
    Guest

    same speed on all machines

    How???

  2. #2
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Base it on time, thats the only way I can think of.

  3. #3
    Registered User dirkduck's Avatar
    Join Date
    Aug 2001
    Posts
    428
    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.

  4. #4
    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.

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    Another way is to just wait for a number of milliseconds
    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.

    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.

    long mils;
    loop->
    mils=0; // Updated with the clock.
    game code;
    while(mils > const_num_you_like)
    {
    do nothing but update mils.
    }
    draw_frame();
    <-loop

    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.

    -Justin
    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/

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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?

  7. #7
    Registered User dirkduck's Avatar
    Join Date
    Aug 2001
    Posts
    428
    Bubba - ive never heard of that kind, maybe theres two different things called tweening or something.

  8. #8
    Registered User Coder's Avatar
    Join Date
    Aug 2001
    Location
    Cairo, Egypt
    Posts
    128
    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
    It's called vertex-tweening, as far as I know.

    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.
    Muhammad Haggag

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I am very new . . . :(
    By Eternalglory47 in forum C++ Programming
    Replies: 6
    Last Post: 09-05-2008, 11:29 AM
  2. Flight Simulator Wind Speed!!
    By Dilmerv in forum C++ Programming
    Replies: 6
    Last Post: 03-20-2006, 12:40 AM
  3. Replies: 6
    Last Post: 01-08-2006, 02:49 PM
  4. increased net speed
    By PING in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 03-29-2005, 07:05 AM
  5. Best way to show speed?
    By CompiledMonkey in forum C Programming
    Replies: 6
    Last Post: 11-17-2002, 04:42 PM