how do you make a games speed not rely on fps?

Discussion in 'Computer Programming, Emulation, and Game Modding' started by Nyap, Jul 8, 2016.

  1. Nyap
    OP

    Nyap HTML Noob

    Banned
    973
    344
    Jan 13, 2016
    That Chaos Site
    so if you did this (pseudocode)
    Code:
    int main()
    {
        while (inGame)
        {
            render stuff etc
        }
    }
    the game would be blazing fast at 200fps and slow-motion in 20fps. How do modern games remedy this?
     
    Last edited by Nyap, Jul 8, 2016
  2. Tom Bombadildo

    Tom Bombadildo Honk!

    pip Contributor
    GBAtemp Patron
    Tom Bombadildo is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    10,555
    10,493
    Jul 11, 2009
    United States
    I forgot
    Most modern games use what's basically called a time step. Instead of having things like physics or game speed run based on the amount of frames someone's hardware can render, they use equations to limit actions performed in the game to a specific interval. This allows the game to run at whatever fps hardware can handle while keeping things like physics or in-game speed at a stable speed instead of increasing/decreasing. I suggest googling around about it for more in-depth information.

    That's usually the preferred way of doing things in modern games, however there are some that instead will just limit the amount of FPS a game can render instead. Fallout 4 is one of the most recent examples I can think of, Bethesda made the game's speed tied to framerate and just capped the framerate. If you do a little modding and unlock the framerate to, say, 144fps, in-game actions would happen twice as fast; you run faster, objects fall quicker, etc.
     
    Nyap likes this.