Options
All
  • Public
  • Public/Protected
  • All
Menu
classdesc

Creates a DuckEngine Game

description

The Game Class. Stores many important methods and properties.

since

1.0.0-beta

Hierarchy

  • Game

Index

Constructors

constructor

Properties

animationFrame

animationFrame: undefined | number
memberof

Game

description

A reference to the animationFrame

since

1.0.0

browser

browser: string
memberof

Game

description

The browser being used

since

2.0.0

cacheManager

cacheManager: CacheManager
memberof

Game

description

A CacheManager instance

since

2.0.0

canvas

canvas: HTMLCanvasElement
memberof

Game

description

The Canvas that is used to render to

since

1.0.0-beta

Readonly config

memberof

Game

description

Game Configuration

since

1.0.0-beta

deltaTime

deltaTime: number
memberof

Game

description

The time since the last frame

since

1.0.0

deltaTimeArray

deltaTimeArray: number[]
memberof

Game

description

An array of the last 100 deltaTimes, deltaTime = time since last frame

since

2.0.0

displayManager

displayManager: DisplayManager
memberof

Game

description

A DisplayManager, manages the scaling of the canvas

since

2.0.0

eventEmitter

eventEmitter: EventEmitter
memberof

Game

description

An EventEmitter, used by many classes other than the Game class (also used by Game class)

since

2.0.0

fps

fps: number
memberof

Game

description

The current fps (Frames per second) that the Game loop is running at

since

2.0.0

isInFullscreen

isInFullscreen: boolean
memberof

Game

description

The state of being in fullscreen, determines if the game is in fullscreen or not, changing this value does nothing use game.fullscreen and game.unfullscreen to effect this value

since

1.0.0

isLoaded

isLoaded: boolean
memberof

Game

description

The state of the game, if it is currently loading

since

2.0.0

isRendering

isRendering: boolean
memberof

Game

description

The state of the game, if it is currently rendering

since

2.0.0

Protected now

now: number

Readonly oldHeight

oldHeight: number
memberof

Game

description

The width of the canvas that was set by the config, never changes, may not be current

since

2.1.0

Protected oldTime

oldTime: number

Readonly oldWidth

oldWidth: number
memberof

Game

description

The width of the canvas that was set by the config, never changes, may not be current

since

2.1.0

pluginManager

pluginManager: PluginManager
memberof

Game

description

A PluginManager, stores and manages plugins

since

2.0.0

renderer

renderer: CanvasRenderer
memberof

Game

description

The Renderer used to draw and clear frames

since

2.1.0

scenes

scenes: { add: any; remove: any }
memberof

Game

description

The scene manager, object that holds methods to add and remove scenes from the Game.stack

type{

add: (scenes: Scene[]) => void; remove: (scene: Scene) => void };

since

1.0.0-beta

Type declaration

smoothDeltaTime

smoothDeltaTime: number
memberof

Game

description

The time since the last frame averaged and smoothed out using Game.deltaTimeArray, applied to velocity of gameobjects

since

2.0.0

splashScreen

splashScreen: string
memberof

Game

description

The source to the splash screen image that is shown during loading

since

2.0.0

stack

stack: Stack
memberof

Game

description

The Game Stack, holds all Scenes, and the defaultScene key

since

1.0.0-beta

Methods

Protected drawSplashScreen

  • drawSplashScreen(): Promise<void>
  • memberof

    Game

    description

    Draws the splash screen to the canvas by setting the background image

    since

    2.0.0

    Returns Promise<void>

Protected hideSplashScreen

  • hideSplashScreen(): Promise<void>
  • memberof

    Game

    description

    Hides the splash screen to the canvas

    since

    2.0.0

    Returns Promise<void>

lockPointer

  • lockPointer(): void
  • memberof

    Game

    description

    Locks the pointer on the canvas

    emits

    EVENTS.GAME.LOCK_POINTER

    since

    1.0.0

    Returns void

Protected loop

  • loop(): void
  • memberof

    Game

    description

    Core loop

    since

    1.0.0-beta

    Returns void

setBackground

  • setBackground(background: string): void
  • memberof

    Game

    description

    Sets the style background color of the canvas

    emits

    EVENTS.GAME.SET_BACKGROUND

    since

    1.0.0-beta

    Parameters

    • background: string

      Background color

    Returns void

setScale

  • setScale(scale: Scale): void
  • memberof

    Game

    description

    Sets the scale of the canvas

    emits

    EVENTS.GAME.SET_SCALE

    since

    1.0.0-beta

    Parameters

    • scale: Scale

      Scale to set the canvas to

    Returns void

showScene

  • showScene(key: string): void
  • memberof

    Game

    description

    Sets a scene to visible. Keeps the current scene visible

    emits

    EVENTS.GAME.SHOW_SCENE

    since

    1.0.0-beta

    Parameters

    • key: string

      Key of the scene to show

    Returns void

Protected sleep

  • sleep(ms: number): Promise<unknown>

start

  • start(): Promise<void>
  • memberof

    Game

    description

    Starts the game loop

    emits

    EVENTS.GAME.LOAD_BEGIN

    emits

    EVENTS.GAME.DRAW_SPLASH

    emits

    EVENTS.GAME.LOAD_SCENE

    emits

    EVENTS.GAME.LOAD_FINISH

    since

    1.0.0-beta

    Returns Promise<void>

stop

  • stop(): void
  • memberof

    Game

    description

    Stops the game loop

    emits

    EVENTS.GAME.STOP

    since

    1.0.0

    Returns void

switchScene

  • switchScene(key: string, key2: string): void
  • memberof

    Game

    description

    Switches the current scene by the key

    emits

    EVENTS.GAME.SWITCH_SCENE

    since

    1.0.0-beta

    Parameters

    • key: string

      Key of the scene to switch from

    • key2: string

      Key of the scene to switch to

    Returns void

unlockPointer

  • unlockPointer(): void
  • memberof

    Game

    description

    Unlocks the pointer from the canvas

    emits

    EVENTS.GAME.UNLOCK_POINTER

    since

    1.0.0

    Returns void

Generated using TypeDoc