Package de.gurkenlabs.litiengine
Interface ILoop
- All Superinterfaces:
ILaunchable
- All Known Subinterfaces:
IGameLoop
- All Known Implementing Classes:
GameLoop,UpdateLoop
public interface ILoop
extends ILaunchableThe
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:
IUpdateable
Method Summary
Modifier and Type Method Description voidattach(IUpdateable updatable)Attaches the update method of the specified IUpdatable instance to be called every tick.voiddetach(IUpdateable updatable)Detaches the specified instance from the game loop.longgetDeltaTime()Gets the total time in milliseconds that passed since the last tick.java.util.concurrent.locks.LockgetLock()Returns a lock that can be used for actions that must be performed either within or independently of the loop.doublegetProcessTime()Gets the actual process time in milliseconds that was required during the last tick.intgetTickRate()Gets the rate at which this loop performs its updates.longgetTicks()Gets the total amount of ticks performed by this loop since it was started.intgetUpdatableCount()Gets the amount of attachedIUpdatableinstances of this loop.voidsetTickRate(int tickRate)Sets the tickrate at which the loop performs its updates.
Method Details
attach
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
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 attachedIUpdatableinstances 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:
ILaunchable.start()
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()
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:
getDeltaTime()
getLock
java.util.concurrent.locks.Lock getLock()Returns a lock that can be used for actions that must be performed either within or independently of the loop.- Returns:
- A
Lockfor this loop.
setTickRate
void setTickRate(int tickRate)Sets the tickrate at which the loop performs its updates.- Parameters:
tickRate- The tickrate of the loop.
