Skip to content

Latest commit

 

History

History
90 lines (46 loc) · 1.38 KB

File metadata and controls

90 lines (46 loc) · 1.38 KB

Renderer

Handles rendering the game using 2D Context.

Constructor

constructor(runtime)

Creates an instance of the Renderer.

Arguments

  • runtimeRuntime The current Runtime instance.

Properties

width

Returns

The display's character width.

height

Returns

The display's character height.


Methods

static validateConfig(config)

Validates a renderer configuration file and throws an error if it is invalid.

Arguments

  • configObject The config object to validate.

clearDisplay()

Clears the screen.

drawFrames(frames)

Draws an array of frames to the screen.

Arguments

  • framesArray<Frame> The frames to draw.

coordinatesToIndex(x, y)

Determines the frame index of a pixel coordinate.

Arguments

  • xnumber The x-value of the coordinate.
  • ynumber The y-value of the coordinate.

Returns

The index of that coordinate in a frame.

indexToCoordinates(index)

Converts a frame index into x and y coordinates.

Arguments

  • indexnumber The frame index.

Returns

A coordinate array.

compileFrames(...frames)

Compiles several frames. The last frame provided is on top.

Arguments

  • ...framesFrame The frames to compile.

Returns

The compiled frames.