Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • GameLoop

Index

Constructors

constructor

  • new GameLoop(websocketServerUrl: string, fpsDivName: string, changeResolutionCallback: any, gameHUD: GameHUD, windowMock?: any): GameLoop
  • Constructs a new game loop.

    Parameters

    • websocketServerUrl: string

      URL of the {@link WebSocket}

    • fpsDivName: string

      HTML ID as string where we put how much FPS we got

    • changeResolutionCallback: any

      Callback function ({@link deltaResolution}) to change the raycaster resolution

    • gameHUD: GameHUD

      GameHUD instance.

    • Optional windowMock: any

      Mocked {@link window} instance for tests.

    Returns GameLoop

Properties

Private callback

callback: any

Function callback that implements what happens each frame function(time, packetArray, sendCallback)

Private changeResolutionCallback

changeResolutionCallback: any

Callback to resolution change method located in the Renderer class. Has form function(deltaResolution), so by how much we change the resolution.

Private fpsElem

fpsElem: HTMLElement

Where we .innerText put how much FPS we achieved

Private frameSum

frameSum: number

Counter to keep track of how many frames we achieved in the last second.

Private gameHudReference

gameHudReference: GameHUD

A reference to the gamehud

Private lastTime

lastTime: number

Last frame time in seconds

Private resolutionAdjustCounter

resolutionAdjustCounter: number

Counts of dynamic resolution.

Private secSum

secSum: number

Timer sum to eventually check if a second has passed.

Private socket

socket: Socket

For server communication

Static Private Readonly DYNAMIC_RESOLUTION_AGGRESSIVENESS

DYNAMIC_RESOLUTION_AGGRESSIVENESS: 10 = 10

How aggressive the dynamic resolution iteration is. Ideally between 5 and 20. The higher, the faster the resolution gets turned.

Static Private Readonly FPS_GOAL

FPS_GOAL: number = 50

FPS goal ideally met. If below, resolution gets toned down. By resolution we mean bar subdivision of walls rendered on-screen.

Static Private Readonly FPS_MINIMUM

FPS_MINIMUM: number = 30

Minimum FPS threshold. If the framerate dips below that, dynamic resolution iteration gets triggered.

Static Private Readonly MAXIMUM_RESOLUTION_ADJUST

MAXIMUM_RESOLUTION_ADJUST: 10 = 10

Maximum amount of resolution iteration steps and seconds until an ideal resolution was found.

Accessors

getSocket

getSocketState

Methods

begin

  • begin(callb: any): void
  • Set callback function that gets called each frame.

    Parameters

    • callb: any

      Callback function(time, packetArray, sendCallback)

    Returns void

Private dynamicResolution

  • dynamicResolution(): void
  • Triggers dynamic resolution negotiation between game and browser / machine.

    Returns void

frame

  • frame(currTime: number): void
  • Handling of each frame.

    Parameters

    • currTime: number

      Current time.

    Returns void

overrrideSocket

  • overrrideSocket(socket: Socket): void

Private requestFrame

  • requestFrame(): void

restartDynamicResolution

  • restartDynamicResolution(): void

Generated using TypeDoc