Interface ILoop

All Superinterfaces:
ILaunchable
All Known Subinterfaces:
IGameLoop
All Known Implementing Classes:
GameLoop, UpdateLoop

public interface ILoop extends ILaunchable
The ILoop interface provide method for game loops that are publicly exposed.

A loop is an implementation that performs actions (e.g. physics, rendering, input processing, ...) and updates other IUpdatable instances while the game is running.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    attach(IUpdateable updatable)
    Attaches the update method of the specified IUpdatable instance to be called every tick.
    void
    detach(IUpdateable updatable)
    Detaches the specified instance from the game loop.
    long
    Gets the total time in milliseconds that passed since the last tick.
    Returns a lock that can be used for actions that must be performed either within or independently of the loop.
    double
    Gets the actual process time in milliseconds that was required during the last tick.
    int
    Gets the rate at which this loop performs its updates.
    long
    Gets the total amount of ticks performed by this loop since it was started.
    int
    Gets the amount of attached IUpdatable instances of this loop.
    void
    setTickRate(int tickRate)
    Sets the tickrate at which the loop performs its updates.

    Methods inherited from interface de.gurkenlabs.litiengine.ILaunchable

    start, terminate
  • Method Details

    • attach

      void attach(IUpdateable updatable)
      Attaches the update method of the specified IUpdatable instance to be called every tick. The tick rate can be configured in the client configuration and is independent from rendering.
      Parameters:
      updatable - The instance that will be registered for the update event.
    • detach

      void detach(IUpdateable updatable)
      Detaches the specified instance from the game loop.
      Parameters:
      updatable - The instance that will be unregistered for the update event.
    • getUpdatableCount

      int getUpdatableCount()
      Gets the amount of attached IUpdatable instances of this loop.
      Returns:
      The amount instances attached to this loop.
    • getTicks

      long getTicks()
      Gets the total amount of ticks performed by this loop since it was started.
      Returns:
      The total amount of elapsed ticks.
      See Also:
    • getTickRate

      int getTickRate()
      Gets the rate at which this loop performs its updates.
      Returns:
      The update rate in ticks per second.
    • getDeltaTime

      long getDeltaTime()
      Gets the total time in milliseconds that passed since the last tick.
      i.e. process time + delay (to enforce the tick rate of this loop)
      Returns:
      The delta time in ms.
      See Also:
    • getProcessTime

      double getProcessTime()
      Gets the actual process time in milliseconds that was required during the last tick.
      i.e. delta time - delay
      Returns:
      The actual process time of the last tick in ms.
      See Also:
    • getLock

      Lock getLock()
      Returns a lock that can be used for actions that must be performed either within or independently of the loop.
      Returns:
      A Lock for this loop.
    • setTickRate

      void setTickRate(int tickRate)
      Sets the tickrate at which the loop performs its updates.
      Parameters:
      tickRate - The tickrate of the loop.