Jump to content

LJJK

From Kerris Haus Wiki
  1. Weather

`Weather` is a helper class for generating weather effects. Currently, only rain and lightning are supported, and all weather effects are HTML based, thus livining in the interface

    1. Methods
      1. `startRain`

Starts a rain storm.

      1. `stopRain`

Stops a rain storm.

      1. `lightning`

Blinds the user with lightning.

  1. StateMachine

The StateMachine is the most important component of the engine, while also being one of the simplest. The StateMachine separates seperate tasks into their own bespoke states, and allows for simple pausing, resuming, and swapping between them.

See State.

    1. Methods
      1. `cleanup`

Cleans up all active states and shuts down the State Machine.

      1. `pushState(state)`

First pauses the current active State, if one is active. Then pushes the provided State `state` onto the stack. The provided State will become active after the current `update` function has finished execution, not necessarily immediately after this function is called. In most cases, steps should be taken to ensure the active State's update function does not continue execution following this call, as data saved during the active State's pause function may be overriden, and data expected by the active State's update function may become undefined, causing memory exceptions.

      1. `popState`

Cleans up and removes the current active State from the stack. If there are States beneath the current active State, the most recent one will be resumed.

      1. `changeState(state)`

Cleans up and removes the current state, and then initialises and activates the provided State `state`.

Internally calls `popState` and then `pushState(state)`.

      1. `update(deltaTime)`

Updates the current active state, if there is one.

  1. State

A State handled by the StateMachine.

    1. Methods
      1. `init(stateMachine)`

Initialises the State and sets the internal `stateMachine` member to the provided `stateMachine`.

This method is usually overriden by extending States, but it is important to call `super.init(stateMachine)` to ensure the State is properly initialised.

      1. `cleanup`

This method cleans up the State. By default, this method does nothing because JavaScript handles memory deallocation and what not for us. This method can be used to clean up, transfer, or save data that is required to persist outside of a given state.

For example, LoadingState will save all loaded assets to the window variable for use by other States within this method.

      1. `pause`

Runs necessary code when a State is paused by the StateMachine.

      1. `resume`

Runs necessary code when a State is resumed by the StateMachine.

      1. `update(deltaTime)`

Called every frame by the StateMachine.

  1. Player

`Player` is a user controller character. This class contains the main scene camera.

  1. Interface

This is the game's user interface. It is housed in `.interface-container` and is a standard HTML div. It is positioned at the top left corner of the view and is as tall and wide as the view. It is not interactable unless a class specifically gives it interaction.

  1. DialogTile

`DialogTile` is a `Triggerable` object that opens a `DialogBox` when triggered.

  1. DialogBox

`DialogBox` is the component used to create on screen DialogBoxes, with which the user can interact. `DialogBox` uses a div pre-created that lives inside the `.interface-container` element. When a new `DialogBox` is created, shown, or hidden, the content contained in the `.dialog-box` element is reset and replaced with the new content.

    1. Methods
      1. `constructor(message, printSpeed = 50, printDelay = 400)`

`message` message `printSpeed` default is 50. `printDelay` default is 400.

      1. `presentDialog`

Moves the dialog box on screen.

      1. `hideDialog`

Moves the dialog box off screen.

  1. Dialog

Dialog is controlled through the interface and the DialogBox system.

  1. Actor

The Actor class represents characters, player or non-player.

    1. Configuration

`spriteUpdateTime` represents the time in seconds between sprite changes.

    1. Methods
      1. `addSpriteSheet(name, frames)`

`name` is the filename of the sprite, location in `textures/sprites/`. `frames` is the number of frames in the sheet.

      1. `removeSpriteSheet(name)`

`name` is the name of the sprite as loaded previously.

      1. `setSpriteSheet(name)`

This will set the current spritesheet, provided it is already loaded.

`name` is the name of the sprite as loaded previously.