VISU - PHP Game Framework

GameLoop
in package

Table of Contents

Properties

$frameTimeSampleCount  : int
The amount of samples that are collected to determine the average frametime.
$tickCountSampleCount  : int
The amount of samples that are collected to determine the average tick count.
$tickTimeSampleCount  : int
The amount of samples that are collected to determine the average tick time.
$delegate  : GameLoopDelegate
$forceStop  : bool
If set to true, the game loop will force stop, even if the delegate doesn't want to.
$frameTimeSamples  : array<string|int, int>
An array of the last few frametiems in nanoseconds.
$maxUpdatesPerFrame  : int
The maximum amount of updates that can be executed, before a render call is forced.
$targetTickRate  : float
The targeted amount of game update ticks per second of the game loop.
$tickCountSamples  : array<string|int, int>
An array of the last tick count per frame to calculate the average tick count.
$tickTimeSamples  : array<string|int, int>
An array of tick time samples in nanoseconds.
$timestepNs  : int
The timestep in nanoseconds of a single game update tick.

Methods

__construct()  : void
Constructor
forceStop()  : void
Force stops the game loop.
getAverageFps()  : float
Returns the average frames per second.
getAverageFrameTime()  : float
Returns the average frametime in nanoseconds.
getAverageFrameTimeFormatted()  : string
Returns the average frametime in a human readable format.
getAverageTickCount()  : float
Returns the average tick count per frame.
getAverageTickTime()  : float
Returns the average tick time in nanoseconds.
getAverageTickTimeFormatted()  : string
Returns the average tick time in a human readable format.
getMaxUpdatesPerFrame()  : int
Returns the maximum amount of updates that can be executed, before a render call is forced.
getTargetTickRate()  : float
Returns the target tick rate of the game loop.
getTimestepNs()  : int
Returns the timestep in nanoseconds of a single game update tick.
start()  : void
Starts and runs the game loop
formatNStoHuman()  : string

Properties

$frameTimeSampleCount

The amount of samples that are collected to determine the average frametime.

public int $frameTimeSampleCount = 32

$tickCountSampleCount

The amount of samples that are collected to determine the average tick count.

public int $tickCountSampleCount = 32

$tickTimeSampleCount

The amount of samples that are collected to determine the average tick time.

public int $tickTimeSampleCount = 60

$forceStop

If set to true, the game loop will force stop, even if the delegate doesn't want to.

private bool $forceStop = false

$frameTimeSamples

An array of the last few frametiems in nanoseconds.

private array<string|int, int> $frameTimeSamples = []

This is used to calculate the average frametime.

$maxUpdatesPerFrame

The maximum amount of updates that can be executed, before a render call is forced.

private int $maxUpdatesPerFrame

$targetTickRate

The targeted amount of game update ticks per second of the game loop.

private float $targetTickRate

$tickCountSamples

An array of the last tick count per frame to calculate the average tick count.

private array<string|int, int> $tickCountSamples = []

$tickTimeSamples

An array of tick time samples in nanoseconds.

private array<string|int, int> $tickTimeSamples = []

This represents the time it took to execute a single game update tick.

$timestepNs

The timestep in nanoseconds of a single game update tick.

private int $timestepNs

Methods

__construct()

Constructor

public __construct(GameLoopDelegate $delegate[, float $targetTickRate = 60.0 ][, int $maxUpdatesPerFrame = 10 ]) : void
Parameters
$delegate : GameLoopDelegate

The game loop delegate to handle update, draw etc.

$targetTickRate : float = 60.0

The targeted amount of game update ticks of the game loop.

$maxUpdatesPerFrame : int = 10

The maximum amount of updates that can be executed, before a render call is forced.

forceStop()

Force stops the game loop.

public forceStop() : void

getAverageFps()

Returns the average frames per second.

public getAverageFps() : float
Return values
float

getAverageFrameTime()

Returns the average frametime in nanoseconds.

public getAverageFrameTime() : float
Return values
float

getAverageFrameTimeFormatted()

Returns the average frametime in a human readable format.

public getAverageFrameTimeFormatted() : string
Return values
string

getAverageTickCount()

Returns the average tick count per frame.

public getAverageTickCount() : float
Return values
float

getAverageTickTime()

Returns the average tick time in nanoseconds.

public getAverageTickTime() : float

This represents the time it took to execute a single game update tick.

Return values
float

getAverageTickTimeFormatted()

Returns the average tick time in a human readable format.

public getAverageTickTimeFormatted() : string
Return values
string

getMaxUpdatesPerFrame()

Returns the maximum amount of updates that can be executed, before a render call is forced.

public getMaxUpdatesPerFrame() : int
Return values
int

getTargetTickRate()

Returns the target tick rate of the game loop.

public getTargetTickRate() : float
Return values
float

getTimestepNs()

Returns the timestep in nanoseconds of a single game update tick.

public getTimestepNs() : int
Return values
int

start()

Starts and runs the game loop

public start() : void

formatNStoHuman()

private formatNStoHuman(int $ns) : string
Parameters
$ns : int
Return values
string

        
On this page

Search results