Skip to content
FutureBlitz

    Install

    Import std.time.timers

    FixedStep

    std.time.timers

    class

    Public Class FixedStep

    Steps at a fixed rate, however far apart the calls that ask for them are: Advance, or Tick, takes the time since the last call and gives how many steps to run, keeping what's left for the next, and Alpha says how far into the next step that is, for showing what's between two steps' states.

    Examples

    Local physics = FixedStep(10)
    Expect(physics.Advance(250.Milliseconds) == 2)
    Expect(physics.Alpha == 0.5)
    Expect(physics.Step == 100.Milliseconds)

    std/time/timers.fb, line 188

    • @PanicsAtCaller Public New(rate: Int) constructor #

      Steps at a rate of that many a second, which panics for one that isn't above 0.

    • @PanicsAtCaller Public New(step: Duration) constructor #

      Steps of that length, which panics for one that isn't above 0.

    • Public Property Step: Duration property #

      How long a step is, to the nearest nanosecond.

    • Public Property StepSeconds: Double property #

      How long a step is, in seconds.

    • @PanicsAtCaller Public Property MaxSteps: Int property #

      The most steps one call gives, 8 unless it's set, so a long wait doesn't make the next one longer still: the whole steps past them are dropped, and the part of a step left over stays. One below 1 panics.

    • Public Property Alpha: Double property #

      How far into the next step the time left over is, from 0 up to 1.

    • Public Method Advance(elapsed: Duration): Int method #

      How many steps to run for that much time. A Duration below 0 counts as 0.

    • Public Method Tick(): Int method #

      How many steps to run for the time since the last Tick, now or at the Instant; the first Tick starts the clock and gives 0.

    • Public Method Tick(now: Instant): Int method #

      How many steps to run for the time from the last Tick to now; the first Tick starts the clock and gives 0.

    • Public Method Reset() method #

      Forgets the time left over and the last Tick.

    Report an issue with this page or with FutureBlitz on GitHub.