Skip to content

1681-engine / pixel / Darkness

Class: Darkness ​

Defined in: src/pixel/Darkness.ts:116

Constructors ​

Constructor ​

ts
new Darkness(
   stage, 
   color, 
   alpha, 
   options?
): Darkness;

Defined in: src/pixel/Darkness.ts:159

Parameters ​

ParameterType
stageStage
colornumber
alphanumber
optionsDarknessOptions

Returns ​

Darkness

Properties ​

carriedLight ​

ts
readonly carriedLight: number;

Defined in: src/pixel/Darkness.ts:157

The radius update uses when it is given none (DarknessOptions.carriedLight).

Methods ​

addLamp() ​

ts
addLamp(
   x, 
   y, 
   radius, 
   flicker?, 
   color?
): void;

Defined in: src/pixel/Darkness.ts:192

A lamp fixed in the world: a torch on a wall, the seep in its chamber, a crystal in a seam, in its own colour.

Parameters ​

ParameterTypeDefault value
xnumberundefined
ynumberundefined
radiusnumberundefined
flickernumber0
colornumberWARM_LIGHT

Returns ​

void


destroy() ​

ts
destroy(): void;

Defined in: src/pixel/Darkness.ts:330

Returns ​

void


setLampsDimmed() ​

ts
setLampsDimmed(dim): void;

Defined in: src/pixel/Darkness.ts:212

Dimmed lamps lay only LAMP_DIM of their colour on the dark (a "fewer ambient lights" setting). The holes they cut stay as wide, so a dark place is still seen by them.

Parameters ​

ParameterType
dimboolean

Returns ​

void


setShade() ​

ts
setShade(color, alpha): void;

Defined in: src/pixel/Darkness.ts:202

Changes how dark and what colour the sheet is (the outdoor night, NightShade, deepens and lifts with the world clock). A sheet with no alpha left is neither drawn nor redrawn, so a map at noon pays nothing for its night.

Parameters ​

ParameterType
colornumber
alphanumber

Returns ​

void


update() ​

ts
update(
   now, 
   px, 
   py, 
   carriedRadius?
): void;

Defined in: src/pixel/Darkness.ts:240

Redraws the night with this frame's holes in it, when anything in it changed. px/py is where the player stands; carriedRadius is the light they carry (default the carriedLight option, 0 for none).

Parameters ​

ParameterType
nownumber
pxnumber
pynumber
carriedRadiusnumber

Returns ​

void

Released under the MIT License.