diff --git a/docs/Audio.html b/docs/Audio.html index 30ca6fc7..43698e1c 100644 --- a/docs/Audio.html +++ b/docs/Audio.html @@ -1,3 +1,3 @@ Namespace: Audio
On this page

Audio

LittleJS Audio System

  • ZzFX Sound Effects - ZzFX Sound Effect Generator
  • ZzFXM Music - ZzFXM Music System
  • Caches sounds and music for fast playback
  • Can attenuate and apply stereo panning to sounds
  • Ability to play mp3, ogg, and wave files
  • Speech synthesis functions

Members

(static) audioContext :AudioContext

Audio context used by the engine

Type:
  • AudioContext

(static, constant) zzfxR

Sample rate used for all ZzFX sounds

Default Value
  • 44100

Methods

(static) getNoteFrequency(semitoneOffset, rootFrequencyopt) → {Number}

Get frequency of a note on a musical scale

Parameters:
NameTypeAttributesDefaultDescription
semitoneOffsetNumber

How many semitones away from the root note

rootFrequencyNumber<optional>
220

Frequency at semitone offset 0

Returns:
  • The frequency of the note
Type: 
Number

(static) playAudioFile(url, volumeopt, loopopt) → {HTMLAudioElement}

Play an mp3, ogg, or wav audio from a local file or url

Parameters:
NameTypeAttributesDefaultDescription
urlString

Location of sound file to play

volumeNumber<optional>
1

How much to scale volume by

loopBoolean<optional>
false

True if the music should loop

Returns:
  • The audio element for this sound
Type: 
HTMLAudioElement

(static) playSamples(sampleChannels, volumeopt, rateopt, panopt, loopopt, sampleRateopt) → {AudioBufferSourceNode}

Play cached audio samples with given settings

Parameters:
NameTypeAttributesDefaultDescription
sampleChannelsArray

Array of arrays of samples to play (for stereo playback)

volumeNumber<optional>
1

How much to scale volume by

rateNumber<optional>
1

The playback rate to use

panNumber<optional>
0

How much to apply stereo panning

loopBoolean<optional>
false

True if the sound should loop when it reaches the end

sampleRateNumber<optional>
44100

Sample rate for the sound

Returns:
  • The audio node of the sound played
Type: 
AudioBufferSourceNode

(static) speak(text, languageopt, volumeopt, rateopt, pitchopt) → {SpeechSynthesisUtterance}

Speak text with passed in settings

Parameters:
NameTypeAttributesDefaultDescription
textString

The text to speak

languageString<optional>

The language/accent to use (examples: en, it, ru, ja, zh)

volumeNumber<optional>
1

How much to scale volume by

rateNumber<optional>
1

How quickly to speak

pitchNumber<optional>
1

How much to change the pitch by

Returns:
  • The utterance that was spoken
Type: 
SpeechSynthesisUtterance

(static) speakStop()

Stop all queued speech

(static) zzfx(…zzfxSound) → {AudioBufferSourceNode}

Generate and play a ZzFX sound

Create sounds using the ZzFX Sound Designer.

Parameters:
NameTypeAttributesDescription
zzfxSoundArray<repeatable>

Array of ZzFX parameters, ex. [.5,.5]

Returns:
  • The audio node of the sound played
Type: 
AudioBufferSourceNode

(static) zzfxG(volumeopt, randomnessopt, frequencyopt, attackopt, sustainopt, releaseopt, shapeopt, shapeCurveopt, slideopt, deltaSlideopt, pitchJumpopt, pitchJumpTimeopt, repeatTimeopt, noiseopt, modulationopt, bitCrushopt, delayopt, sustainVolumeopt, decayopt, tremoloopt, filteropt) → {Array}

Generate samples for a ZzFX sound

Parameters:
NameTypeAttributesDefaultDescription
volumeNumber<optional>
1

Volume scale (percent)

randomnessNumber<optional>
0.05

How much to randomize frequency (percent Hz)

frequencyNumber<optional>
220

Frequency of sound (Hz)

attackNumber<optional>
0

Attack time, how fast sound starts (seconds)

sustainNumber<optional>
0

Sustain time, how long sound holds (seconds)

releaseNumber<optional>
0.1

Release time, how fast sound fades out (seconds)

shapeNumber<optional>
0

Shape of the sound wave

shapeCurveNumber<optional>
1

Squarenes of wave (0=square, 1=normal, 2=pointy)

slideNumber<optional>
0

How much to slide frequency (kHz/s)

deltaSlideNumber<optional>
0

How much to change slide (kHz/s/s)

pitchJumpNumber<optional>
0

Frequency of pitch jump (Hz)

pitchJumpTimeNumber<optional>
0

Time of pitch jump (seconds)

repeatTimeNumber<optional>
0

Resets some parameters periodically (seconds)

noiseNumber<optional>
0

How much random noise to add (percent)

modulationNumber<optional>
0

Frequency of modulation wave, negative flips phase (Hz)

bitCrushNumber<optional>
0

Resamples at a lower frequency in (samples*100)

delayNumber<optional>
0

Overlap sound with itself for reverb and flanger effects (seconds)

sustainVolumeNumber<optional>
1

Volume level for sustain (percent)

decayNumber<optional>
0

Decay time, how long to reach sustain after attack (seconds)

tremoloNumber<optional>
0

Trembling effect, rate controlled by repeat time (precent)

filterNumber<optional>
0

Filter cutoff frequency, positive for HPF, negative for LPF (Hz)

Returns:
  • Array of audio samples
Type: 
Array

(static) zzfxM(instruments, patterns, sequence, BPMopt) → {Array}

Generate samples for a ZzFM song with given parameters

Parameters:
NameTypeAttributesDefaultDescription
instrumentsArray

Array of ZzFX sound paramaters

patternsArray

Array of pattern data

sequenceArray

Array of pattern indexes

BPMNumber<optional>
125

Playback speed of the song in BPM

Returns:
  • Left and right channel sample data
Type: 
Array
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

Audio

LittleJS Audio System

  • ZzFX Sound Effects - ZzFX Sound Effect Generator
  • ZzFXM Music - ZzFXM Music System
  • Caches sounds and music for fast playback
  • Can attenuate and apply stereo panning to sounds
  • Ability to play mp3, ogg, and wave files
  • Speech synthesis functions

Members

(static) audioContext :AudioContext

Audio context used by the engine

Type:
  • AudioContext

(static) audioSuspended :Boolean

Keep track if audio was suspended when last sound was played

Type:
  • Boolean

(static, constant) zzfxR

Sample rate used for all ZzFX sounds

Default Value
  • 44100

Methods

(static) getNoteFrequency(semitoneOffset, rootFrequencyopt) → {Number}

Get frequency of a note on a musical scale

Parameters:
NameTypeAttributesDefaultDescription
semitoneOffsetNumber

How many semitones away from the root note

rootFrequencyNumber<optional>
220

Frequency at semitone offset 0

Returns:
  • The frequency of the note
Type: 
Number

(static) playAudioFile(filename, volumeopt, loopopt) → {HTMLAudioElement}

Play an mp3, ogg, or wav audio from a local file or url

Parameters:
NameTypeAttributesDefaultDescription
filenameString

Location of sound file to play

volumeNumber<optional>
1

How much to scale volume by

loopBoolean<optional>
false

True if the music should loop

Returns:
  • The audio element for this sound
Type: 
HTMLAudioElement

(static) playSamples(sampleChannels, volumeopt, rateopt, panopt, loopopt, sampleRateopt) → {AudioBufferSourceNode}

Play cached audio samples with given settings

Parameters:
NameTypeAttributesDefaultDescription
sampleChannelsArray

Array of arrays of samples to play (for stereo playback)

volumeNumber<optional>
1

How much to scale volume by

rateNumber<optional>
1

The playback rate to use

panNumber<optional>
0

How much to apply stereo panning

loopBoolean<optional>
false

True if the sound should loop when it reaches the end

sampleRateNumber<optional>
44100

Sample rate for the sound

Returns:
  • The audio node of the sound played
Type: 
AudioBufferSourceNode

(static) speak(text, languageopt, volumeopt, rateopt, pitchopt) → {SpeechSynthesisUtterance}

Speak text with passed in settings

Parameters:
NameTypeAttributesDefaultDescription
textString

The text to speak

languageString<optional>

The language/accent to use (examples: en, it, ru, ja, zh)

volumeNumber<optional>
1

How much to scale volume by

rateNumber<optional>
1

How quickly to speak

pitchNumber<optional>
1

How much to change the pitch by

Returns:
  • The utterance that was spoken
Type: 
SpeechSynthesisUtterance

(static) speakStop()

Stop all queued speech

(static) zzfx(…zzfxSound) → {AudioBufferSourceNode}

Generate and play a ZzFX sound

Create sounds using the ZzFX Sound Designer.

Parameters:
NameTypeAttributesDescription
zzfxSoundArray<repeatable>

Array of ZzFX parameters, ex. [.5,.5]

Returns:
  • The audio node of the sound played
Type: 
AudioBufferSourceNode

(static) zzfxG(volumeopt, randomnessopt, frequencyopt, attackopt, sustainopt, releaseopt, shapeopt, shapeCurveopt, slideopt, deltaSlideopt, pitchJumpopt, pitchJumpTimeopt, repeatTimeopt, noiseopt, modulationopt, bitCrushopt, delayopt, sustainVolumeopt, decayopt, tremoloopt, filteropt) → {Array}

Generate samples for a ZzFX sound

Parameters:
NameTypeAttributesDefaultDescription
volumeNumber<optional>
1

Volume scale (percent)

randomnessNumber<optional>
0.05

How much to randomize frequency (percent Hz)

frequencyNumber<optional>
220

Frequency of sound (Hz)

attackNumber<optional>
0

Attack time, how fast sound starts (seconds)

sustainNumber<optional>
0

Sustain time, how long sound holds (seconds)

releaseNumber<optional>
0.1

Release time, how fast sound fades out (seconds)

shapeNumber<optional>
0

Shape of the sound wave

shapeCurveNumber<optional>
1

Squarenes of wave (0=square, 1=normal, 2=pointy)

slideNumber<optional>
0

How much to slide frequency (kHz/s)

deltaSlideNumber<optional>
0

How much to change slide (kHz/s/s)

pitchJumpNumber<optional>
0

Frequency of pitch jump (Hz)

pitchJumpTimeNumber<optional>
0

Time of pitch jump (seconds)

repeatTimeNumber<optional>
0

Resets some parameters periodically (seconds)

noiseNumber<optional>
0

How much random noise to add (percent)

modulationNumber<optional>
0

Frequency of modulation wave, negative flips phase (Hz)

bitCrushNumber<optional>
0

Resamples at a lower frequency in (samples*100)

delayNumber<optional>
0

Overlap sound with itself for reverb and flanger effects (seconds)

sustainVolumeNumber<optional>
1

Volume level for sustain (percent)

decayNumber<optional>
0

Decay time, how long to reach sustain after attack (seconds)

tremoloNumber<optional>
0

Trembling effect, rate controlled by repeat time (precent)

filterNumber<optional>
0

Filter cutoff frequency, positive for HPF, negative for LPF (Hz)

Returns:
  • Array of audio samples
Type: 
Array

(static) zzfxM(instruments, patterns, sequence, BPMopt) → {Array}

Generate samples for a ZzFM song with given parameters

Parameters:
NameTypeAttributesDefaultDescription
instrumentsArray

Array of ZzFX sound paramaters

patternsArray

Array of pattern data

sequenceArray

Array of pattern indexes

BPMNumber<optional>
125

Playback speed of the song in BPM

Returns:
  • Left and right channel sample data
Type: 
Array
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/Color.html b/docs/Color.html index 84589b8a..a0c04a1d 100644 --- a/docs/Color.html +++ b/docs/Color.html @@ -1,3 +1,3 @@ Class: Color
On this page

Color

Color object (red, green, blue, alpha) with some helpful functions

Constructor

new Color(ropt, gopt, bopt, aopt)

Create a color with the rgba components passed in, white by default

Parameters:
NameTypeAttributesDefaultDescription
rNumber<optional>
1

red

gNumber<optional>
1

green

bNumber<optional>
1

blue

aNumber<optional>
1

alpha

Example
let a = new Color;              // white
let b = new Color(1, 0, 0);     // red
let c = new Color(0, 0, 0, 0);  // transparent black
let d = rgb(0, 0, 1);           // blue using rgb color
let e = hsl(.3, 1, .5);         // green using hsl color

Members

a

Properties
TypeDescription
Number

Alpha

b

Properties
TypeDescription
Number

Blue

g

Properties
TypeDescription
Number

Green

r

Properties
TypeDescription
Number

Red

Methods

add(c) → {Color}

Returns a copy of this color plus the color passed in

Parameters:
NameTypeDescription
cColor

other color

Returns:
Type: 
Color

clamp() → {Color}

Returns a copy of this color clamped to the valid range between 0 and 1

Returns:
Type: 
Color

copy() → {Color}

Returns a new color that is a copy of this

Returns:
Type: 
Color

divide(c) → {Color}

Returns a copy of this color divided by the color passed in

Parameters:
NameTypeDescription
cColor

other color

Returns:
Type: 
Color

getHSLA() → {Array}

Returns this color expressed in hsla format

Returns:
Type: 
Array

lerp(c, percent) → {Color}

Returns a new color that is p percent between this and the color passed in

Parameters:
NameTypeDescription
cColor

other color

percentNumber
Returns:
Type: 
Color

multiply(c) → {Color}

Returns a copy of this color times the color passed in

Parameters:
NameTypeDescription
cColor

other color

Returns:
Type: 
Color

mutate(amountopt, alphaAmountopt) → {Color}

Returns a new color that has each component randomly adjusted

Parameters:
NameTypeAttributesDefaultDescription
amountNumber<optional>
0.05
alphaAmountNumber<optional>
0
Returns:
Type: 
Color

rgbaInt() → {Number}

Returns this color expressed as 32 bit RGBA value

Returns:
Type: 
Number

scale(scale, alphaScaleopt) → {Color}

Returns a copy of this color scaled by the value passed in, alpha can be scaled separately

Parameters:
NameTypeAttributesDefaultDescription
scaleNumber
alphaScaleNumber<optional>
scale
Returns:
Type: 
Color

setHSLA(hopt, sopt, lopt, aopt) → {Color}

Sets this color given a hue, saturation, lightness, and alpha

Parameters:
NameTypeAttributesDefaultDescription
hNumber<optional>
0

hue

sNumber<optional>
0

saturation

lNumber<optional>
1

lightness

aNumber<optional>
1

alpha

Returns:
Type: 
Color

setHex(hex) → {Color}

Set this color from a hex code

Parameters:
NameTypeDescription
hexString

html hex code

Returns:
Type: 
Color

subtract(c) → {Color}

Returns a copy of this color minus the color passed in

Parameters:
NameTypeDescription
cColor

other color

Returns:
Type: 
Color

toString(useAlphaopt) → {String}

Returns this color expressed as a hex color code

Parameters:
NameTypeAttributesDefaultDescription
useAlphaBoolean<optional>
true

if alpha should be included in result

Returns:
Type: 
String
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

Color

Color object (red, green, blue, alpha) with some helpful functions

Constructor

new Color(ropt, gopt, bopt, aopt)

Create a color with the rgba components passed in, white by default

Parameters:
NameTypeAttributesDefaultDescription
rNumber<optional>
1

red

gNumber<optional>
1

green

bNumber<optional>
1

blue

aNumber<optional>
1

alpha

Example
let a = new Color;              // white
let b = new Color(1, 0, 0);     // red
let c = new Color(0, 0, 0, 0);  // transparent black
let d = rgb(0, 0, 1);           // blue using rgb color
let e = hsl(.3, 1, .5);         // green using hsl color

Members

a

Properties
TypeDescription
Number

Alpha

b

Properties
TypeDescription
Number

Blue

g

Properties
TypeDescription
Number

Green

r

Properties
TypeDescription
Number

Red

Methods

HSLA() → {Array}

Returns this color expressed in hsla format

Returns:
Type: 
Array

add(c) → {Color}

Returns a copy of this color plus the color passed in

Parameters:
NameTypeDescription
cColor

other color

Returns:
Type: 
Color

clamp() → {Color}

Returns a copy of this color clamped to the valid range between 0 and 1

Returns:
Type: 
Color

copy() → {Color}

Returns a new color that is a copy of this

Returns:
Type: 
Color

divide(c) → {Color}

Returns a copy of this color divided by the color passed in

Parameters:
NameTypeDescription
cColor

other color

Returns:
Type: 
Color

lerp(c, percent) → {Color}

Returns a new color that is p percent between this and the color passed in

Parameters:
NameTypeDescription
cColor

other color

percentNumber
Returns:
Type: 
Color

multiply(c) → {Color}

Returns a copy of this color times the color passed in

Parameters:
NameTypeDescription
cColor

other color

Returns:
Type: 
Color

mutate(amountopt, alphaAmountopt) → {Color}

Returns a new color that has each component randomly adjusted

Parameters:
NameTypeAttributesDefaultDescription
amountNumber<optional>
0.05
alphaAmountNumber<optional>
0
Returns:
Type: 
Color

rgbaInt() → {Number}

Returns this color expressed as 32 bit RGBA value

Returns:
Type: 
Number

scale(scale, alphaScaleopt) → {Color}

Returns a copy of this color scaled by the value passed in, alpha can be scaled separately

Parameters:
NameTypeAttributesDefaultDescription
scaleNumber
alphaScaleNumber<optional>
scale
Returns:
Type: 
Color

setHSLA(hopt, sopt, lopt, aopt) → {Color}

Sets this color given a hue, saturation, lightness, and alpha

Parameters:
NameTypeAttributesDefaultDescription
hNumber<optional>
0

hue

sNumber<optional>
0

saturation

lNumber<optional>
1

lightness

aNumber<optional>
1

alpha

Returns:
Type: 
Color

setHex(hex) → {Color}

Set this color from a hex code

Parameters:
NameTypeDescription
hexString

html hex code

Returns:
Type: 
Color

subtract(c) → {Color}

Returns a copy of this color minus the color passed in

Parameters:
NameTypeDescription
cColor

other color

Returns:
Type: 
Color

toString(useAlphaopt) → {String}

Returns this color expressed as a hex color code

Parameters:
NameTypeAttributesDefaultDescription
useAlphaBoolean<optional>
true

if alpha should be included in result

Returns:
Type: 
String
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/Debug.html b/docs/Debug.html index 0d8c1349..4b4cdf8a 100644 --- a/docs/Debug.html +++ b/docs/Debug.html @@ -1,3 +1,3 @@ Namespace: Debug
On this page

Debug

LittleJS Debug System

  • Press Esc to show debug overlay with mouse pick
  • Number keys toggle debug functions
  • +/- apply time scale
  • Debug primitive rendering
  • Save a 2d canvas as a png image

Members

(static, constant) debug :Boolean

True if debug is enabled

Type:
  • Boolean
Default Value
  • true

(static) debugKey :String

Key code used to toggle debug mode, Esc by default

Type:
  • String
Default Value
  • Escape

(static) debugOverlay :Boolean

True if the debug overlay is active, always false in release builds

Type:
  • Boolean

(static, constant) debugPointSize :Number

Size to render debug points by default

Type:
  • Number
Default Value
  • 0.5

(static, constant) enableAsserts :Boolean

True if asserts are enaled

Type:
  • Boolean
Default Value
  • true

(static) showWatermark :Boolean

True if watermark with FPS should be shown, false in release builds

Type:
  • Boolean
Default Value
  • true

Methods

(static) ASSERT(assert, outputopt)

Asserts if the experssion is false, does not do anything in release builds

Parameters:
NameTypeAttributesDescription
assertBoolean
outputObject<optional>

(static) debugAABB(pA, sA, pB, sB, coloropt)

Draw a debug axis aligned bounding box in world space

Parameters:
NameTypeAttributesDescription
pAVector2

position A

sAVector2

size A

pBVector2

position B

sBVector2

size B

colorString<optional>

(static) debugCircle(pos, radiusopt, coloropt, timeopt, fillopt)

Draw a debug circle in world space

Parameters:
NameTypeAttributesDefaultDescription
posVector2
radiusNumber<optional>
0
colorString<optional>
#fff
timeNumber<optional>
0
fillBoolean<optional>
false

(static) debugClear()

Clear all debug primitives in the list

(static) debugLine(posA, posB, coloropt, thicknessopt, timeopt)

Draw a debug line in world space

Parameters:
NameTypeAttributesDefaultDescription
posAVector2
posBVector2
colorString<optional>
thicknessNumber<optional>
0.1
timeNumber<optional>

(static) debugPoint(pos, coloropt, timeopt, angleopt)

Draw a debug point in world space

Parameters:
NameTypeAttributesDescription
posVector2
colorString<optional>
timeNumber<optional>
angleNumber<optional>

(static) debugRect(pos, sizeopt, coloropt, timeopt, angleopt, fillopt)

Draw a debug rectangle in world space

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2<optional>
Vector2()
colorString<optional>
#fff
timeNumber<optional>
0
angleNumber<optional>
0
fillBoolean<optional>
false

(static) debugSaveCanvas(canvas, filenameopt, typeopt)

Save a canvas to disk

Parameters:
NameTypeAttributesDefaultDescription
canvasHTMLCanvasElement
filenameString<optional>
typeString<optional>
image/png

(static) debugSaveDataURL(dataURL, filename)

Save a data url to disk

Parameters:
NameTypeDescription
dataURLString
filenameString

(static) debugSaveText(text, filenameopt, typeopt)

Save a text file to disk

Parameters:
NameTypeAttributesDefaultDescription
textString
filenameString<optional>
typeString<optional>
text/plain

(static) debugText(text, pos, sizeopt, coloropt, timeopt, angleopt, fontopt)

Draw a debug axis aligned bounding box in world space

Parameters:
NameTypeAttributesDefaultDescription
textString
posVector2
sizeNumber<optional>
1
colorString<optional>
#fff
timeNumber<optional>
0
angleNumber<optional>
0
fontString<optional>
monospace

(static) setDebugKey(key)

Set key code used to toggle debug mode, Esc by default

Parameters:
NameTypeDescription
keyString

(static) setShowWatermark(show)

Set if watermark with FPS should be shown

Parameters:
NameTypeDescription
showBoolean
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

Debug

LittleJS Debug System

  • Press Esc to show debug overlay with mouse pick
  • Number keys toggle debug functions
  • +/- apply time scale
  • Debug primitive rendering
  • Save a 2d canvas as a png image

Members

(static, constant) debug :Boolean

True if debug is enabled

Type:
  • Boolean
Default Value
  • true

(static) debugKey :String

Key code used to toggle debug mode, Esc by default

Type:
  • String
Default Value
  • Escape

(static) debugOverlay :Boolean

True if the debug overlay is active, always false in release builds

Type:
  • Boolean

(static, constant) debugPointSize :Number

Size to render debug points by default

Type:
  • Number
Default Value
  • 0.5

(static, constant) enableAsserts :Boolean

True if asserts are enaled

Type:
  • Boolean
Default Value
  • true

(static) showWatermark :Boolean

True if watermark with FPS should be shown, false in release builds

Type:
  • Boolean
Default Value
  • true

Methods

(static) ASSERT(assert, outputopt)

Asserts if the expression is false, does not do anything in release builds

Parameters:
NameTypeAttributesDescription
assertBoolean
outputObject<optional>

(static) debugAABB(pA, sA, pB, sB, coloropt)

Draw a debug axis aligned bounding box in world space

Parameters:
NameTypeAttributesDescription
pAVector2

position A

sAVector2

size A

pBVector2

position B

sBVector2

size B

colorString<optional>

(static) debugCircle(pos, radiusopt, coloropt, timeopt, fillopt)

Draw a debug circle in world space

Parameters:
NameTypeAttributesDefaultDescription
posVector2
radiusNumber<optional>
0
colorString<optional>
#fff
timeNumber<optional>
0
fillBoolean<optional>
false

(static) debugClear()

Clear all debug primitives in the list

(static) debugLine(posA, posB, coloropt, thicknessopt, timeopt)

Draw a debug line in world space

Parameters:
NameTypeAttributesDefaultDescription
posAVector2
posBVector2
colorString<optional>
thicknessNumber<optional>
0.1
timeNumber<optional>

(static) debugPoint(pos, coloropt, timeopt, angleopt)

Draw a debug point in world space

Parameters:
NameTypeAttributesDescription
posVector2
colorString<optional>
timeNumber<optional>
angleNumber<optional>

(static) debugRect(pos, sizeopt, coloropt, timeopt, angleopt, fillopt)

Draw a debug rectangle in world space

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2<optional>
Vector2()
colorString<optional>
#fff
timeNumber<optional>
0
angleNumber<optional>
0
fillBoolean<optional>
false

(static) debugSaveCanvas(canvas, filenameopt, typeopt)

Save a canvas to disk

Parameters:
NameTypeAttributesDefaultDescription
canvasHTMLCanvasElement
filenameString<optional>
typeString<optional>
image/png

(static) debugSaveDataURL(dataURL, filename)

Save a data url to disk

Parameters:
NameTypeDescription
dataURLString
filenameString

(static) debugSaveText(text, filenameopt, typeopt)

Save a text file to disk

Parameters:
NameTypeAttributesDefaultDescription
textString
filenameString<optional>
typeString<optional>
text/plain

(static) debugText(text, pos, sizeopt, coloropt, timeopt, angleopt, fontopt)

Draw a debug axis aligned bounding box in world space

Parameters:
NameTypeAttributesDefaultDescription
textString
posVector2
sizeNumber<optional>
1
colorString<optional>
#fff
timeNumber<optional>
0
angleNumber<optional>
0
fontString<optional>
monospace

(static) setDebugKey(key)

Set key code used to toggle debug mode, Esc by default

Parameters:
NameTypeDescription
keyString

(static) setShowWatermark(show)

Set if watermark with FPS should be shown

Parameters:
NameTypeDescription
showBoolean
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/Draw.html b/docs/Draw.html index e097720c..c38c6ccb 100644 --- a/docs/Draw.html +++ b/docs/Draw.html @@ -1,3 +1,3 @@ Namespace: Draw
On this page

Draw

LittleJS Drawing System

  • Hybrid system with both Canvas2D and WebGL available
  • Super fast tile sheet rendering with WebGL
  • Can apply rotation, mirror, color and additive color
  • Font rendering system with built in engine font
  • Many useful utility functions

LittleJS uses a hybrid rendering solution with the best of both Canvas2D and WebGL. There are 3 canvas/contexts available to draw to... mainCanvas - 2D background canvas, non WebGL stuff like tile layers are drawn here. glCanvas - Used by the accelerated WebGL batch rendering system. overlayCanvas - Another 2D canvas that appears on top of the other 2 canvases.

The WebGL rendering system is very fast with some caveats...

  • Switching blend modes (additive) or textures causes another draw call which is expensive in excess
  • Group additive rendering together using renderOrder to mitigate this issue

The LittleJS rendering solution is intentionally simple, feel free to adjust it for your needs!

Members

(static) mainCanvas :HTMLCanvasElement

The primary 2D canvas visible to the user

Type:
  • HTMLCanvasElement

(static) mainCanvasSize :Vector2

The size of the main canvas (and other secondary canvases)

Type:

(static) mainContext :CanvasRenderingContext2D

2d context for mainCanvas

Type:
  • CanvasRenderingContext2D

(static) overlayCanvas :HTMLCanvasElement

A canvas that appears on top of everything the same size as mainCanvas

Type:
  • HTMLCanvasElement

(static) overlayContext :CanvasRenderingContext2D

2d context for overlayCanvas

Type:
  • CanvasRenderingContext2D

(static) textureInfos :Array

Array containing texture info for batch rendering system

Type:
  • Array

Methods

(static) drawCanvas2D(pos, size, angle, mirror, drawFunction, screenSpaceopt, contextopt)

Draw directly to a 2d canvas context in world space

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2
angleNumber
mirrorBoolean
drawFunctionfunction
screenSpaceBoolean<optional>
false
contextCanvasRenderingContext2D<optional>
mainContext

(static) drawLine(posA, posB, thicknessopt, coloropt, useWebGLopt, screenSpaceopt, contextopt)

Draw colored line between two points

Parameters:
NameTypeAttributesDefaultDescription
posAVector2
posBVector2
thicknessNumber<optional>
0.1
colorColor<optional>
(1,1,1,1)
useWebGLBoolean<optional>
glEnable
screenSpaceBoolean<optional>
false
contextCanvasRenderingContext2D<optional>

(static) drawPoly(points, coloropt, screenSpaceopt, contextopt)

Draw colored polygon using passed in points

Parameters:
NameTypeAttributesDefaultDescription
pointsArray

Array of Vector2 points

colorColor<optional>
(1,1,1,1)
screenSpaceBoolean<optional>
false
contextCanvasRenderingContext2D<optional>
mainContext

(static) drawRect(pos, sizeopt, coloropt, angleopt, useWebGLopt, screenSpaceopt, contextopt)

Draw colored rect centered on pos

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2<optional>
(1,1)
colorColor<optional>
(1,1,1,1)
angleNumber<optional>
useWebGLBoolean<optional>
glEnable
screenSpaceBoolean<optional>
false
contextCanvasRenderingContext2D<optional>

(static) drawText(text, pos, sizeopt, coloropt, lineWidthopt, lineColoropt, textAlignopt, fontopt, contextopt)

Draw text on overlay canvas in world space Automatically splits new lines into rows

Parameters:
NameTypeAttributesDefaultDescription
textString
posVector2
sizeNumber<optional>
1
colorColor<optional>
(1,1,1,1)
lineWidthNumber<optional>
0
lineColorColor<optional>
(0,0,0,1)
textAlignCanvasTextAlign<optional>
'center'
fontString<optional>
fontDefault
contextCanvasRenderingContext2D<optional>
overlayContext

(static) drawTextScreen(text, pos, sizeopt, coloropt, lineWidthopt, lineColoropt, textAlignopt, fontopt, contextopt)

Draw text on overlay canvas in screen space Automatically splits new lines into rows

Parameters:
NameTypeAttributesDefaultDescription
textString
posVector2
sizeNumber<optional>
1
colorColor<optional>
(1,1,1,1)
lineWidthNumber<optional>
0
lineColorColor<optional>
(0,0,0,1)
textAlignCanvasTextAlign<optional>
center
fontString<optional>
fontDefault
contextCanvasRenderingContext2D<optional>
overlayContext

(static) drawTile(pos, sizeopt, tileInfoopt, coloropt, angleopt, mirroropt, additiveColoropt, useWebGLopt, screenSpaceopt, contextopt)

Draw textured tile centered in world space, with color applied if using WebGL

Parameters:
NameTypeAttributesDefaultDescription
posVector2

Center of the tile in world space

sizeVector2<optional>
(1,1)

Size of the tile in world space

tileInfoTileInfo<optional>

Tile info to use, untextured if undefined

colorColor<optional>
(1,1,1,1)

Color to modulate with

angleNumber<optional>
0

Angle to rotate by

mirrorBoolean<optional>

If true image is flipped along the Y axis

additiveColorColor<optional>
(0,0,0,0)

Additive color to be applied

useWebGLBoolean<optional>
glEnable

Use accelerated WebGL rendering

screenSpaceBoolean<optional>
false

If true the pos and size are in screen space

contextCanvasRenderingContext2D<optional>

Canvas 2D context to draw to

(static) isFullscreen() → {Boolean}

Returns true if fullscreen mode is active

Returns:
Type: 
Boolean

(static) screenToWorld(screenPos) → {Vector2}

Convert from screen to world space coordinates

Parameters:
NameTypeDescription
screenPosVector2
Returns:
Type: 
Vector2

(static) setBlendMode(additiveopt, useWebGLopt, contextopt)

Enable normal or additive blend mode

Parameters:
NameTypeAttributesDefaultDescription
additiveBoolean<optional>
useWebGLBoolean<optional>
glEnable
contextCanvasRenderingContext2D<optional>
mainContext

(static) tile(posopt, sizeopt, textureIndexopt) → {TileInfo}

Create a tile info object

  • This can take vecs or floats for easier use and conversion
  • If an index is passed in, the tile size and index will determine the position
Parameters:
NameTypeAttributesDefaultDescription
posNumber | Vector2<optional>
(0,0)

Top left corner of tile in pixels or index

sizeNumber | Vector2<optional>
tileSizeDefault

Size of tile in pixels

textureIndexNumber<optional>
0

Texture index to use

Returns:
Type: 
TileInfo
Example
tile(2)                       // a tile at index 2 using the default tile size of 16
tile(5, 8)                    // a tile at index 5 using a tile size of 8
tile(1, 16, 3)                // a tile at index 1 of size 16 on texture 3
tile(vec2(4,8), vec2(30,10))  // a tile at pixel location (4,8) with a size of (30,10)

(static) toggleFullscreen()

Toggle fullsceen mode

(static) worldToScreen(worldPos) → {Vector2}

Convert from world to screen space coordinates

Parameters:
NameTypeDescription
worldPosVector2
Returns:
Type: 
Vector2
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

Draw

LittleJS Drawing System

  • Hybrid system with both Canvas2D and WebGL available
  • Super fast tile sheet rendering with WebGL
  • Can apply rotation, mirror, color and additive color
  • Font rendering system with built in engine font
  • Many useful utility functions

LittleJS uses a hybrid rendering solution with the best of both Canvas2D and WebGL. There are 3 canvas/contexts available to draw to... mainCanvas - 2D background canvas, non WebGL stuff like tile layers are drawn here. glCanvas - Used by the accelerated WebGL batch rendering system. overlayCanvas - Another 2D canvas that appears on top of the other 2 canvases.

The WebGL rendering system is very fast with some caveats...

  • Switching blend modes (additive) or textures causes another draw call which is expensive in excess
  • Group additive rendering together using renderOrder to mitigate this issue

The LittleJS rendering solution is intentionally simple, feel free to adjust it for your needs!

Members

(static) mainCanvas :HTMLCanvasElement

The primary 2D canvas visible to the user

Type:
  • HTMLCanvasElement

(static) mainCanvasSize :Vector2

The size of the main canvas (and other secondary canvases)

Type:

(static) mainContext :CanvasRenderingContext2D

2d context for mainCanvas

Type:
  • CanvasRenderingContext2D

(static) overlayCanvas :HTMLCanvasElement

A canvas that appears on top of everything the same size as mainCanvas

Type:
  • HTMLCanvasElement

(static) overlayContext :CanvasRenderingContext2D

2d context for overlayCanvas

Type:
  • CanvasRenderingContext2D

(static) textureInfos :Array

Array containing texture info for batch rendering system

Type:
  • Array

Methods

(static) drawCanvas2D(pos, size, angle, mirror, drawFunction, screenSpaceopt, contextopt)

Draw directly to a 2d canvas context in world space

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2
angleNumber
mirrorBoolean
drawFunctionfunction
screenSpaceBoolean<optional>
false
contextCanvasRenderingContext2D<optional>
mainContext

(static) drawLine(posA, posB, thicknessopt, coloropt, useWebGLopt, screenSpaceopt, contextopt)

Draw colored line between two points

Parameters:
NameTypeAttributesDefaultDescription
posAVector2
posBVector2
thicknessNumber<optional>
0.1
colorColor<optional>
(1,1,1,1)
useWebGLBoolean<optional>
glEnable
screenSpaceBoolean<optional>
false
contextCanvasRenderingContext2D<optional>

(static) drawRect(pos, sizeopt, coloropt, angleopt, useWebGLopt, screenSpaceopt, contextopt)

Draw colored rect centered on pos

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2<optional>
(1,1)
colorColor<optional>
(1,1,1,1)
angleNumber<optional>
useWebGLBoolean<optional>
glEnable
screenSpaceBoolean<optional>
false
contextCanvasRenderingContext2D<optional>

(static) drawText(text, pos, sizeopt, coloropt, lineWidthopt, lineColoropt, textAlignopt, fontopt, contextopt)

Draw text on overlay canvas in world space Automatically splits new lines into rows

Parameters:
NameTypeAttributesDefaultDescription
textString
posVector2
sizeNumber<optional>
1
colorColor<optional>
(1,1,1,1)
lineWidthNumber<optional>
0
lineColorColor<optional>
(0,0,0,1)
textAlignCanvasTextAlign<optional>
'center'
fontString<optional>
fontDefault
contextCanvasRenderingContext2D<optional>
overlayContext

(static) drawTextScreen(text, pos, sizeopt, coloropt, lineWidthopt, lineColoropt, textAlignopt, fontopt, contextopt)

Draw text on overlay canvas in screen space Automatically splits new lines into rows

Parameters:
NameTypeAttributesDefaultDescription
textString
posVector2
sizeNumber<optional>
1
colorColor<optional>
(1,1,1,1)
lineWidthNumber<optional>
0
lineColorColor<optional>
(0,0,0,1)
textAlignCanvasTextAlign<optional>
center
fontString<optional>
fontDefault
contextCanvasRenderingContext2D<optional>
overlayContext

(static) drawTile(pos, sizeopt, tileInfoopt, coloropt, angleopt, mirroropt, additiveColoropt, useWebGLopt, screenSpaceopt, contextopt)

Draw textured tile centered in world space, with color applied if using WebGL

Parameters:
NameTypeAttributesDefaultDescription
posVector2

Center of the tile in world space

sizeVector2<optional>
(1,1)

Size of the tile in world space

tileInfoTileInfo<optional>

Tile info to use, untextured if undefined

colorColor<optional>
(1,1,1,1)

Color to modulate with

angleNumber<optional>
0

Angle to rotate by

mirrorBoolean<optional>

If true image is flipped along the Y axis

additiveColorColor<optional>
(0,0,0,0)

Additive color to be applied

useWebGLBoolean<optional>
glEnable

Use accelerated WebGL rendering

screenSpaceBoolean<optional>
false

If true the pos and size are in screen space

contextCanvasRenderingContext2D<optional>

Canvas 2D context to draw to

(static) getCameraSize() → {Vector2}

Get the camera's visible area in world space

Returns:
Type: 
Vector2

(static) isFullscreen() → {Boolean}

Returns true if fullscreen mode is active

Returns:
Type: 
Boolean

(static) screenToWorld(screenPos) → {Vector2}

Convert from screen to world space coordinates

Parameters:
NameTypeDescription
screenPosVector2
Returns:
Type: 
Vector2

(static) setBlendMode(additiveopt, useWebGLopt, contextopt)

Enable normal or additive blend mode

Parameters:
NameTypeAttributesDefaultDescription
additiveBoolean<optional>
useWebGLBoolean<optional>
glEnable
contextCanvasRenderingContext2D<optional>
mainContext

(static) tile(posopt, sizeopt, textureIndexopt) → {TileInfo}

Create a tile info object

  • This can take vecs or floats for easier use and conversion
  • If an index is passed in, the tile size and index will determine the position
Parameters:
NameTypeAttributesDefaultDescription
posNumber | Vector2<optional>
(0,0)

Top left corner of tile in pixels or index

sizeNumber | Vector2<optional>
tileSizeDefault

Size of tile in pixels

textureIndexNumber<optional>
0

Texture index to use

Returns:
Type: 
TileInfo
Example
tile(2)                       // a tile at index 2 using the default tile size of 16
tile(5, 8)                    // a tile at index 5 using a tile size of 8
tile(1, 16, 3)                // a tile at index 1 of size 16 on texture 3
tile(vec2(4,8), vec2(30,10))  // a tile at pixel location (4,8) with a size of (30,10)

(static) toggleFullscreen()

Toggle fullsceen mode

(static) worldToScreen(worldPos) → {Vector2}

Convert from world to screen space coordinates

Parameters:
NameTypeDescription
worldPosVector2
Returns:
Type: 
Vector2
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/Engine.html b/docs/Engine.html index 7053eb5a..16ca90cd 100644 --- a/docs/Engine.html +++ b/docs/Engine.html @@ -1,3 +1,3 @@ Namespace: Engine
On this page

Engine

LittleJS - The Tiny JavaScript Game Engine That Can! MIT License - Copyright 2021 Frank Force

Engine Features

  • Object oriented system with base class engine object
  • Base class object handles update, physics, collision, rendering, etc
  • Engine helper classes and functions like Vector2, Color, and Timer
  • Super fast rendering system for tile sheets
  • Sound effects audio with zzfx and music with zzfxm
  • Input processing system with gamepad and touchscreen support
  • Tile layer rendering and collision system
  • Particle effect system
  • Medal system tracks and displays achievements
  • Debug tools and debug rendering system
  • Post processing effects
  • Call engineInit() to start it up!

Members

(static, constant) engineName :String

Name of engine

Type:
  • String
Default Value
  • LittleJS

(static) engineObjects :Array

Array containing all engine objects

Type:
  • Array

(static) engineObjectsCollide :Array

Array containing only objects that are set to collide with other objects this frame (for optimization)

Type:
  • Array

(static, constant) engineVersion :String

Version of engine

Type:
  • String
Default Value
  • 1.9.2

(static) frame :Number

Current update frame, used to calculate time

Type:
  • Number

(static, constant) frameRate :Number

Frames per second to update objects

Type:
  • Number
Default Value
  • 60

(static) paused :Boolean

Is the game paused? Causes time and objects to not be updated

Type:
  • Boolean
Default Value
  • false

(static) time :Number

Current engine time since start in seconds, derived from frame

Type:
  • Number

(static, constant) timeDelta :Number

How many seconds each frame lasts, engine uses a fixed time step

Type:
  • Number
Default Value
  • 1/60

(static) timeReal :Number

Actual clock time since start in seconds (not affected by pause or frame rate clamping)

Type:
  • Number

Methods

(static) engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, imageSourcesopt)

Start up LittleJS engine with your callback functions

Parameters:
NameTypeAttributesDefaultDescription
gameInitfunction

Called once after the engine starts up, setup the game

gameUpdatefunction

Called every frame at 60 frames per second, handle input and update the game state

gameUpdatePostfunction

Called after physics and objects are updated, setup camera and prepare for render

gameRenderfunction

Called before objects are rendered, draw any background effects that appear behind objects

gameRenderPostfunction

Called after objects are rendered, draw effects or hud that appear above all objects

imageSourcesArray<optional>
['tiles.png']

Image to load

(static) engineObjectsCallback(posopt, sizeopt, callbackFunctionopt, objectsopt)

Triggers a callback for each object within a given area

Parameters:
NameTypeAttributesDefaultDescription
posVector2<optional>

Center of test area

sizeNumber | Vector2<optional>

Radius of circle if float, rectangle size if Vector2

callbackFunctionfunction<optional>

Calls this function on every object that passes the test

objectsArray<optional>
engineObjects

List of objects to check

(static) engineObjectsDestroy()

Destroy and remove all objects

(static) engineObjectsUpdate()

Update each engine object, remove destroyed objects, and update time

(static) setPaused(isPaused)

Set if game is paused

Parameters:
NameTypeDescription
isPausedBoolean
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

Engine

LittleJS - The Tiny Fast JavaScript Game Engine MIT License - Copyright 2021 Frank Force

Engine Features

  • Object oriented system with base class engine object
  • Base class object handles update, physics, collision, rendering, etc
  • Engine helper classes and functions like Vector2, Color, and Timer
  • Super fast rendering system for tile sheets
  • Sound effects audio with zzfx and music with zzfxm
  • Input processing system with gamepad and touchscreen support
  • Tile layer rendering and collision system
  • Particle effect system
  • Medal system tracks and displays achievements
  • Debug tools and debug rendering system
  • Post processing effects
  • Call engineInit() to start it up!

Members

(static, constant) engineName :String

Name of engine

Type:
  • String
Default Value
  • LittleJS

(static) engineObjects :Array

Array containing all engine objects

Type:
  • Array

(static) engineObjectsCollide :Array

Array with only objects set to collide with other objects this frame (for optimization)

Type:
  • Array

(static, constant) engineVersion :String

Version of engine

Type:
  • String
Default Value
  • 1.9.4

(static) frame :Number

Current update frame, used to calculate time

Type:
  • Number

(static, constant) frameRate :Number

Frames per second to update

Type:
  • Number
Default Value
  • 60

(static) paused :Boolean

Is the game paused? Causes time and objects to not be updated

Type:
  • Boolean
Default Value
  • false

(static) time :Number

Current engine time since start in seconds

Type:
  • Number

(static, constant) timeDelta :Number

How many seconds each frame lasts, engine uses a fixed time step

Type:
  • Number
Default Value
  • 1/60

(static) timeReal :Number

Actual clock time since start in seconds (not affected by pause or frame rate clamping)

Type:
  • Number

Methods

(static) engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, imageSourcesopt)

Startup LittleJS engine with your callback functions

Parameters:
NameTypeAttributesDefaultDescription
gameInitfunction

Called once after the engine starts up, setup the game

gameUpdatefunction

Called every frame at 60 frames per second, handle input and update the game state

gameUpdatePostfunction

Called after physics and objects are updated, setup camera and prepare for render

gameRenderfunction

Called before objects are rendered, draw any background effects that appear behind objects

gameRenderPostfunction

Called after objects are rendered, draw effects or hud that appear above all objects

imageSourcesArray<optional>
['tiles.png']

Image to load

(static) engineObjectsCallback(posopt, sizeopt, callbackFunctionopt, objectsopt)

Triggers a callback for each object within a given area

Parameters:
NameTypeAttributesDefaultDescription
posVector2<optional>

Center of test area

sizeNumber | Vector2<optional>

Radius of circle if float, rectangle size if Vector2

callbackFunctionfunction<optional>

Calls this function on every object that passes the test

objectsArray<optional>
engineObjects

List of objects to check

(static) engineObjectsDestroy()

Destroy and remove all objects

(static) engineObjectsUpdate()

Update each engine object, remove destroyed objects, and update time

(static) setPaused(isPaused)

Set if game is paused

Parameters:
NameTypeDescription
isPausedBoolean
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/EngineObject.html b/docs/EngineObject.html index a24dd063..4664eee4 100644 --- a/docs/EngineObject.html +++ b/docs/EngineObject.html @@ -1,3 +1,3 @@ Class: EngineObject
On this page

EngineObject

LittleJS Object Base Object Class

  • Top level object class used by the engine
  • Automatically adds self to object list
  • Will be updated and rendered each frame
  • Renders as a sprite from a tilesheet by default
  • Can have color and addtive color applied
  • 2D Physics and collision system
  • Sorted by renderOrder
  • Objects can have children attached
  • Parents are updated before children, and set child transform
  • Call destroy() to get rid of objects

The physics system used by objects is simple and fast with some caveats...

  • Collision uses the axis aligned size, the object's rotation angle is only for rendering
  • Objects are guaranteed to not intersect tile collision from physics
  • If an object starts or is moved inside tile collision, it will not collide with that tile
  • Collision for objects can be set to be solid to block other objects
  • Objects may get pushed into overlapping other solid objects, if so they will push away
  • Solid objects are more performance intensive and should be used sparingly

Constructor

new EngineObject(posopt, sizeopt, tileInfoopt, angleopt, coloropt, renderOrderopt)

Create an engine object and adds it to the list of objects

Parameters:
NameTypeAttributesDefaultDescription
posVector2<optional>
(0,0)

World space position of the object

sizeVector2<optional>
(1,1)

World space size of the object

tileInfoTileInfo<optional>

Tile info to render object (undefined is untextured)

angleNumber<optional>
0

Angle the object is rotated by

colorColor<optional>
(1,1,1,1)

Color to apply to tile when rendered

renderOrderNumber<optional>
0

Objects sorted by renderOrder before being rendered

Example
// create an engine object, normally you would first extend the class with your own
const pos = vec2(2,3);
const object = new EngineObject(pos); 

Members

additiveColor

Properties
TypeDescription
Color

Additive color to apply when rendered

angle

Properties
TypeDescription
Number

Angle to rotate the object

angleDamping

Properties
NameTypeAttributesDefaultDescription
angleDampingNumber<optional>
objectDefaultAngleDamping

How much to slow down rotation each frame (0-1)

angleVelocity

Properties
TypeDescription
Number

Angular velocity of the object

children

Properties
TypeDescription
Array

List of children of this object

collideSolidObjects

Properties
TypeDescription
Boolean

Object collides with solid objects

collideTiles

Properties
TypeDescription
Boolean

Object collides with the tile collision

color

Properties
TypeDescription
Color

Color to apply when rendered

damping

Properties
NameTypeAttributesDefaultDescription
dampingNumber<optional>
objectDefaultDamping

How much to slow down velocity each frame (0-1)

drawSize

Properties
TypeDescription
Vector2

Size of object used for drawing, uses size if not set

elasticity

Properties
NameTypeAttributesDefaultDescription
elasticityNumber<optional>
objectDefaultElasticity

How bouncy the object is when colliding (0-1)

friction

Properties
NameTypeAttributesDefaultDescription
frictionNumber<optional>
objectDefaultFriction

How much friction to apply when sliding (0-1)

gravityScale

Properties
TypeDescription
Number

How much to scale gravity by for this object

isSolid

Properties
TypeDescription
Boolean

Object collides with and blocks other objects

localAngle

Properties
TypeDescription
Number

Local angle if child

localPos

Properties
TypeDescription
Vector2

Local position if child

mass

Properties
NameTypeAttributesDefaultDescription
massNumber<optional>
objectDefaultMass

How heavy the object is, static if 0

mirror

Properties
TypeDescription
Boolean

Should it flip along y axis when rendered

parent

Properties
TypeDescription
EngineObject

Parent of object if in local space

pos

Properties
TypeDescription
Vector2

World space position of the object

renderOrder

Properties
TypeDescription
Number

Objects are sorted by render order

size

Properties
TypeDescription
Vector2

World space width and height of the object

spawnTime

Properties
TypeDescription
Number

Track when object was created

tileInfo

Properties
TypeDescription
TileInfo

Tile info to render object (undefined is untextured)

velocity

Properties
TypeDescription
Vector2

Velocity of the object

Methods

addChild(child, localPosopt, localAngleopt)

Attaches a child to this with a given local transform

Parameters:
NameTypeAttributesDefaultDescription
childEngineObject
localPosVector2<optional>
(0,0)
localAngleNumber<optional>
0

applyAcceleration(acceleration)

Apply acceleration to this object (adjust velocity, not affected by mass)

Parameters:
NameTypeDescription
accelerationVector2

applyForce(force)

Apply force to this object (adjust velocity, affected by mass)

Parameters:
NameTypeDescription
forceVector2

collideWithObject(object) → {Boolean}

Called to check if a object collision should be resolved

Parameters:
NameTypeDescription
objectEngineObject

the object to test against

Returns:
  • true if the collision should be resolved
Type: 
Boolean

collideWithTile(tileData, pos) → {Boolean}

Called to check if a tile collision should be resolved

Parameters:
NameTypeDescription
tileDataNumber

the value of the tile at the position

posVector2

tile where the collision occured

Returns:
  • true if the collision should be resolved
Type: 
Boolean

collideWithTileRaycast(tileData, pos) → {Boolean}

Called to check if a tile raycast hit

Parameters:
NameTypeDescription
tileDataNumber

the value of the tile at the position

posVector2

tile where the raycast is

Returns:
  • true if the raycast should hit
Type: 
Boolean

destroy()

Destroy this object, destroy it's children, detach it's parent, and mark it for removal

getAliveTime() → {Number}

How long since the object was created

Returns:
Type: 
Number

getMirrorSign() → {Number}

Get the direction of the mirror

Returns:

-1 if this.mirror is true, or 1 if not mirrored

Type: 
Number

removeChild(child)

Removes a child from this one

Parameters:
NameTypeDescription
childEngineObject

render()

Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder

setCollision(collideSolidObjectsopt, isSolidopt, collideTilesopt)

Set how this object collides

Parameters:
NameTypeAttributesDefaultDescription
collideSolidObjectsBoolean<optional>
true

Does it collide with solid objects

isSolidBoolean<optional>
true

Does it collide with and block other objects (expensive in large numbers)

collideTilesBoolean<optional>
true

Does it collide with the tile collision

toString() → {String}

Returns string containg info about this object for debugging

Returns:
Type: 
String

update()

Update the object transform and physics, called automatically by engine once each frame

LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

EngineObject

LittleJS Object Base Object Class

  • Top level object class used by the engine
  • Automatically adds self to object list
  • Will be updated and rendered each frame
  • Renders as a sprite from a tilesheet by default
  • Can have color and additive color applied
  • 2D Physics and collision system
  • Sorted by renderOrder
  • Objects can have children attached
  • Parents are updated before children, and set child transform
  • Call destroy() to get rid of objects

The physics system used by objects is simple and fast with some caveats...

  • Collision uses the axis aligned size, the object's rotation angle is only for rendering
  • Objects are guaranteed to not intersect tile collision from physics
  • If an object starts or is moved inside tile collision, it will not collide with that tile
  • Collision for objects can be set to be solid to block other objects
  • Objects may get pushed into overlapping other solid objects, if so they will push away
  • Solid objects are more performance intensive and should be used sparingly

Constructor

new EngineObject(posopt, sizeopt, tileInfoopt, angleopt, coloropt, renderOrderopt)

Create an engine object and adds it to the list of objects

Parameters:
NameTypeAttributesDefaultDescription
posVector2<optional>
(0,0)

World space position of the object

sizeVector2<optional>
(1,1)

World space size of the object

tileInfoTileInfo<optional>

Tile info to render object (undefined is untextured)

angleNumber<optional>
0

Angle the object is rotated by

colorColor<optional>
(1,1,1,1)

Color to apply to tile when rendered

renderOrderNumber<optional>
0

Objects sorted by renderOrder before being rendered

Example
// create an engine object, normally you would first extend the class with your own
const pos = vec2(2,3);
const object = new EngineObject(pos); 

Members

additiveColor

Properties
TypeDescription
Color

Additive color to apply when rendered

angle

Properties
TypeDescription
Number

Angle to rotate the object

angleDamping

Properties
NameTypeAttributesDefaultDescription
angleDampingNumber<optional>
objectDefaultAngleDamping

How much to slow down rotation each frame (0-1)

angleVelocity

Properties
TypeDescription
Number

Angular velocity of the object

children

Properties
TypeDescription
Array

List of children of this object

collideSolidObjects

Properties
TypeDescription
Boolean

Object collides with solid objects

collideTiles

Properties
TypeDescription
Boolean

Object collides with the tile collision

color

Properties
TypeDescription
Color

Color to apply when rendered

damping

Properties
NameTypeAttributesDefaultDescription
dampingNumber<optional>
objectDefaultDamping

How much to slow down velocity each frame (0-1)

drawSize

Properties
TypeDescription
Vector2

Size of object used for drawing, uses size if not set

elasticity

Properties
NameTypeAttributesDefaultDescription
elasticityNumber<optional>
objectDefaultElasticity

How bouncy the object is when colliding (0-1)

friction

Properties
NameTypeAttributesDefaultDescription
frictionNumber<optional>
objectDefaultFriction

How much friction to apply when sliding (0-1)

gravityScale

Properties
TypeDescription
Number

How much to scale gravity by for this object

isSolid

Properties
TypeDescription
Boolean

Object collides with and blocks other objects

localAngle

Properties
TypeDescription
Number

Local angle if child

localPos

Properties
TypeDescription
Vector2

Local position if child

mass

Properties
NameTypeAttributesDefaultDescription
massNumber<optional>
objectDefaultMass

How heavy the object is, static if 0

mirror

Properties
TypeDescription
Boolean

Should it flip along y axis when rendered

parent

Properties
TypeDescription
EngineObject

Parent of object if in local space

pos

Properties
TypeDescription
Vector2

World space position of the object

renderOrder

Properties
TypeDescription
Number

Objects are sorted by render order

size

Properties
TypeDescription
Vector2

World space width and height of the object

spawnTime

Properties
TypeDescription
Number

Track when object was created

tileInfo

Properties
TypeDescription
TileInfo

Tile info to render object (undefined is untextured)

velocity

Properties
TypeDescription
Vector2

Velocity of the object

Methods

addChild(child, localPosopt, localAngleopt)

Attaches a child to this with a given local transform

Parameters:
NameTypeAttributesDefaultDescription
childEngineObject
localPosVector2<optional>
(0,0)
localAngleNumber<optional>
0

applyAcceleration(acceleration)

Apply acceleration to this object (adjust velocity, not affected by mass)

Parameters:
NameTypeDescription
accelerationVector2

applyForce(force)

Apply force to this object (adjust velocity, affected by mass)

Parameters:
NameTypeDescription
forceVector2

collideWithObject(object) → {Boolean}

Called to check if a object collision should be resolved

Parameters:
NameTypeDescription
objectEngineObject

the object to test against

Returns:
  • true if the collision should be resolved
Type: 
Boolean

collideWithTile(tileData, pos) → {Boolean}

Called to check if a tile collision should be resolved

Parameters:
NameTypeDescription
tileDataNumber

the value of the tile at the position

posVector2

tile where the collision occured

Returns:
  • true if the collision should be resolved
Type: 
Boolean

collideWithTileRaycast(tileData, pos) → {Boolean}

Called to check if a tile raycast hit

Parameters:
NameTypeDescription
tileDataNumber

the value of the tile at the position

posVector2

tile where the raycast is

Returns:
  • true if the raycast should hit
Type: 
Boolean

destroy()

Destroy this object, destroy it's children, detach it's parent, and mark it for removal

getAliveTime() → {Number}

How long since the object was created

Returns:
Type: 
Number

getMirrorSign() → {Number}

Get the direction of the mirror

Returns:

-1 if this.mirror is true, or 1 if not mirrored

Type: 
Number

removeChild(child)

Removes a child from this one

Parameters:
NameTypeDescription
childEngineObject

render()

Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder

setCollision(collideSolidObjectsopt, isSolidopt, collideTilesopt)

Set how this object collides

Parameters:
NameTypeAttributesDefaultDescription
collideSolidObjectsBoolean<optional>
true

Does it collide with solid objects

isSolidBoolean<optional>
true

Does it collide with and block other objects (expensive in large numbers)

collideTilesBoolean<optional>
true

Does it collide with the tile collision

toString() → {String}

Returns string containg info about this object for debugging

Returns:
Type: 
String

update()

Update the object transform and physics, called automatically by engine once each frame

LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/FontImage.html b/docs/FontImage.html index abc5e589..de3d6513 100644 --- a/docs/FontImage.html +++ b/docs/FontImage.html @@ -1,3 +1,3 @@ Class: FontImage
On this page

FontImage

Font Image Object - Draw text on a 2D canvas by using characters in an image

  • 96 characters (from space to tilde) are stored in an image
  • Uses a default 8x8 font if none is supplied
  • You can also use fonts from the main tile sheet

Constructor

new FontImage(imageopt, tileSizeopt, paddingSizeopt, contextopt)

Create an image font

Parameters:
NameTypeAttributesDefaultDescription
imageHTMLImageElement<optional>

Image for the font, if undefined default font is used

tileSizeVector2<optional>
(8,8)

Size of the font source tiles

paddingSizeVector2<optional>
(0,1)

How much extra space to add between characters

contextCanvasRenderingContext2D<optional>
overlayContext

context to draw to

Example
// use built in font
const font = new ImageFont;

// draw text
font.drawTextScreen("LittleJS\nHello World!", vec2(200, 50));

Methods

drawText(text, pos, scaleopt, centeropt)

Draw text in world space using the image font

Parameters:
NameTypeAttributesDefaultDescription
textString
posVector2
scaleNumber<optional>
.25
centerBoolean<optional>

drawTextScreen(text, pos, scaleopt, centeropt)

Draw text in screen space using the image font

Parameters:
NameTypeAttributesDefaultDescription
textString
posVector2
scaleNumber<optional>
4
centerBoolean<optional>
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

FontImage

Font Image Object - Draw text on a 2D canvas by using characters in an image

  • 96 characters (from space to tilde) are stored in an image
  • Uses a default 8x8 font if none is supplied
  • You can also use fonts from the main tile sheet

Constructor

new FontImage(imageopt, tileSizeopt, paddingSizeopt, contextopt)

Create an image font

Parameters:
NameTypeAttributesDefaultDescription
imageHTMLImageElement<optional>

Image for the font, if undefined default font is used

tileSizeVector2<optional>
(8,8)

Size of the font source tiles

paddingSizeVector2<optional>
(0,1)

How much extra space to add between characters

contextCanvasRenderingContext2D<optional>
overlayContext

context to draw to

Example
// use built in font
const font = new ImageFont;

// draw text
font.drawTextScreen("LittleJS\nHello World!", vec2(200, 50));

Methods

drawText(text, pos, scaleopt, centeropt)

Draw text in world space using the image font

Parameters:
NameTypeAttributesDefaultDescription
textString
posVector2
scaleNumber<optional>
.25
centerBoolean<optional>

drawTextScreen(text, pos, scaleopt, centeropt)

Draw text in screen space using the image font

Parameters:
NameTypeAttributesDefaultDescription
textString
posVector2
scaleNumber<optional>
4
centerBoolean<optional>
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/Input.html b/docs/Input.html index a0411c27..53de73dd 100644 --- a/docs/Input.html +++ b/docs/Input.html @@ -1,3 +1,3 @@ Namespace: Input
On this page

Input

LittleJS Input System

  • Tracks keyboard down, pressed, and released
  • Tracks mouse buttons, position, and wheel
  • Tracks multiple analog gamepads
  • Virtual gamepad for touch devices

Members

(static, constant) isTouchDevice

True if a touch device has been detected

(static) isUsingGamepad :Boolean

Returns true if user is using gamepad (has more recently pressed a gamepad button)

Type:
  • Boolean

(static) mousePos :Vector2

Mouse pos in world space

Type:

(static) mousePosScreen :Vector2

Mouse pos in screen space

Type:

(static) mouseWheel :Number

Mouse wheel delta this frame

Type:
  • Number

(static) preventDefaultInput :Boolean

Prevents input continuing to the default browser handling (false by default)

Type:
  • Boolean

Methods

(static) clearInput()

Clears all input

(static) gamepadIsDown(button, gamepadopt) → {Boolean}

Returns true if gamepad button is down

Parameters:
NameTypeAttributesDefaultDescription
buttonNumber
gamepadNumber<optional>
0
Returns:
Type: 
Boolean

(static) gamepadStick(stick, gamepadopt) → {Vector2}

Returns gamepad stick value

Parameters:
NameTypeAttributesDefaultDescription
stickNumber
gamepadNumber<optional>
0
Returns:
Type: 
Vector2

(static) gamepadWasPressed(button, gamepadopt) → {Boolean}

Returns true if gamepad button was pressed

Parameters:
NameTypeAttributesDefaultDescription
buttonNumber
gamepadNumber<optional>
0
Returns:
Type: 
Boolean

(static) gamepadWasReleased(button, gamepadopt) → {Boolean}

Returns true if gamepad button was released

Parameters:
NameTypeAttributesDefaultDescription
buttonNumber
gamepadNumber<optional>
0
Returns:
Type: 
Boolean

(static) keyIsDown(key, deviceopt) → {Boolean}

Returns true if device key is down

Parameters:
NameTypeAttributesDefaultDescription
keyString | Number
deviceNumber<optional>
0
Returns:
Type: 
Boolean

(static) keyWasPressed(key, deviceopt) → {Boolean}

Returns true if device key was pressed this frame

Parameters:
NameTypeAttributesDefaultDescription
keyString | Number
deviceNumber<optional>
0
Returns:
Type: 
Boolean

(static) keyWasReleased(key, deviceopt) → {Boolean}

Returns true if device key was released this frame

Parameters:
NameTypeAttributesDefaultDescription
keyString | Number
deviceNumber<optional>
0
Returns:
Type: 
Boolean

(static) mouseIsDown(button) → {Boolean}

Returns true if mouse button is down

Parameters:
NameTypeDescription
buttonNumber
Returns:
Type: 
Boolean

(static) mouseWasPressed(button) → {Boolean}

Returns true if mouse button was pressed

Parameters:
NameTypeDescription
buttonNumber
Returns:
Type: 
Boolean

(static) mouseWasReleased(button) → {Boolean}

Returns true if mouse button was released

Parameters:
NameTypeDescription
buttonNumber
Returns:
Type: 
Boolean

(static) vibrate(patternopt)

Pulse the vibration hardware if it exists

Parameters:
NameTypeAttributesDefaultDescription
patternNumber | Array<optional>
100

single value in ms or vibration interval array

(static) vibrateStop()

Cancel any ongoing vibration

LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

Input

LittleJS Input System

  • Tracks keyboard down, pressed, and released
  • Tracks mouse buttons, position, and wheel
  • Tracks multiple analog gamepads
  • Virtual gamepad for touch devices

Members

(static, constant) isTouchDevice

True if a touch device has been detected

(static) isUsingGamepad :Boolean

Returns true if user is using gamepad (has more recently pressed a gamepad button)

Type:
  • Boolean

(static) mousePos :Vector2

Mouse pos in world space

Type:

(static) mousePosScreen :Vector2

Mouse pos in screen space

Type:

(static) mouseWheel :Number

Mouse wheel delta this frame

Type:
  • Number

(static) preventDefaultInput :Boolean

Prevents input continuing to the default browser handling (false by default)

Type:
  • Boolean

Methods

(static) clearInput()

Clears all input

(static) gamepadIsDown(button, gamepadopt) → {Boolean}

Returns true if gamepad button is down

Parameters:
NameTypeAttributesDefaultDescription
buttonNumber
gamepadNumber<optional>
0
Returns:
Type: 
Boolean

(static) gamepadStick(stick, gamepadopt) → {Vector2}

Returns gamepad stick value

Parameters:
NameTypeAttributesDefaultDescription
stickNumber
gamepadNumber<optional>
0
Returns:
Type: 
Vector2

(static) gamepadWasPressed(button, gamepadopt) → {Boolean}

Returns true if gamepad button was pressed

Parameters:
NameTypeAttributesDefaultDescription
buttonNumber
gamepadNumber<optional>
0
Returns:
Type: 
Boolean

(static) gamepadWasReleased(button, gamepadopt) → {Boolean}

Returns true if gamepad button was released

Parameters:
NameTypeAttributesDefaultDescription
buttonNumber
gamepadNumber<optional>
0
Returns:
Type: 
Boolean

(static) keyIsDown(key, deviceopt) → {Boolean}

Returns true if device key is down

Parameters:
NameTypeAttributesDefaultDescription
keyString | Number
deviceNumber<optional>
0
Returns:
Type: 
Boolean

(static) keyWasPressed(key, deviceopt) → {Boolean}

Returns true if device key was pressed this frame

Parameters:
NameTypeAttributesDefaultDescription
keyString | Number
deviceNumber<optional>
0
Returns:
Type: 
Boolean

(static) keyWasReleased(key, deviceopt) → {Boolean}

Returns true if device key was released this frame

Parameters:
NameTypeAttributesDefaultDescription
keyString | Number
deviceNumber<optional>
0
Returns:
Type: 
Boolean

(static) mouseIsDown(button) → {Boolean}

Returns true if mouse button is down

Parameters:
NameTypeDescription
buttonNumber
Returns:
Type: 
Boolean

(static) mouseWasPressed(button) → {Boolean}

Returns true if mouse button was pressed

Parameters:
NameTypeDescription
buttonNumber
Returns:
Type: 
Boolean

(static) mouseWasReleased(button) → {Boolean}

Returns true if mouse button was released

Parameters:
NameTypeDescription
buttonNumber
Returns:
Type: 
Boolean

(static) vibrate(patternopt)

Pulse the vibration hardware if it exists

Parameters:
NameTypeAttributesDefaultDescription
patternNumber | Array<optional>
100

single value in ms or vibration interval array

(static) vibrateStop()

Cancel any ongoing vibration

LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/Music.html b/docs/Music.html index 3f74b4c5..90a22b2f 100644 --- a/docs/Music.html +++ b/docs/Music.html @@ -1,3 +1,3 @@ Class: Music
On this page

Music

Music Object - Stores a zzfx music track for later use

Create music with the ZzFXM tracker.

Constructor

new Music(zzfxMusic)

Create a music object and cache the zzfx music samples for later use

Parameters:
NameTypeDescription
zzfxMusic
Example
// create some music
const music_example = new Music(
[
    [                         // instruments
      [,0,400]                // simple note
    ], 
    [                         // patterns
        [                     // pattern 1
            [                 // channel 0
                0, -1,        // instrument 0, left speaker
                1, 0, 9, 1    // channel notes
            ], 
            [                 // channel 1
                0, 1,         // instrument 1, right speaker
                0, 12, 17, -1 // channel notes
            ]
        ],
    ],
    [0, 0, 0, 0], // sequence, play pattern 0 four times
    90            // BPM
]);

// play the music
music_example.play();

Methods

playMusic(volumeopt, loopopt) → {AudioBufferSourceNode}

Play the music

Parameters:
NameTypeAttributesDefaultDescription
volumeNumber<optional>
1

How much to scale volume by

loopBoolean<optional>
1

True if the music should loop

Returns:
  • The audio source node
Type: 
AudioBufferSourceNode
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

Music

Music Object - Stores a zzfx music track for later use

Create music with the ZzFXM tracker.

Constructor

new Music(zzfxMusic)

Create a music object and cache the zzfx music samples for later use

Parameters:
NameTypeDescription
zzfxMusic
Example
// create some music
const music_example = new Music(
[
    [                         // instruments
      [,0,400]                // simple note
    ], 
    [                         // patterns
        [                     // pattern 1
            [                 // channel 0
                0, -1,        // instrument 0, left speaker
                1, 0, 9, 1    // channel notes
            ], 
            [                 // channel 1
                0, 1,         // instrument 0, right speaker
                0, 12, 17, -1 // channel notes
            ]
        ],
    ],
    [0, 0, 0, 0], // sequence, play pattern 0 four times
    90            // BPM
]);

// play the music
music_example.play();

Methods

playMusic(volumeopt, loopopt) → {AudioBufferSourceNode}

Play the music

Parameters:
NameTypeAttributesDefaultDescription
volumeNumber<optional>
1

How much to scale volume by

loopBoolean<optional>
false

True if the music should loop

Returns:
  • The audio source node
Type: 
AudioBufferSourceNode
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/Particle.html b/docs/Particle.html index f4406d86..401eb7b3 100644 --- a/docs/Particle.html +++ b/docs/Particle.html @@ -1,3 +1,3 @@ Class: Particle
On this page

Particle

Particle Object - Created automatically by Particle Emitters

Constructor

new Particle(position, tileInfoopt, angleopt, colorStartopt, colorEndopt, lifeTimeopt, sizeStartopt, sizeEndopt, fadeRateopt, additiveopt, trailScaleopt, localSpaceEmitteropt, destroyCallbackopt)

Create a particle with the given shis.colorStart = undefined;ettings

Parameters:
NameTypeAttributesDescription
positionVector2

World space position of the particle

tileInfoTileInfo<optional>

Tile info to render particles

angleNumber<optional>

Angle to rotate the particle

colorStartColor<optional>

Color at start of life

colorEndColor<optional>

Color at end of life

lifeTimeNumber<optional>

How long to live for

sizeStartNumber<optional>

Angle to rotate the particle

sizeEndNumber<optional>

Angle to rotate the particle

fadeRateNumber<optional>

Angle to rotate the particle

additiveBoolean<optional>

Angle to rotate the particle

trailScaleNumber<optional>

If a trail, how long to make it

localSpaceEmitterParticleEmitter<optional>

Parent emitter if local space

destroyCallbackfunction<optional>

Called when particle dies

Extends

Members

additive

Properties
TypeDescription
Boolean

Is it additive

additiveColor

Properties
TypeDescription
Color

Additive color to apply when rendered

angle

Properties
TypeDescription
Number

Angle to rotate the object

angleDamping

Properties
NameTypeAttributesDefaultDescription
angleDampingNumber<optional>
objectDefaultAngleDamping

How much to slow down rotation each frame (0-1)

angleVelocity

Properties
TypeDescription
Number

Angular velocity of the object

children

Properties
TypeDescription
Array

List of children of this object

collideSolidObjects

Properties
TypeDescription
Boolean

Object collides with solid objects

collideTiles

Properties
TypeDescription
Boolean

Object collides with the tile collision

color

Properties
TypeDescription
Color

Color to apply when rendered

colorEndDelta

Properties
TypeDescription
Color

Calculated change in color

colorStart

Properties
TypeDescription
Color

Color at start of life

damping

Properties
NameTypeAttributesDefaultDescription
dampingNumber<optional>
objectDefaultDamping

How much to slow down velocity each frame (0-1)

destroyCallback

Properties
TypeDescription
function

Called when particle dies

drawSize

Properties
TypeDescription
Vector2

Size of object used for drawing, uses size if not set

elasticity

Properties
NameTypeAttributesDefaultDescription
elasticityNumber<optional>
objectDefaultElasticity

How bouncy the object is when colliding (0-1)

fadeRate

Properties
TypeDescription
Number

How quick to fade in/out

friction

Properties
NameTypeAttributesDefaultDescription
frictionNumber<optional>
objectDefaultFriction

How much friction to apply when sliding (0-1)

gravityScale

Properties
TypeDescription
Number

How much to scale gravity by for this object

isSolid

Properties
TypeDescription
Boolean

Object collides with and blocks other objects

lifeTime

Properties
TypeDescription
Number

How long to live for

localAngle

Properties
TypeDescription
Number

Local angle if child

localPos

Properties
TypeDescription
Vector2

Local position if child

localSpaceEmitter

Properties
TypeDescription
ParticleEmitter

Parent emitter if local space

mass

Properties
NameTypeAttributesDefaultDescription
massNumber<optional>
objectDefaultMass

How heavy the object is, static if 0

mirror

Properties
TypeDescription
Boolean

Should it flip along y axis when rendered

parent

Properties
TypeDescription
EngineObject

Parent of object if in local space

pos

Properties
TypeDescription
Vector2

World space position of the object

renderOrder

Properties
TypeDescription
Number

Objects are sorted by render order

size

Properties
TypeDescription
Vector2

World space width and height of the object

sizeEndDelta

Properties
TypeDescription
Number

Calculated change in size

sizeStart

Properties
TypeDescription
Number

Size at start of life

spawnTime

Properties
TypeDescription
Number

Track when object was created

tileInfo

Properties
TypeDescription
TileInfo

Tile info to render object (undefined is untextured)

trailScale

Properties
TypeDescription
Number

If a trail, how long to make it

velocity

Properties
TypeDescription
Vector2

Velocity of the object

Methods

addChild(child, localPosopt, localAngleopt)

Attaches a child to this with a given local transform

Parameters:
NameTypeAttributesDefaultDescription
childEngineObject
localPosVector2<optional>
(0,0)
localAngleNumber<optional>
0

applyAcceleration(acceleration)

Apply acceleration to this object (adjust velocity, not affected by mass)

Parameters:
NameTypeDescription
accelerationVector2

applyForce(force)

Apply force to this object (adjust velocity, affected by mass)

Parameters:
NameTypeDescription
forceVector2

collideWithObject(object) → {Boolean}

Called to check if a object collision should be resolved

Parameters:
NameTypeDescription
objectEngineObject

the object to test against

Returns:
  • true if the collision should be resolved
Type: 
Boolean

collideWithTile(tileData, pos) → {Boolean}

Called to check if a tile collision should be resolved

Parameters:
NameTypeDescription
tileDataNumber

the value of the tile at the position

posVector2

tile where the collision occured

Returns:
  • true if the collision should be resolved
Type: 
Boolean

collideWithTileRaycast(tileData, pos) → {Boolean}

Called to check if a tile raycast hit

Parameters:
NameTypeDescription
tileDataNumber

the value of the tile at the position

posVector2

tile where the raycast is

Returns:
  • true if the raycast should hit
Type: 
Boolean

destroy()

Destroy this object, destroy it's children, detach it's parent, and mark it for removal

getAliveTime() → {Number}

How long since the object was created

Returns:
Type: 
Number

getMirrorSign() → {Number}

Get the direction of the mirror

Returns:

-1 if this.mirror is true, or 1 if not mirrored

Type: 
Number

removeChild(child)

Removes a child from this one

Parameters:
NameTypeDescription
childEngineObject

render()

Render the particle, automatically called each frame, sorted by renderOrder

setCollision(collideSolidObjectsopt, isSolidopt, collideTilesopt)

Set how this object collides

Parameters:
NameTypeAttributesDefaultDescription
collideSolidObjectsBoolean<optional>
true

Does it collide with solid objects

isSolidBoolean<optional>
true

Does it collide with and block other objects (expensive in large numbers)

collideTilesBoolean<optional>
true

Does it collide with the tile collision

toString() → {String}

Returns string containg info about this object for debugging

Returns:
Type: 
String

update()

Update the object transform and physics, called automatically by engine once each frame

LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

Particle

Particle Object - Created automatically by Particle Emitters

Constructor

new Particle(position, tileInfoopt, angleopt, colorStartopt, colorEndopt, lifeTimeopt, sizeStartopt, sizeEndopt, fadeRateopt, additiveopt, trailScaleopt, localSpaceEmitteropt, destroyCallbackopt)

Create a particle with the given shis.colorStart = undefined;ettings

Parameters:
NameTypeAttributesDescription
positionVector2

World space position of the particle

tileInfoTileInfo<optional>

Tile info to render particles

angleNumber<optional>

Angle to rotate the particle

colorStartColor<optional>

Color at start of life

colorEndColor<optional>

Color at end of life

lifeTimeNumber<optional>

How long to live for

sizeStartNumber<optional>

Angle to rotate the particle

sizeEndNumber<optional>

Angle to rotate the particle

fadeRateNumber<optional>

Angle to rotate the particle

additiveBoolean<optional>

Angle to rotate the particle

trailScaleNumber<optional>

If a trail, how long to make it

localSpaceEmitterParticleEmitter<optional>

Parent emitter if local space

destroyCallbackfunction<optional>

Called when particle dies

Extends

Members

additive

Properties
TypeDescription
Boolean

Is it additive

additiveColor

Properties
TypeDescription
Color

Additive color to apply when rendered

angle

Properties
TypeDescription
Number

Angle to rotate the object

angleDamping

Properties
NameTypeAttributesDefaultDescription
angleDampingNumber<optional>
objectDefaultAngleDamping

How much to slow down rotation each frame (0-1)

angleVelocity

Properties
TypeDescription
Number

Angular velocity of the object

children

Properties
TypeDescription
Array

List of children of this object

collideSolidObjects

Properties
TypeDescription
Boolean

Object collides with solid objects

collideTiles

Properties
TypeDescription
Boolean

Object collides with the tile collision

color

Properties
TypeDescription
Color

Color to apply when rendered

colorEndDelta

Properties
TypeDescription
Color

Calculated change in color

colorStart

Properties
TypeDescription
Color

Color at start of life

damping

Properties
NameTypeAttributesDefaultDescription
dampingNumber<optional>
objectDefaultDamping

How much to slow down velocity each frame (0-1)

destroyCallback

Properties
TypeDescription
function

Called when particle dies

drawSize

Properties
TypeDescription
Vector2

Size of object used for drawing, uses size if not set

elasticity

Properties
NameTypeAttributesDefaultDescription
elasticityNumber<optional>
objectDefaultElasticity

How bouncy the object is when colliding (0-1)

fadeRate

Properties
TypeDescription
Number

How quick to fade in/out

friction

Properties
NameTypeAttributesDefaultDescription
frictionNumber<optional>
objectDefaultFriction

How much friction to apply when sliding (0-1)

gravityScale

Properties
TypeDescription
Number

How much to scale gravity by for this object

isSolid

Properties
TypeDescription
Boolean

Object collides with and blocks other objects

lifeTime

Properties
TypeDescription
Number

How long to live for

localAngle

Properties
TypeDescription
Number

Local angle if child

localPos

Properties
TypeDescription
Vector2

Local position if child

localSpaceEmitter

Properties
TypeDescription
ParticleEmitter

Parent emitter if local space

mass

Properties
NameTypeAttributesDefaultDescription
massNumber<optional>
objectDefaultMass

How heavy the object is, static if 0

mirror

Properties
TypeDescription
Boolean

Should it flip along y axis when rendered

parent

Properties
TypeDescription
EngineObject

Parent of object if in local space

pos

Properties
TypeDescription
Vector2

World space position of the object

renderOrder

Properties
TypeDescription
Number

Objects are sorted by render order

size

Properties
TypeDescription
Vector2

World space width and height of the object

sizeEndDelta

Properties
TypeDescription
Number

Calculated change in size

sizeStart

Properties
TypeDescription
Number

Size at start of life

spawnTime

Properties
TypeDescription
Number

Track when object was created

tileInfo

Properties
TypeDescription
TileInfo

Tile info to render object (undefined is untextured)

trailScale

Properties
TypeDescription
Number

If a trail, how long to make it

velocity

Properties
TypeDescription
Vector2

Velocity of the object

Methods

addChild(child, localPosopt, localAngleopt)

Attaches a child to this with a given local transform

Parameters:
NameTypeAttributesDefaultDescription
childEngineObject
localPosVector2<optional>
(0,0)
localAngleNumber<optional>
0

applyAcceleration(acceleration)

Apply acceleration to this object (adjust velocity, not affected by mass)

Parameters:
NameTypeDescription
accelerationVector2

applyForce(force)

Apply force to this object (adjust velocity, affected by mass)

Parameters:
NameTypeDescription
forceVector2

collideWithObject(object) → {Boolean}

Called to check if a object collision should be resolved

Parameters:
NameTypeDescription
objectEngineObject

the object to test against

Returns:
  • true if the collision should be resolved
Type: 
Boolean

collideWithTile(tileData, pos) → {Boolean}

Called to check if a tile collision should be resolved

Parameters:
NameTypeDescription
tileDataNumber

the value of the tile at the position

posVector2

tile where the collision occured

Returns:
  • true if the collision should be resolved
Type: 
Boolean

collideWithTileRaycast(tileData, pos) → {Boolean}

Called to check if a tile raycast hit

Parameters:
NameTypeDescription
tileDataNumber

the value of the tile at the position

posVector2

tile where the raycast is

Returns:
  • true if the raycast should hit
Type: 
Boolean

destroy()

Destroy this object, destroy it's children, detach it's parent, and mark it for removal

getAliveTime() → {Number}

How long since the object was created

Returns:
Type: 
Number

getMirrorSign() → {Number}

Get the direction of the mirror

Returns:

-1 if this.mirror is true, or 1 if not mirrored

Type: 
Number

removeChild(child)

Removes a child from this one

Parameters:
NameTypeDescription
childEngineObject

render()

Render the particle, automatically called each frame, sorted by renderOrder

setCollision(collideSolidObjectsopt, isSolidopt, collideTilesopt)

Set how this object collides

Parameters:
NameTypeAttributesDefaultDescription
collideSolidObjectsBoolean<optional>
true

Does it collide with solid objects

isSolidBoolean<optional>
true

Does it collide with and block other objects (expensive in large numbers)

collideTilesBoolean<optional>
true

Does it collide with the tile collision

toString() → {String}

Returns string containg info about this object for debugging

Returns:
Type: 
String

update()

Update the object transform and physics, called automatically by engine once each frame

LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/Settings.html b/docs/Settings.html index ca5ca08a..3f310b60 100644 --- a/docs/Settings.html +++ b/docs/Settings.html @@ -1,3 +1,3 @@ Namespace: Settings
On this page

Settings

LittleJS Engine Settings

  • All settings for the engine are here

Members

(static) cameraPos :Vector2

Position of camera in world space

Type:
Default Value
  • Vector2()

(static) cameraScale :Number

Scale of camera in world space

Type:
  • Number
Default Value
  • 32

(static) canvasFixedSize :Vector2

Fixed size of the canvas, if enabled canvas size never changes

  • you may also need to set mainCanvasSize if using screen space coords in startup
Type:
Default Value
  • Vector2()

(static) canvasMaxSize :Vector2

The max size of the canvas, centered if window is larger

Type:
Default Value
  • Vector2(1920,1200)

(static) canvasPixelated :Boolean

Disables filtering for crisper pixel art if true

Type:
  • Boolean
Default Value
  • true

(static) enablePhysicsSolver :Boolean

Enable physics solver for collisions between objects

Type:
  • Boolean
Default Value
  • true

(static) fontDefault :String

Default font used for text rendering

Type:
  • String
Default Value
  • arial

(static) gamepadDirectionEmulateStick :Boolean

If true, the dpad input is also routed to the left analog stick (for better accessability)

Type:
  • Boolean
Default Value
  • true

(static) gamepadsEnable :Boolean

Should gamepads be allowed

Type:
  • Boolean
Default Value
  • true

(static) glEnable :Boolean

Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)

Type:
  • Boolean
Default Value
  • true

(static) glOverlay :Boolean

Fixes slow rendering in some browsers by not compositing the WebGL canvas

Type:
  • Boolean
Default Value
  • true

(static) gravity :Number

How much gravity to apply to objects along the Y axis, negative is down

Type:
  • Number

(static) inputWASDEmulateDirection :Boolean

If true the WASD keys are also routed to the direction keys (for better accessability)

Type:
  • Boolean
Default Value
  • true

(static) medalDisplayIconSize :Number

Size of icon in medal display

Type:
  • Number
Default Value
  • 50

(static) medalDisplaySize :Vector2

Size of medal display

Type:
Default Value
  • Vector2(640,80)

(static) medalDisplaySlideTime :Number

How quickly to slide on/off medals in seconds

Type:
  • Number
Default Value
  • 0.5

(static) medalDisplayTime :Number

How long to show medals for in seconds

Type:
  • Number
Default Value
  • 5

(static) medalsPreventUnlock :Boolean

Set to stop medals from being unlockable (like if cheats are enabled)

Type:
  • Boolean

(static) objectDefaultAngleDamping :Number

How much to slow angular velocity each frame (0-1)

Type:
  • Number
Default Value
  • 1

(static) objectDefaultDamping :Number

How much to slow velocity by each frame (0-1)

Type:
  • Number
Default Value
  • 1

(static) objectDefaultElasticity :Number

How much to bounce when a collision occurs (0-1)

Type:
  • Number

(static) objectDefaultFriction :Number

How much to slow when touching (0-1)

Type:
  • Number
Default Value
  • 0.8

(static) objectDefaultMass :Number

Default object mass for collison calcuations (how heavy objects are)

Type:
  • Number
Default Value
  • 1

(static) objectMaxSpeed :Number

Clamp max speed to avoid fast objects missing collisions

Type:
  • Number
Default Value
  • 1

(static) particleEmitRateScale :Number

Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)

Type:
  • Number
Default Value
  • 1

(static) showSplashScreen :Boolean

Enable to show the LittleJS splash screen be shown on startup

Type:
  • Boolean

(static) soundDefaultRange :Number

Default range where sound no longer plays

Type:
  • Number
Default Value
  • 40

(static) soundDefaultTaper :Number

Default range percent to start tapering off sound (0-1)

Type:
  • Number
Default Value
  • 0.7

(static) soundEnable :Boolean

All audio code can be disabled and removed from build

Type:
  • Boolean
Default Value
  • true

(static) soundVolume :Number

Volume scale to apply to all sound, music and speech

Type:
  • Number
Default Value
  • 0.5

(static) tileFixBleedScale :Number

How many pixels smaller to draw tiles to prevent bleeding from neighbors

Type:
  • Number
Default Value
  • 0.3

(static) tileSizeDefault :Vector2

Default size of tiles in pixels

Type:
Default Value
  • Vector2(16,16)

(static) touchGamepadAlpha :Number

Transparency of touch gamepad overlay

Type:
  • Number
Default Value
  • 0.3

(static) touchGamepadAnalog :Boolean

True if touch gamepad should be analog stick or false to use if 8 way dpad

Type:
  • Boolean
Default Value
  • true

(static) touchGamepadEnable :Boolean

True if touch gamepad should appear on mobile devices

  • Supports left analog stick, 4 face buttons and start button (button 9)
  • Must be set by end of gameInit to be activated
Type:
  • Boolean

(static) touchGamepadSize :Number

Size of virutal gamepad for touch devices in pixels

Type:
  • Number
Default Value
  • 99

(static) vibrateEnable :Boolean

Allow vibration hardware if it exists

Type:
  • Boolean
Default Value
  • true

Methods

(static) setCameraPos(pos)

Set position of camera in world space

Parameters:
NameTypeDescription
posVector2

(static) setCameraScale(scale)

Set scale of camera in world space

Parameters:
NameTypeDescription
scaleNumber

(static) setCanvasFixedSize(size)

Set fixed size of the canvas

Parameters:
NameTypeDescription
sizeVector2

(static) setCanvasMaxSize(size)

Set max size of the canvas

Parameters:
NameTypeDescription
sizeVector2

(static) setCanvasPixelated(pixelated)

Disables anti aliasing for pixel art if true

Parameters:
NameTypeDescription
pixelatedBoolean

(static) setEnablePhysicsSolver(enable)

Set if collisions between objects are enabled

Parameters:
NameTypeDescription
enableBoolean

(static) setFontDefault(font)

Set default font used for text rendering

Parameters:
NameTypeDescription
fontString

(static) setGamepadDirectionEmulateStick(enable)

Set if the dpad input is also routed to the left analog stick

Parameters:
NameTypeDescription
enableBoolean

(static) setGamepadsEnable(enable)

Set if gamepads are enabled

Parameters:
NameTypeDescription
enableBoolean

(static) setGlEnable(enable)

Set if webgl rendering is enabled

Parameters:
NameTypeDescription
enableBoolean

(static) setGlOverlay(overlay)

Set to not composite the WebGL canvas

Parameters:
NameTypeDescription
overlayBoolean

(static) setGravity(newGravity)

Set how much gravity to apply to objects along the Y axis

Parameters:
NameTypeDescription
newGravityNumber

(static) setInputWASDEmulateDirection(enable)

Set if true the WASD keys are also routed to the direction keys

Parameters:
NameTypeDescription
enableBoolean

(static) setMedalDisplayIconSize(size)

Set size of icon in medal display

Parameters:
NameTypeDescription
sizeNumber

(static) setMedalDisplaySize(size)

Set size of medal display

Parameters:
NameTypeDescription
sizeVector2

(static) setMedalDisplaySlideTime(time)

Set how quickly to slide on/off medals in seconds

Parameters:
NameTypeDescription
timeNumber

(static) setMedalDisplayTime(time)

Set how long to show medals for in seconds

Parameters:
NameTypeDescription
timeNumber

(static) setMedalsPreventUnlock(preventUnlock)

Set to stop medals from being unlockable

Parameters:
NameTypeDescription
preventUnlockBoolean

(static) setObjectDefaultAngleDamping(damp)

Set how much to slow angular velocity each frame

Parameters:
NameTypeDescription
dampNumber

(static) setObjectDefaultDamping(damp)

Set how much to slow velocity by each frame

Parameters:
NameTypeDescription
dampNumber

(static) setObjectDefaultElasticity(elasticity)

Set how much to bounce when a collision occur

Parameters:
NameTypeDescription
elasticityNumber

(static) setObjectDefaultFriction(friction)

Set how much to slow when touching

Parameters:
NameTypeDescription
frictionNumber

(static) setObjectDefaultMass(mass)

Set default object mass for collison calcuations

Parameters:
NameTypeDescription
massNumber

(static) setObjectMaxSpeed(speed)

Set max speed to avoid fast objects missing collisions

Parameters:
NameTypeDescription
speedNumber

(static) setParticleEmitRateScale(scale)

Set to scales emit rate of particles

Parameters:
NameTypeDescription
scaleNumber

(static) setShowSplashScreen(show)

Set if the LittleJS splash screen be shown on startup

Parameters:
NameTypeDescription
showBoolean

(static) setSoundDefaultRange(range)

Set default range where sound no longer plays

Parameters:
NameTypeDescription
rangeNumber

(static) setSoundDefaultTaper(taper)

Set default range percent to start tapering off sound

Parameters:
NameTypeDescription
taperNumber

(static) setSoundEnable(enable)

Set to disable all audio code

Parameters:
NameTypeDescription
enableBoolean

(static) setSoundVolume(volume)

Set volume scale to apply to all sound, music and speech

Parameters:
NameTypeDescription
volumeNumber

(static) setTileFixBleedScale(scale)

Set to prevent tile bleeding from neighbors in pixels

Parameters:
NameTypeDescription
scaleNumber

(static) setTileSizeDefault(size)

Set default size of tiles in pixels

Parameters:
NameTypeDescription
sizeVector2

(static) setTouchGamepadAlpha(alpha)

Set transparency of touch gamepad overlay

Parameters:
NameTypeDescription
alphaNumber

(static) setTouchGamepadAnalog(analog)

Set if touch gamepad should be analog stick or 8 way dpad

Parameters:
NameTypeDescription
analogBoolean

(static) setTouchGamepadEnable(enable)

Set if touch gamepad should appear on mobile devices

Parameters:
NameTypeDescription
enableBoolean

(static) setTouchGamepadSize(size)

Set size of virutal gamepad for touch devices in pixels

Parameters:
NameTypeDescription
sizeNumber

(static) setVibrateEnable(enable)

Set to allow vibration hardware if it exists

Parameters:
NameTypeDescription
enableBoolean
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

Settings

LittleJS Engine Settings

  • All settings for the engine are here

Members

(static) cameraPos :Vector2

Position of camera in world space

Type:
Default Value
  • Vector2()

(static) cameraScale :Number

Scale of camera in world space

Type:
  • Number
Default Value
  • 32

(static) canvasFixedSize :Vector2

Fixed size of the canvas, if enabled canvas size never changes

  • you may also need to set mainCanvasSize if using screen space coords in startup
Type:
Default Value
  • Vector2()

(static) canvasMaxSize :Vector2

The max size of the canvas, centered if window is larger

Type:
Default Value
  • Vector2(1920,1200)

(static) canvasPixelated :Boolean

Disables filtering for crisper pixel art if true

Type:
  • Boolean
Default Value
  • true

(static) enablePhysicsSolver :Boolean

Enable physics solver for collisions between objects

Type:
  • Boolean
Default Value
  • true

(static) fontDefault :String

Default font used for text rendering

Type:
  • String
Default Value
  • arial

(static) gamepadDirectionEmulateStick :Boolean

If true, the dpad input is also routed to the left analog stick (for better accessability)

Type:
  • Boolean
Default Value
  • true

(static) gamepadsEnable :Boolean

Should gamepads be allowed

Type:
  • Boolean
Default Value
  • true

(static) glEnable :Boolean

Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)

Type:
  • Boolean
Default Value
  • true

(static) glOverlay :Boolean

Fixes slow rendering in some browsers by not compositing the WebGL canvas

Type:
  • Boolean
Default Value
  • true

(static) gravity :Number

How much gravity to apply to objects along the Y axis, negative is down

Type:
  • Number

(static) inputWASDEmulateDirection :Boolean

If true the WASD keys are also routed to the direction keys (for better accessability)

Type:
  • Boolean
Default Value
  • true

(static) medalDisplayIconSize :Number

Size of icon in medal display

Type:
  • Number
Default Value
  • 50

(static) medalDisplaySize :Vector2

Size of medal display

Type:
Default Value
  • Vector2(640,80)

(static) medalDisplaySlideTime :Number

How quickly to slide on/off medals in seconds

Type:
  • Number
Default Value
  • 0.5

(static) medalDisplayTime :Number

How long to show medals for in seconds

Type:
  • Number
Default Value
  • 5

(static) medalsPreventUnlock :Boolean

Set to stop medals from being unlockable (like if cheats are enabled)

Type:
  • Boolean

(static) objectDefaultAngleDamping :Number

How much to slow angular velocity each frame (0-1)

Type:
  • Number
Default Value
  • 1

(static) objectDefaultDamping :Number

How much to slow velocity by each frame (0-1)

Type:
  • Number
Default Value
  • 1

(static) objectDefaultElasticity :Number

How much to bounce when a collision occurs (0-1)

Type:
  • Number

(static) objectDefaultFriction :Number

How much to slow when touching (0-1)

Type:
  • Number
Default Value
  • 0.8

(static) objectDefaultMass :Number

Default object mass for collision calcuations (how heavy objects are)

Type:
  • Number
Default Value
  • 1

(static) objectMaxSpeed :Number

Clamp max speed to avoid fast objects missing collisions

Type:
  • Number
Default Value
  • 1

(static) particleEmitRateScale :Number

Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)

Type:
  • Number
Default Value
  • 1

(static) showSplashScreen :Boolean

Enable to show the LittleJS splash screen be shown on startup

Type:
  • Boolean

(static) soundDefaultRange :Number

Default range where sound no longer plays

Type:
  • Number
Default Value
  • 40

(static) soundDefaultTaper :Number

Default range percent to start tapering off sound (0-1)

Type:
  • Number
Default Value
  • 0.7

(static) soundEnable :Boolean

All audio code can be disabled and removed from build

Type:
  • Boolean
Default Value
  • true

(static) soundVolume :Number

Volume scale to apply to all sound, music and speech

Type:
  • Number
Default Value
  • 0.5

(static) tileFixBleedScale :Number

How many pixels smaller to draw tiles to prevent bleeding from neighbors

Type:
  • Number
Default Value
  • 0.1

(static) tileSizeDefault :Vector2

Default size of tiles in pixels

Type:
Default Value
  • Vector2(16,16)

(static) touchGamepadAlpha :Number

Transparency of touch gamepad overlay

Type:
  • Number
Default Value
  • 0.3

(static) touchGamepadAnalog :Boolean

True if touch gamepad should be analog stick or false to use if 8 way dpad

Type:
  • Boolean
Default Value
  • true

(static) touchGamepadEnable :Boolean

True if touch gamepad should appear on mobile devices

  • Supports left analog stick, 4 face buttons and start button (button 9)
  • Must be set by end of gameInit to be activated
Type:
  • Boolean

(static) touchGamepadSize :Number

Size of virtual gamepad for touch devices in pixels

Type:
  • Number
Default Value
  • 99

(static) vibrateEnable :Boolean

Allow vibration hardware if it exists

Type:
  • Boolean
Default Value
  • true

Methods

(static) setCameraPos(pos)

Set position of camera in world space

Parameters:
NameTypeDescription
posVector2

(static) setCameraScale(scale)

Set scale of camera in world space

Parameters:
NameTypeDescription
scaleNumber

(static) setCanvasFixedSize(size)

Set fixed size of the canvas

Parameters:
NameTypeDescription
sizeVector2

(static) setCanvasMaxSize(size)

Set max size of the canvas

Parameters:
NameTypeDescription
sizeVector2

(static) setCanvasPixelated(pixelated)

Disables anti aliasing for pixel art if true

Parameters:
NameTypeDescription
pixelatedBoolean

(static) setEnablePhysicsSolver(enable)

Set if collisions between objects are enabled

Parameters:
NameTypeDescription
enableBoolean

(static) setFontDefault(font)

Set default font used for text rendering

Parameters:
NameTypeDescription
fontString

(static) setGamepadDirectionEmulateStick(enable)

Set if the dpad input is also routed to the left analog stick

Parameters:
NameTypeDescription
enableBoolean

(static) setGamepadsEnable(enable)

Set if gamepads are enabled

Parameters:
NameTypeDescription
enableBoolean

(static) setGlEnable(enable)

Set if webgl rendering is enabled

Parameters:
NameTypeDescription
enableBoolean

(static) setGlOverlay(overlay)

Set to not composite the WebGL canvas

Parameters:
NameTypeDescription
overlayBoolean

(static) setGravity(newGravity)

Set how much gravity to apply to objects along the Y axis

Parameters:
NameTypeDescription
newGravityNumber

(static) setInputWASDEmulateDirection(enable)

Set if true the WASD keys are also routed to the direction keys

Parameters:
NameTypeDescription
enableBoolean

(static) setMedalDisplayIconSize(size)

Set size of icon in medal display

Parameters:
NameTypeDescription
sizeNumber

(static) setMedalDisplaySize(size)

Set size of medal display

Parameters:
NameTypeDescription
sizeVector2

(static) setMedalDisplaySlideTime(time)

Set how quickly to slide on/off medals in seconds

Parameters:
NameTypeDescription
timeNumber

(static) setMedalDisplayTime(time)

Set how long to show medals for in seconds

Parameters:
NameTypeDescription
timeNumber

(static) setMedalsPreventUnlock(preventUnlock)

Set to stop medals from being unlockable

Parameters:
NameTypeDescription
preventUnlockBoolean

(static) setObjectDefaultAngleDamping(damp)

Set how much to slow angular velocity each frame

Parameters:
NameTypeDescription
dampNumber

(static) setObjectDefaultDamping(damp)

Set how much to slow velocity by each frame

Parameters:
NameTypeDescription
dampNumber

(static) setObjectDefaultElasticity(elasticity)

Set how much to bounce when a collision occur

Parameters:
NameTypeDescription
elasticityNumber

(static) setObjectDefaultFriction(friction)

Set how much to slow when touching

Parameters:
NameTypeDescription
frictionNumber

(static) setObjectDefaultMass(mass)

Set default object mass for collison calcuations

Parameters:
NameTypeDescription
massNumber

(static) setObjectMaxSpeed(speed)

Set max speed to avoid fast objects missing collisions

Parameters:
NameTypeDescription
speedNumber

(static) setParticleEmitRateScale(scale)

Set to scales emit rate of particles

Parameters:
NameTypeDescription
scaleNumber

(static) setShowSplashScreen(show)

Set if the LittleJS splash screen be shown on startup

Parameters:
NameTypeDescription
showBoolean

(static) setSoundDefaultRange(range)

Set default range where sound no longer plays

Parameters:
NameTypeDescription
rangeNumber

(static) setSoundDefaultTaper(taper)

Set default range percent to start tapering off sound

Parameters:
NameTypeDescription
taperNumber

(static) setSoundEnable(enable)

Set to disable all audio code

Parameters:
NameTypeDescription
enableBoolean

(static) setSoundVolume(volume)

Set volume scale to apply to all sound, music and speech

Parameters:
NameTypeDescription
volumeNumber

(static) setTileFixBleedScale(scale)

Set to prevent tile bleeding from neighbors in pixels

Parameters:
NameTypeDescription
scaleNumber

(static) setTileSizeDefault(size)

Set default size of tiles in pixels

Parameters:
NameTypeDescription
sizeVector2

(static) setTouchGamepadAlpha(alpha)

Set transparency of touch gamepad overlay

Parameters:
NameTypeDescription
alphaNumber

(static) setTouchGamepadAnalog(analog)

Set if touch gamepad should be analog stick or 8 way dpad

Parameters:
NameTypeDescription
analogBoolean

(static) setTouchGamepadEnable(enable)

Set if touch gamepad should appear on mobile devices

Parameters:
NameTypeDescription
enableBoolean

(static) setTouchGamepadSize(size)

Set size of virutal gamepad for touch devices in pixels

Parameters:
NameTypeDescription
sizeNumber

(static) setVibrateEnable(enable)

Set to allow vibration hardware if it exists

Parameters:
NameTypeDescription
enableBoolean
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/Sound.html b/docs/Sound.html index a4d65ee2..ea7f5b0b 100644 --- a/docs/Sound.html +++ b/docs/Sound.html @@ -1,3 +1,3 @@ Class: Sound
On this page

Sound

Sound Object - Stores a zzfx sound for later use and can be played positionally

Create sounds using the ZzFX Sound Designer.

Constructor

new Sound(zzfxSound, rangeopt, taperopt)

Create a sound object and cache the zzfx samples for later use

Parameters:
NameTypeAttributesDefaultDescription
zzfxSoundArray

Array of zzfx parameters, ex. [.5,.5]

rangeNumber<optional>
soundDefaultRange

World space max range of sound, will not play if camera is farther away

taperNumber<optional>
soundDefaultTaper

At what percentage of range should it start tapering off

Example
// create a sound
const sound_example = new Sound([.5,.5]);

// play the sound
sound_example.play();

Members

randomness

Properties
TypeDescription
Number

How much to randomize frequency each time sound plays

range

Properties
TypeDescription
Number

World space max range of sound, will not play if camera is farther away

taper

Properties
TypeDescription
Number

At what percentage of range should it start tapering off

Methods

getDuration() → {Number}

Get how long this sound is in seconds

Returns:
  • How long the sound is in seconds (undefined if loading)
Type: 
Number

getSource() → {AudioBufferSourceNode}

Get source of most recent instance of this sound that was played

Returns:
Type: 
AudioBufferSourceNode

isLoading() → {Boolean}

Check if sound is loading, for sounds fetched from a url

Returns:
  • True if sound is loading and not ready to play
Type: 
Boolean

play(posopt, volumeopt, pitchopt, randomnessScaleopt, loopopt) → {AudioBufferSourceNode}

Play the sound

Parameters:
NameTypeAttributesDefaultDescription
posVector2<optional>

World space position to play the sound, sound is not attenuated if null

volumeNumber<optional>
1

How much to scale volume by (in addition to range fade)

pitchNumber<optional>
1

How much to scale pitch by (also adjusted by this.randomness)

randomnessScaleNumber<optional>
1

How much to scale randomness

loopBoolean<optional>
false

Should the sound loop

Returns:
  • The audio source node
Type: 
AudioBufferSourceNode

playNote(semitoneOffset, posopt, volumeopt) → {AudioBufferSourceNode}

Play the sound as a note with a semitone offset

Parameters:
NameTypeAttributesDefaultDescription
semitoneOffsetNumber

How many semitones to offset pitch

posVector2<optional>

World space position to play the sound, sound is not attenuated if null

volumeNumber<optional>
1

How much to scale volume by (in addition to range fade)

Returns:
  • The audio source node
Type: 
AudioBufferSourceNode

stop()

Stop the last instance of this sound that was played

LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

Sound

Sound Object - Stores a sound for later use and can be played positionally

Create sounds using the ZzFX Sound Designer.

Constructor

new Sound(zzfxSound, rangeopt, taperopt)

Create a sound object and cache the zzfx samples for later use

Parameters:
NameTypeAttributesDefaultDescription
zzfxSoundArray

Array of zzfx parameters, ex. [.5,.5]

rangeNumber<optional>
soundDefaultRange

World space max range of sound, will not play if camera is farther away

taperNumber<optional>
soundDefaultTaper

At what percentage of range should it start tapering

Example
// create a sound
const sound_example = new Sound([.5,.5]);

// play the sound
sound_example.play();

Members

randomness

Properties
TypeDescription
Number

How much to randomize frequency each time sound plays

range

Properties
TypeDescription
Number

World space max range of sound, will not play if camera is farther away

taper

Properties
TypeDescription
Number

At what percentage of range should it start tapering off

Methods

getDuration() → {Number}

Get how long this sound is in seconds

Returns:
  • How long the sound is in seconds (undefined if loading)
Type: 
Number

getSource() → {AudioBufferSourceNode}

Get source of most recent instance of this sound that was played

Returns:
Type: 
AudioBufferSourceNode

isLoading() → {Boolean}

Check if sound is loading, for sounds fetched from a url

Returns:
  • True if sound is loading and not ready to play
Type: 
Boolean

play(posopt, volumeopt, pitchopt, randomnessScaleopt, loopopt) → {AudioBufferSourceNode}

Play the sound

Parameters:
NameTypeAttributesDefaultDescription
posVector2<optional>

World space position to play the sound, sound is not attenuated if null

volumeNumber<optional>
1

How much to scale volume by (in addition to range fade)

pitchNumber<optional>
1

How much to scale pitch by (also adjusted by this.randomness)

randomnessScaleNumber<optional>
1

How much to scale randomness

loopBoolean<optional>
false

Should the sound loop

Returns:
  • The audio source node
Type: 
AudioBufferSourceNode

playNote(semitoneOffset, posopt, volumeopt) → {AudioBufferSourceNode}

Play the sound as a note with a semitone offset

Parameters:
NameTypeAttributesDefaultDescription
semitoneOffsetNumber

How many semitones to offset pitch

posVector2<optional>

World space position to play the sound, sound is not attenuated if null

volumeNumber<optional>
1

How much to scale volume by (in addition to range fade)

Returns:
  • The audio source node
Type: 
AudioBufferSourceNode

stop()

Stop the last instance of this sound that was played

LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/TextureInfo.html b/docs/TextureInfo.html index ef96e9ec..995233b5 100644 --- a/docs/TextureInfo.html +++ b/docs/TextureInfo.html @@ -1,3 +1,3 @@ Class: TextureInfo
On this page

TextureInfo

Texture Info - Stores info about each texture

Constructor

new TextureInfo(image)

Create a TextureInfo, called automatically by the engine

Parameters:
NameTypeDescription
imageHTMLImageElement

Members

fixBleedSize

Properties
TypeDescription
Vector2

size to adjust tile to fix bleeding

glTexture

Properties
TypeDescription
WebGLTexture

webgl texture

image

Properties
TypeDescription
HTMLImageElement

image source

size

Properties
TypeDescription
Vector2

size of the image

LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

TextureInfo

Texture Info - Stores info about each texture

Constructor

new TextureInfo(image)

Create a TextureInfo, called automatically by the engine

Parameters:
NameTypeDescription
imageHTMLImageElement

Members

fixBleedSize

Properties
TypeDescription
Vector2

size to adjust tile to fix bleeding

glTexture

Properties
TypeDescription
WebGLTexture

webgl texture

image

Properties
TypeDescription
HTMLImageElement

image source

size

Properties
TypeDescription
Vector2

size of the image

LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/TileCollision.html b/docs/TileCollision.html index 55741dcd..b016a864 100644 --- a/docs/TileCollision.html +++ b/docs/TileCollision.html @@ -1,3 +1,3 @@ Namespace: TileCollision
On this page

TileCollision

LittleJS Tile Layer System

  • Caches arrays of tiles to off screen canvas for fast rendering
  • Unlimted numbers of layers, allocates canvases as needed
  • Interfaces with EngineObject for collision
  • Collision layer is separate from visible layers
  • It is recommended to have a visible layer that matches the collision
  • Tile layers can be drawn to using their context with canvas2d
  • Drawn directly to the main canvas without using WebGL

Members

(static) tileCollision :Array

The tile collision layer array, use setTileCollisionData and getTileCollisionData to access

Type:
  • Array

(static) tileCollisionSize :Vector2

Size of the tile collision layer

Type:

Methods

(static) getTileCollisionData(pos) → {Number}

Get tile collision data

Parameters:
NameTypeDescription
posVector2
Returns:
Type: 
Number

(static) initTileCollision(size)

Clear and initialize tile collision

Parameters:
NameTypeDescription
sizeVector2

(static) setTileCollisionData(pos, dataopt)

Set tile collision data

Parameters:
NameTypeAttributesDefaultDescription
posVector2
dataNumber<optional>
0

(static) tileCollisionRaycast(posStart, posEnd, objectopt) → {Vector2}

Return the center of tile if any that is hit (does not return the exact intersection)

Parameters:
NameTypeAttributesDescription
posStartVector2
posEndVector2
objectEngineObject<optional>
Returns:
Type: 
Vector2

(static) tileCollisionTest(pos, sizeopt, objectopt) → {Boolean}

Check if collision with another object should occur

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2<optional>
(1,1)
objectEngineObject<optional>
Returns:
Type: 
Boolean
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

TileCollision

LittleJS Tile Layer System

  • Caches arrays of tiles to off screen canvas for fast rendering
  • Unlimited numbers of layers, allocates canvases as needed
  • Interfaces with EngineObject for collision
  • Collision layer is separate from visible layers
  • It is recommended to have a visible layer that matches the collision
  • Tile layers can be drawn to using their context with canvas2d
  • Drawn directly to the main canvas without using WebGL

Members

(static) tileCollision :Array

The tile collision layer array, use setTileCollisionData and getTileCollisionData to access

Type:
  • Array

(static) tileCollisionSize :Vector2

Size of the tile collision layer

Type:

Methods

(static) getTileCollisionData(pos) → {Number}

Get tile collision data

Parameters:
NameTypeDescription
posVector2
Returns:
Type: 
Number

(static) initTileCollision(size)

Clear and initialize tile collision

Parameters:
NameTypeDescription
sizeVector2

(static) setTileCollisionData(pos, dataopt)

Set tile collision data

Parameters:
NameTypeAttributesDefaultDescription
posVector2
dataNumber<optional>
0

(static) tileCollisionRaycast(posStart, posEnd, objectopt) → {Vector2}

Return the center of tile if any that is hit (does not return the exact intersection)

Parameters:
NameTypeAttributesDescription
posStartVector2
posEndVector2
objectEngineObject<optional>
Returns:
Type: 
Vector2

(static) tileCollisionTest(pos, sizeopt, objectopt) → {Boolean}

Check if collision with another object should occur

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2<optional>
(0,0)
objectEngineObject<optional>
Returns:
Type: 
Boolean
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/TileInfo.html b/docs/TileInfo.html index 853d96a8..739e58af 100644 --- a/docs/TileInfo.html +++ b/docs/TileInfo.html @@ -1,3 +1,3 @@ Class: TileInfo
On this page

TileInfo

Tile Info - Stores info about how to draw a tile

Constructor

new TileInfo(posopt, sizeopt, textureIndexopt)

Create a tile info object

Parameters:
NameTypeAttributesDefaultDescription
posVector2<optional>
(0,0)

Top left corner of tile in pixels

sizeVector2<optional>
tileSizeDefault

Size of tile in pixels

textureIndexNumber<optional>
0

Texture index to use

Members

pos

Properties
TypeDescription
Vector2

Top left corner of tile in pixels

size

Properties
TypeDescription
Vector2

Size of tile in pixels

textureIndex

Properties
TypeDescription
Number

Texture index to use

Methods

getTextureInfo() → {TextureInfo}

Returns the texture info for this tile

Returns:
Type: 
TextureInfo

offset(offset) → {TileInfo}

Returns an offset copy of this tile, useful for animation

Parameters:
NameTypeDescription
offsetVector2

Offset to apply in pixels

Returns:
Type: 
TileInfo
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

TileInfo

Tile Info - Stores info about how to draw a tile

Constructor

new TileInfo(posopt, sizeopt, textureIndexopt)

Create a tile info object

Parameters:
NameTypeAttributesDefaultDescription
posVector2<optional>
(0,0)

Top left corner of tile in pixels

sizeVector2<optional>
tileSizeDefault

Size of tile in pixels

textureIndexNumber<optional>
0

Texture index to use

Members

pos

Properties
TypeDescription
Vector2

Top left corner of tile in pixels

size

Properties
TypeDescription
Vector2

Size of tile in pixels

textureIndex

Properties
TypeDescription
Number

Texture index to use

Methods

frame(frame) → {TileInfo}

Returns a copy of this tile offset by a number of animation frames

Parameters:
NameTypeDescription
frameNumber

Offset to apply in animation frames

Returns:
Type: 
TileInfo

getTextureInfo() → {TextureInfo}

Returns the texture info for this tile

Returns:
Type: 
TextureInfo

offset(offset) → {TileInfo}

Returns a copy of this tile offset by a vector

Parameters:
NameTypeDescription
offsetVector2

Offset to apply in pixels

Returns:
Type: 
TileInfo
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/Utilities.html b/docs/Utilities.html index 3f2a00a1..653ec5ed 100644 --- a/docs/Utilities.html +++ b/docs/Utilities.html @@ -1,3 +1,3 @@ Namespace: Utilities
On this page

Utilities

LittleJS Utility Classes and Functions

  • General purpose math library
  • Vector2 - fast, simple, easy 2D vector class
  • Color - holds a rgba color with some math functions
  • Timer - tracks time automatically
  • RandomGenerator - seeded random number generator

Members

(static, constant) PI :Number

A shortcut to get Math.PI

Type:
  • Number
Default Value
  • Math.PI

Methods

(static) abs(value) → {Number}

Returns absoulte value of value passed in

Parameters:
NameTypeDescription
valueNumber
Returns:
Type: 
Number

(static) clamp(value, minopt, maxopt) → {Number}

Clamps the value beween max and min

Parameters:
NameTypeAttributesDefaultDescription
valueNumber
minNumber<optional>
0
maxNumber<optional>
1
Returns:
Type: 
Number

(static) distanceAngle(angleA, angleB) → {Number}

Returns signed wrapped distance between the two angles passed in

Parameters:
NameTypeDescription
angleANumber
angleBNumber
Returns:
Type: 
Number

(static) distanceWrap(valueA, valueB, wrapSizeopt) → {Number}

Returns signed wrapped distance between the two values passed in

Parameters:
NameTypeAttributesDefaultDescription
valueANumber
valueBNumber
wrapSizeNumber<optional>
1
Returns:
Type: 
Number

(static) formatTime(t) → {String}

Formats seconds to mm:ss style for display purposes

Parameters:
NameTypeDescription
tNumber

time in seconds

Returns:
Type: 
String

(static) hsl(hopt, sopt, lopt, aopt) → {Color}

Create a color object with HSLA values, white by default

Parameters:
NameTypeAttributesDefaultDescription
hNumber<optional>
0

hue

sNumber<optional>
0

saturation

lNumber<optional>
1

lightness

aNumber<optional>
1

alpha

Returns:
Type: 
Color

(static) isColor(c) → {Boolean}

Check if object is a valid Color

Parameters:
NameTypeDescription
cany
Returns:
Type: 
Boolean

(static) isOverlapping(pointA, sizeA, pointB, sizeBopt) → {Boolean}

Returns true if two axis aligned bounding boxes are overlapping

Parameters:
NameTypeAttributesDefaultDescription
pointAVector2

Center of box A

sizeAVector2

Size of box A

pointBVector2

Center of box B

sizeBVector2<optional>
(0,0)

Size of box B, a point if undefined

Returns:
  • True if overlapping
Type: 
Boolean

(static) isVector2(v) → {Boolean}

Check if object is a valid Vector2

Parameters:
NameTypeDescription
vany
Returns:
Type: 
Boolean

(static) lerp(percent, valueA, valueB) → {Number}

Linearly interpolates between values passed in using percent

Parameters:
NameTypeDescription
percentNumber
valueANumber
valueBNumber
Returns:
Type: 
Number

(static) lerpAngle(percent, angleA, angleB) → {Number}

Linearly interpolates between the angles passed in with wrappping

Parameters:
NameTypeDescription
percentNumber
angleANumber
angleBNumber
Returns:
Type: 
Number

(static) lerpWrap(percent, valueA, valueB, wrapSizeopt) → {Number}

Linearly interpolates between values passed in with wrappping

Parameters:
NameTypeAttributesDefaultDescription
percentNumber
valueANumber
valueBNumber
wrapSizeNumber<optional>
1
Returns:
Type: 
Number

(static) max(valueA, valueB) → {Number}

Returns highest of two values passed in

Parameters:
NameTypeDescription
valueANumber
valueBNumber
Returns:
Type: 
Number

(static) min(valueA, valueB) → {Number}

Returns lowest of two values passed in

Parameters:
NameTypeDescription
valueANumber
valueBNumber
Returns:
Type: 
Number

(static) mod(dividend, divisoropt) → {Number}

Returns first parm modulo the second param, but adjusted so negative numbers work as expected

Parameters:
NameTypeAttributesDefaultDescription
dividendNumber
divisorNumber<optional>
1
Returns:
Type: 
Number

(static) nearestPowerOfTwo(value) → {Number}

Returns the nearest power of two not less then the value

Parameters:
NameTypeDescription
valueNumber
Returns:
Type: 
Number

(static) percent(value, valueA, valueB) → {Number}

Returns what percentage the value is between valueA and valueB

Parameters:
NameTypeDescription
valueNumber
valueANumber
valueBNumber
Returns:
Type: 
Number

(static) rgb(ropt, gopt, bopt, aopt) → {Color}

Create a color object with RGBA values, white by default

Parameters:
NameTypeAttributesDefaultDescription
rNumber<optional>
1

red

gNumber<optional>
1

green

bNumber<optional>
1

blue

aNumber<optional>
1

alpha

Returns:
Type: 
Color

(static) sign(value) → {Number}

Returns the sign of value passed in (also returns 1 if 0)

Parameters:
NameTypeDescription
valueNumber
Returns:
Type: 
Number

(static) smoothStep(percent) → {Number}

Applies smoothstep function to the percentage value

Parameters:
NameTypeDescription
percentNumber
Returns:
Type: 
Number

(static) vec2(xopt, yopt) → {Vector2}

Create a 2d vector, can take another Vector2 to copy, 2 scalars, or 1 scalar

Parameters:
NameTypeAttributesDefaultDescription
xNumber | Vector2<optional>
0
yNumber<optional>
Returns:
Type: 
Vector2
Example
let a = vec2(0, 1); // vector with coordinates (0, 1)
let b = vec2(a);    // copy a into b
a = vec2(5);        // set a to (5, 5)
b = vec2();         // set b to (0, 0)

(static) wave(frequencyopt, amplitudeopt, topt) → {Number}

Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default

Parameters:
NameTypeAttributesDefaultDescription
frequencyNumber<optional>
1

Frequency of the wave in Hz

amplitudeNumber<optional>
1

Amplitude (max height) of the wave

tNumber<optional>
time

Value to use for time of the wave

Returns:
  • Value waving between 0 and amplitude
Type: 
Number
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

Utilities

LittleJS Utility Classes and Functions

  • General purpose math library
  • Vector2 - fast, simple, easy 2D vector class
  • Color - holds a rgba color with some math functions
  • Timer - tracks time automatically
  • RandomGenerator - seeded random number generator

Members

(static, constant) PI :Number

A shortcut to get Math.PI

Type:
  • Number
Default Value
  • Math.PI

Methods

(static) abs(value) → {Number}

Returns absoulte value of value passed in

Parameters:
NameTypeDescription
valueNumber
Returns:
Type: 
Number

(static) clamp(value, minopt, maxopt) → {Number}

Clamps the value beween max and min

Parameters:
NameTypeAttributesDefaultDescription
valueNumber
minNumber<optional>
0
maxNumber<optional>
1
Returns:
Type: 
Number

(static) distanceAngle(angleA, angleB) → {Number}

Returns signed wrapped distance between the two angles passed in

Parameters:
NameTypeDescription
angleANumber
angleBNumber
Returns:
Type: 
Number

(static) distanceWrap(valueA, valueB, wrapSizeopt) → {Number}

Returns signed wrapped distance between the two values passed in

Parameters:
NameTypeAttributesDefaultDescription
valueANumber
valueBNumber
wrapSizeNumber<optional>
1
Returns:
Type: 
Number

(static) formatTime(t) → {String}

Formats seconds to mm:ss style for display purposes

Parameters:
NameTypeDescription
tNumber

time in seconds

Returns:
Type: 
String

(static) hsl(hopt, sopt, lopt, aopt) → {Color}

Create a color object with HSLA values, white by default

Parameters:
NameTypeAttributesDefaultDescription
hNumber<optional>
0

hue

sNumber<optional>
0

saturation

lNumber<optional>
1

lightness

aNumber<optional>
1

alpha

Returns:
Type: 
Color

(static) isColor(c) → {Boolean}

Check if object is a valid Color

Parameters:
NameTypeDescription
cany
Returns:
Type: 
Boolean

(static) isOverlapping(pointA, sizeA, pointB, sizeBopt) → {Boolean}

Returns true if two axis aligned bounding boxes are overlapping

Parameters:
NameTypeAttributesDefaultDescription
pointAVector2

Center of box A

sizeAVector2

Size of box A

pointBVector2

Center of box B

sizeBVector2<optional>
(0,0)

Size of box B, a point if undefined

Returns:
  • True if overlapping
Type: 
Boolean

(static) isVector2(v) → {Boolean}

Check if object is a valid Vector2

Parameters:
NameTypeDescription
vany
Returns:
Type: 
Boolean

(static) lerp(percent, valueA, valueB) → {Number}

Linearly interpolates between values passed in using percent

Parameters:
NameTypeDescription
percentNumber
valueANumber
valueBNumber
Returns:
Type: 
Number

(static) lerpAngle(percent, angleA, angleB) → {Number}

Linearly interpolates between the angles passed in with wrapping

Parameters:
NameTypeDescription
percentNumber
angleANumber
angleBNumber
Returns:
Type: 
Number

(static) lerpWrap(percent, valueA, valueB, wrapSizeopt) → {Number}

Linearly interpolates between values passed in with wrapping

Parameters:
NameTypeAttributesDefaultDescription
percentNumber
valueANumber
valueBNumber
wrapSizeNumber<optional>
1
Returns:
Type: 
Number

(static) max(valueA, valueB) → {Number}

Returns highest of two values passed in

Parameters:
NameTypeDescription
valueANumber
valueBNumber
Returns:
Type: 
Number

(static) min(valueA, valueB) → {Number}

Returns lowest of two values passed in

Parameters:
NameTypeDescription
valueANumber
valueBNumber
Returns:
Type: 
Number

(static) mod(dividend, divisoropt) → {Number}

Returns first parm modulo the second param, but adjusted so negative numbers work as expected

Parameters:
NameTypeAttributesDefaultDescription
dividendNumber
divisorNumber<optional>
1
Returns:
Type: 
Number

(static) nearestPowerOfTwo(value) → {Number}

Returns the nearest power of two not less then the value

Parameters:
NameTypeDescription
valueNumber
Returns:
Type: 
Number

(static) percent(value, valueA, valueB) → {Number}

Returns what percentage the value is between valueA and valueB

Parameters:
NameTypeDescription
valueNumber
valueANumber
valueBNumber
Returns:
Type: 
Number

(static) rgb(ropt, gopt, bopt, aopt) → {Color}

Create a color object with RGBA values, white by default

Parameters:
NameTypeAttributesDefaultDescription
rNumber<optional>
1

red

gNumber<optional>
1

green

bNumber<optional>
1

blue

aNumber<optional>
1

alpha

Returns:
Type: 
Color

(static) sign(value) → {Number}

Returns the sign of value passed in

Parameters:
NameTypeDescription
valueNumber
Returns:
Type: 
Number

(static) smoothStep(percent) → {Number}

Applies smoothstep function to the percentage value

Parameters:
NameTypeDescription
percentNumber
Returns:
Type: 
Number

(static) vec2(xopt, yopt) → {Vector2}

Create a 2d vector, can take another Vector2 to copy, 2 scalars, or 1 scalar

Parameters:
NameTypeAttributesDefaultDescription
xNumber | Vector2<optional>
0
yNumber<optional>
Returns:
Type: 
Vector2
Example
let a = vec2(0, 1); // vector with coordinates (0, 1)
let b = vec2(a);    // copy a into b
a = vec2(5);        // set a to (5, 5)
b = vec2();         // set b to (0, 0)

(static) wave(frequencyopt, amplitudeopt, topt) → {Number}

Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default

Parameters:
NameTypeAttributesDefaultDescription
frequencyNumber<optional>
1

Frequency of the wave in Hz

amplitudeNumber<optional>
1

Amplitude (max height) of the wave

tNumber<optional>
time

Value to use for time of the wave

Returns:
  • Value waving between 0 and amplitude
Type: 
Number
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/WebGL.html b/docs/WebGL.html index 10e534e4..95eac508 100644 --- a/docs/WebGL.html +++ b/docs/WebGL.html @@ -1,3 +1,3 @@ Namespace: WebGL
On this page

WebGL

LittleJS WebGL Interface

  • All webgl used by the engine is wrapped up here
  • For normal stuff you won't need to see or call anything in this file
  • For advanced stuff there are helper functions to create shaders, textures, etc
  • Can be disabled with glEnable to revert to 2D canvas rendering
  • Batches sprite rendering on GPU for incredibly fast performance
  • Sprite transform math is done in the shader where possible
  • Supports shadertoy style post processing shaders

Members

(static) glCanvas :HTMLCanvasElement

The WebGL canvas which appears above the main canvas and below the overlay canvas

Type:
  • HTMLCanvasElement

(static) glContext :WebGL2RenderingContext

2d context for glCanvas

Type:
  • WebGL2RenderingContext

Methods

(static) glCompileShader(source, type) → {WebGLShader}

Compile WebGL shader of the given type, will throw errors if in debug mode

Parameters:
NameTypeDescription
sourceString
typeNumber
Returns:
Type: 
WebGLShader

(static) glCopyToContext(context, forceDrawopt)

Draw any sprites still in the buffer, copy to main canvas and clear

Parameters:
NameTypeAttributesDefaultDescription
contextCanvasRenderingContext2D
forceDrawBoolean<optional>
false

(static) glCreateProgram(vsSource, fsSource) → {WebGLProgram}

Create WebGL program with given shaders

Parameters:
NameTypeDescription
vsSourceString
fsSourceString
Returns:
Type: 
WebGLProgram

(static) glCreateTexture(image) → {WebGLTexture}

Create WebGL texture from an image and init the texture settings

Parameters:
NameTypeDescription
imageHTMLImageElement
Returns:
Type: 
WebGLTexture

(static) glDraw(x, y, sizeX, sizeY, angle, uv0X, uv0Y, uv1X, uv1Y, rgba, rgbaAdditiveopt)

Add a sprite to the gl draw list, used by all gl draw functions

Parameters:
NameTypeAttributesDefaultDescription
xNumber
yNumber
sizeXNumber
sizeYNumber
angleNumber
uv0XNumber
uv0YNumber
uv1XNumber
uv1YNumber
rgbaNumber
rgbaAdditiveNumber<optional>
0

(static) glFlush()

Draw all sprites and clear out the buffer, called automatically by the system whenever necessary

(static) glInitPostProcess(shaderCode, includeOverlay)

Set up a post processing shader

Parameters:
NameTypeDefaultDescription
shaderCodeString
includeOverlayBooleanfalse

(static) glSetTexture(texture)

Set the WebGl texture, called automatically if using multiple textures

  • This may also flush the gl buffer resulting in more draw calls and worse performance
Parameters:
NameTypeDescription
textureWebGLTexture
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file +
On this page

WebGL

LittleJS WebGL Interface

  • All webgl used by the engine is wrapped up here
  • For normal stuff you won't need to see or call anything in this file
  • For advanced stuff there are helper functions to create shaders, textures, etc
  • Can be disabled with glEnable to revert to 2D canvas rendering
  • Batches sprite rendering on GPU for incredibly fast performance
  • Sprite transform math is done in the shader where possible
  • Supports shadertoy style post processing shaders

Members

(static) glCanvas :HTMLCanvasElement

The WebGL canvas which appears above the main canvas and below the overlay canvas

Type:
  • HTMLCanvasElement

(static) glContext :WebGL2RenderingContext

2d context for glCanvas

Type:
  • WebGL2RenderingContext

Methods

(static) glCompileShader(source, type) → {WebGLShader}

Compile WebGL shader of the given type, will throw errors if in debug mode

Parameters:
NameTypeDescription
sourceString
typeNumber
Returns:
Type: 
WebGLShader

(static) glCopyToContext(context, forceDrawopt)

Draw any sprites still in the buffer, copy to main canvas and clear

Parameters:
NameTypeAttributesDefaultDescription
contextCanvasRenderingContext2D
forceDrawBoolean<optional>
false

(static) glCreateProgram(vsSource, fsSource) → {WebGLProgram}

Create WebGL program with given shaders

Parameters:
NameTypeDescription
vsSourceString
fsSourceString
Returns:
Type: 
WebGLProgram

(static) glCreateTexture(image) → {WebGLTexture}

Create WebGL texture from an image and init the texture settings

Parameters:
NameTypeDescription
imageHTMLImageElement
Returns:
Type: 
WebGLTexture

(static) glDraw(x, y, sizeX, sizeY, angle, uv0X, uv0Y, uv1X, uv1Y, rgba, rgbaAdditiveopt)

Add a sprite to the gl draw list, used by all gl draw functions

Parameters:
NameTypeAttributesDefaultDescription
xNumber
yNumber
sizeXNumber
sizeYNumber
angleNumber
uv0XNumber
uv0YNumber
uv1XNumber
uv1YNumber
rgbaNumber
rgbaAdditiveNumber<optional>
0

(static) glFlush()

Draw all sprites and clear out the buffer, called automatically by the system whenever necessary

(static) glInitPostProcess(shaderCode, includeOverlay)

Set up a post processing shader

Parameters:
NameTypeDefaultDescription
shaderCodeString
includeOverlayBooleanfalse

(static) glSetTexture(texture)

Set the WebGl texture, called automatically if using multiple textures

  • This may also flush the gl buffer resulting in more draw calls and worse performance
Parameters:
NameTypeDescription
textureWebGLTexture
LittleJS - The Tiny JavaScript Game Engine That Can!
\ No newline at end of file diff --git a/docs/data/search.json b/docs/data/search.json index 2409a822..6c93fe8f 100644 --- a/docs/data/search.json +++ b/docs/data/search.json @@ -1 +1 @@ -{"list":[{"title":"Audio","link":"Audio","description":"

LittleJS Audio System

\n"},{"title":"Audio.audioContext","link":"audioContext","description":"

Audio context used by the engine

"},{"title":"Audio.getNoteFrequency","link":"getNoteFrequency","description":"

Get frequency of a note on a musical scale

"},{"title":"Audio.playAudioFile","link":"playAudioFile","description":"

Play an mp3, ogg, or wav audio from a local file or url

"},{"title":"Audio.playSamples","link":"playSamples","description":"

Play cached audio samples with given settings

"},{"title":"Audio.speak","link":"speak","description":"

Speak text with passed in settings

"},{"title":"Audio.speakStop","link":"speakStop","description":"

Stop all queued speech

"},{"title":"Audio.zzfx","link":"zzfx","description":"

Generate and play a ZzFX sound

\n

Create sounds using the ZzFX Sound Designer.

"},{"title":"Audio.zzfxG","link":"zzfxG","description":"

Generate samples for a ZzFX sound

"},{"title":"Audio.zzfxM","link":"zzfxM","description":"

Generate samples for a ZzFM song with given parameters

"},{"title":"Audio.zzfxR","link":"zzfxR","description":"

Sample rate used for all ZzFX sounds

"},{"title":"Color","link":"Color","description":"

Create a color with the rgba components passed in, white by default

"},{"title":"Color#a","link":"a"},{"title":"Color#add","link":"add","description":"

Returns a copy of this color plus the color passed in

"},{"title":"Color#b","link":"b"},{"title":"Color#clamp","link":"clamp","description":"

Returns a copy of this color clamped to the valid range between 0 and 1

"},{"title":"Color#copy","link":"copy","description":"

Returns a new color that is a copy of this

"},{"title":"Color#divide","link":"divide","description":"

Returns a copy of this color divided by the color passed in

"},{"title":"Color#g","link":"g"},{"title":"Color#getHSLA","link":"getHSLA","description":"

Returns this color expressed in hsla format

"},{"title":"Color#lerp","link":"lerp","description":"

Returns a new color that is p percent between this and the color passed in

"},{"title":"Color#multiply","link":"multiply","description":"

Returns a copy of this color times the color passed in

"},{"title":"Color#mutate","link":"mutate","description":"

Returns a new color that has each component randomly adjusted

"},{"title":"Color#r","link":"r"},{"title":"Color#rgbaInt","link":"rgbaInt","description":"

Returns this color expressed as 32 bit RGBA value

"},{"title":"Color#scale","link":"scale","description":"

Returns a copy of this color scaled by the value passed in, alpha can be scaled separately

"},{"title":"Color#setHSLA","link":"setHSLA","description":"

Sets this color given a hue, saturation, lightness, and alpha

"},{"title":"Color#setHex","link":"setHex","description":"

Set this color from a hex code

"},{"title":"Color#subtract","link":"subtract","description":"

Returns a copy of this color minus the color passed in

"},{"title":"Color#toString","link":"toString","description":"

Returns this color expressed as a hex color code

"},{"title":"Debug","link":"Debug","description":"

LittleJS Debug System

\n"},{"title":"Debug.ASSERT","link":"ASSERT","description":"

Asserts if the experssion is false, does not do anything in release builds

"},{"title":"Debug.debug","link":"debug","description":"

True if debug is enabled

"},{"title":"Debug.debugAABB","link":"debugAABB","description":"

Draw a debug axis aligned bounding box in world space

"},{"title":"Debug.debugCircle","link":"debugCircle","description":"

Draw a debug circle in world space

"},{"title":"Debug.debugClear","link":"debugClear","description":"

Clear all debug primitives in the list

"},{"title":"Debug.debugKey","link":"debugKey","description":"

Key code used to toggle debug mode, Esc by default

"},{"title":"Debug.debugLine","link":"debugLine","description":"

Draw a debug line in world space

"},{"title":"Debug.debugOverlay","link":"debugOverlay","description":"

True if the debug overlay is active, always false in release builds

"},{"title":"Debug.debugPoint","link":"debugPoint","description":"

Draw a debug point in world space

"},{"title":"Debug.debugPointSize","link":"debugPointSize","description":"

Size to render debug points by default

"},{"title":"Debug.debugRect","link":"debugRect","description":"

Draw a debug rectangle in world space

"},{"title":"Debug.debugSaveCanvas","link":"debugSaveCanvas","description":"

Save a canvas to disk

"},{"title":"Debug.debugSaveDataURL","link":"debugSaveDataURL","description":"

Save a data url to disk

"},{"title":"Debug.debugSaveText","link":"debugSaveText","description":"

Save a text file to disk

"},{"title":"Debug.debugText","link":"debugText","description":"

Draw a debug axis aligned bounding box in world space

"},{"title":"Debug.enableAsserts","link":"enableAsserts","description":"

True if asserts are enaled

"},{"title":"Debug.setDebugKey","link":"setDebugKey","description":"

Set key code used to toggle debug mode, Esc by default

"},{"title":"Debug.setShowWatermark","link":"setShowWatermark","description":"

Set if watermark with FPS should be shown

"},{"title":"Debug.showWatermark","link":"showWatermark","description":"

True if watermark with FPS should be shown, false in release builds

"},{"title":"Draw","link":"Draw","description":"

LittleJS Drawing System

\n\n

LittleJS uses a hybrid rendering solution with the best of both Canvas2D and WebGL.\nThere are 3 canvas/contexts available to draw to...\nmainCanvas - 2D background canvas, non WebGL stuff like tile layers are drawn here.\nglCanvas - Used by the accelerated WebGL batch rendering system.\noverlayCanvas - Another 2D canvas that appears on top of the other 2 canvases.

\n

The WebGL rendering system is very fast with some caveats...

\n\n

The LittleJS rendering solution is intentionally simple, feel free to adjust it for your needs!

"},{"title":"Draw.drawCanvas2D","link":"drawCanvas2D","description":"

Draw directly to a 2d canvas context in world space

"},{"title":"Draw.drawLine","link":"drawLine","description":"

Draw colored line between two points

"},{"title":"Draw.drawPoly","link":"drawPoly","description":"

Draw colored polygon using passed in points

"},{"title":"Draw.drawRect","link":"drawRect","description":"

Draw colored rect centered on pos

"},{"title":"Draw.drawText","link":"drawText","description":"

Draw text on overlay canvas in world space\nAutomatically splits new lines into rows

"},{"title":"Draw.drawTextScreen","link":"drawTextScreen","description":"

Draw text on overlay canvas in screen space\nAutomatically splits new lines into rows

"},{"title":"Draw.drawTile","link":"drawTile","description":"

Draw textured tile centered in world space, with color applied if using WebGL

"},{"title":"Draw.isFullscreen","link":"isFullscreen","description":"

Returns true if fullscreen mode is active

"},{"title":"Draw.mainCanvas","link":"mainCanvas","description":"

The primary 2D canvas visible to the user

"},{"title":"Draw.mainCanvasSize","link":"mainCanvasSize","description":"

The size of the main canvas (and other secondary canvases)

"},{"title":"Draw.mainContext","link":"mainContext","description":"

2d context for mainCanvas

"},{"title":"Draw.overlayCanvas","link":"overlayCanvas","description":"

A canvas that appears on top of everything the same size as mainCanvas

"},{"title":"Draw.overlayContext","link":"overlayContext","description":"

2d context for overlayCanvas

"},{"title":"Draw.screenToWorld","link":"screenToWorld","description":"

Convert from screen to world space coordinates

"},{"title":"Draw.setBlendMode","link":"setBlendMode","description":"

Enable normal or additive blend mode

"},{"title":"Draw.textureInfos","link":"textureInfos","description":"

Array containing texture info for batch rendering system

"},{"title":"Draw.tile","link":"tile","description":"

Create a tile info object

\n"},{"title":"Draw.toggleFullscreen","link":"toggleFullscreen","description":"

Toggle fullsceen mode

"},{"title":"Draw.worldToScreen","link":"worldToScreen","description":"

Convert from world to screen space coordinates

"},{"title":"Engine","link":"Engine","description":"

LittleJS - The Tiny JavaScript Game Engine That Can!\nMIT License - Copyright 2021 Frank Force

\n

Engine Features

\n"},{"title":"Engine.engineInit","link":"engineInit","description":"

Start up LittleJS engine with your callback functions

"},{"title":"Engine.engineName","link":"engineName","description":"

Name of engine

"},{"title":"Engine.engineObjects","link":"engineObjects","description":"

Array containing all engine objects

"},{"title":"Engine.engineObjectsCallback","link":"engineObjectsCallback","description":"

Triggers a callback for each object within a given area

"},{"title":"Engine.engineObjectsCollide","link":"engineObjectsCollide","description":"

Array containing only objects that are set to collide with other objects this frame (for optimization)

"},{"title":"Engine.engineObjectsDestroy","link":"engineObjectsDestroy","description":"

Destroy and remove all objects

"},{"title":"Engine.engineObjectsUpdate","link":"engineObjectsUpdate","description":"

Update each engine object, remove destroyed objects, and update time

"},{"title":"Engine.engineVersion","link":"engineVersion","description":"

Version of engine

"},{"title":"Engine.frame","link":"frame","description":"

Current update frame, used to calculate time

"},{"title":"Engine.frameRate","link":"frameRate","description":"

Frames per second to update objects

"},{"title":"Engine.paused","link":"paused","description":"

Is the game paused? Causes time and objects to not be updated

"},{"title":"Engine.setPaused","link":"setPaused","description":"

Set if game is paused

"},{"title":"Engine.time","link":"time","description":"

Current engine time since start in seconds, derived from frame

"},{"title":"Engine.timeDelta","link":"timeDelta","description":"

How many seconds each frame lasts, engine uses a fixed time step

"},{"title":"Engine.timeReal","link":"timeReal","description":"

Actual clock time since start in seconds (not affected by pause or frame rate clamping)

"},{"title":"EngineObject","link":"EngineObject","description":"

Create an engine object and adds it to the list of objects

"},{"title":"EngineObject#addChild","link":"addChild","description":"

Attaches a child to this with a given local transform

"},{"title":"EngineObject#additiveColor","link":"additiveColor"},{"title":"EngineObject#angle","link":"angle"},{"title":"EngineObject#angleDamping","link":"angleDamping"},{"title":"EngineObject#angleVelocity","link":"angleVelocity"},{"title":"EngineObject#applyAcceleration","link":"applyAcceleration","description":"

Apply acceleration to this object (adjust velocity, not affected by mass)

"},{"title":"EngineObject#applyForce","link":"applyForce","description":"

Apply force to this object (adjust velocity, affected by mass)

"},{"title":"EngineObject#children","link":"children"},{"title":"EngineObject#collideSolidObjects","link":"collideSolidObjects"},{"title":"EngineObject#collideTiles","link":"collideTiles"},{"title":"EngineObject#collideWithObject","link":"collideWithObject","description":"

Called to check if a object collision should be resolved

"},{"title":"EngineObject#collideWithTile","link":"collideWithTile","description":"

Called to check if a tile collision should be resolved

"},{"title":"EngineObject#collideWithTileRaycast","link":"collideWithTileRaycast","description":"

Called to check if a tile raycast hit

"},{"title":"EngineObject#color","link":"color"},{"title":"EngineObject#damping","link":"damping"},{"title":"EngineObject#destroy","link":"destroy","description":"

Destroy this object, destroy it's children, detach it's parent, and mark it for removal

"},{"title":"EngineObject#drawSize","link":"drawSize"},{"title":"EngineObject#elasticity","link":"elasticity"},{"title":"EngineObject#friction","link":"friction"},{"title":"EngineObject#getAliveTime","link":"getAliveTime","description":"

How long since the object was created

"},{"title":"EngineObject#getMirrorSign","link":"getMirrorSign","description":"

Get the direction of the mirror

"},{"title":"EngineObject#gravityScale","link":"gravityScale"},{"title":"EngineObject#isSolid","link":"isSolid"},{"title":"EngineObject#localAngle","link":"localAngle"},{"title":"EngineObject#localPos","link":"localPos"},{"title":"EngineObject#mass","link":"mass"},{"title":"EngineObject#mirror","link":"mirror"},{"title":"EngineObject#parent","link":"parent"},{"title":"EngineObject#pos","link":"pos"},{"title":"EngineObject#removeChild","link":"removeChild","description":"

Removes a child from this one

"},{"title":"EngineObject#render","link":"render","description":"

Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder

"},{"title":"EngineObject#renderOrder","link":"renderOrder"},{"title":"EngineObject#setCollision","link":"setCollision","description":"

Set how this object collides

"},{"title":"EngineObject#size","link":"size"},{"title":"EngineObject#spawnTime","link":"spawnTime"},{"title":"EngineObject#tileInfo","link":"tileInfo"},{"title":"EngineObject#toString","link":"toString","description":"

Returns string containg info about this object for debugging

"},{"title":"EngineObject#update","link":"update","description":"

Update the object transform and physics, called automatically by engine once each frame

"},{"title":"EngineObject#velocity","link":"velocity"},{"title":"FontImage","link":"FontImage","description":"

Create an image font

"},{"title":"FontImage#drawText","link":"drawText","description":"

Draw text in world space using the image font

"},{"title":"FontImage#drawTextScreen","link":"drawTextScreen","description":"

Draw text in screen space using the image font

"},{"title":"Input","link":"Input","description":"

LittleJS Input System

\n"},{"title":"Input.clearInput","link":"clearInput","description":"

Clears all input

"},{"title":"Input.gamepadIsDown","link":"gamepadIsDown","description":"

Returns true if gamepad button is down

"},{"title":"Input.gamepadStick","link":"gamepadStick","description":"

Returns gamepad stick value

"},{"title":"Input.gamepadWasPressed","link":"gamepadWasPressed","description":"

Returns true if gamepad button was pressed

"},{"title":"Input.gamepadWasReleased","link":"gamepadWasReleased","description":"

Returns true if gamepad button was released

"},{"title":"Input.isTouchDevice","link":"isTouchDevice","description":"

True if a touch device has been detected

"},{"title":"Input.isUsingGamepad","link":"isUsingGamepad","description":"

Returns true if user is using gamepad (has more recently pressed a gamepad button)

"},{"title":"Input.keyIsDown","link":"keyIsDown","description":"

Returns true if device key is down

"},{"title":"Input.keyWasPressed","link":"keyWasPressed","description":"

Returns true if device key was pressed this frame

"},{"title":"Input.keyWasReleased","link":"keyWasReleased","description":"

Returns true if device key was released this frame

"},{"title":"Input.mouseIsDown","link":"mouseIsDown","description":"

Returns true if mouse button is down

"},{"title":"Input.mousePos","link":"mousePos","description":"

Mouse pos in world space

"},{"title":"Input.mousePosScreen","link":"mousePosScreen","description":"

Mouse pos in screen space

"},{"title":"Input.mouseWasPressed","link":"mouseWasPressed","description":"

Returns true if mouse button was pressed

"},{"title":"Input.mouseWasReleased","link":"mouseWasReleased","description":"

Returns true if mouse button was released

"},{"title":"Input.mouseWheel","link":"mouseWheel","description":"

Mouse wheel delta this frame

"},{"title":"Input.preventDefaultInput","link":"preventDefaultInput","description":"

Prevents input continuing to the default browser handling (false by default)

"},{"title":"Input.vibrate","link":"vibrate","description":"

Pulse the vibration hardware if it exists

"},{"title":"Input.vibrateStop","link":"vibrateStop","description":"

Cancel any ongoing vibration

"},{"title":"Medal","link":"Medal","description":"

Create a medal object and adds it to the list of medals

"},{"title":"Medal#render","link":"render","description":"

Render a medal

"},{"title":"Medal#renderIcon","link":"renderIcon","description":"

Render the icon for a medal

"},{"title":"Medal#unlock","link":"unlock","description":"

Unlocks a medal if not already unlocked

"},{"title":"Medals","link":"Medals","description":"

LittleJS Medal System

\n"},{"title":"Medals.medals","link":"medals","description":"

List of all medals

"},{"title":"Medals.medalsInit","link":"medalsInit","description":"

Initialize medals with a save name used for storage

\n"},{"title":"Medals.newgroundsInit","link":"newgroundsInit","description":"

This can used to enable Newgrounds functionality

"},{"title":"Music","link":"Music","description":"

Create a music object and cache the zzfx music samples for later use

"},{"title":"Music#playMusic","link":"playMusic","description":"

Play the music

"},{"title":"Newgrounds","link":"Newgrounds","description":"

Create a newgrounds object

"},{"title":"Newgrounds#call","link":"call","description":"

Send a message to call a component of the Newgrounds API

"},{"title":"Newgrounds#getScores","link":"getScores","description":"

Get scores from a scoreboard

"},{"title":"Newgrounds#logView","link":"logView","description":"

Send message to log a view

"},{"title":"Newgrounds#postScore","link":"postScore","description":"

Send message to post score

"},{"title":"Newgrounds#unlockMedal","link":"unlockMedal","description":"

Send message to unlock a medal by id

"},{"title":"Particle","link":"Particle","description":"

Create a particle with the given shis.colorStart = undefined;ettings

"},{"title":"Particle#additive","link":"additive"},{"title":"Particle#colorEndDelta","link":"colorEndDelta"},{"title":"Particle#colorStart","link":"colorStart"},{"title":"Particle#destroyCallback","link":"destroyCallback"},{"title":"Particle#fadeRate","link":"fadeRate"},{"title":"Particle#lifeTime","link":"lifeTime"},{"title":"Particle#localSpaceEmitter","link":"localSpaceEmitter"},{"title":"Particle#render","link":"render","description":"

Render the particle, automatically called each frame, sorted by renderOrder

"},{"title":"Particle#sizeEndDelta","link":"sizeEndDelta"},{"title":"Particle#sizeStart","link":"sizeStart"},{"title":"Particle#trailScale","link":"trailScale"},{"title":"ParticleEmitter","link":"ParticleEmitter","description":"

Create a particle system with the given settings

"},{"title":"ParticleEmitter#additive","link":"additive"},{"title":"ParticleEmitter#angleDamping","link":"angleDamping"},{"title":"ParticleEmitter#angleSpeed","link":"angleSpeed"},{"title":"ParticleEmitter#collideTiles","link":"collideTiles"},{"title":"ParticleEmitter#colorEndA","link":"colorEndA"},{"title":"ParticleEmitter#colorEndB","link":"colorEndB"},{"title":"ParticleEmitter#colorStartA","link":"colorStartA"},{"title":"ParticleEmitter#colorStartB","link":"colorStartB"},{"title":"ParticleEmitter#damping","link":"damping"},{"title":"ParticleEmitter#emitConeAngle","link":"emitConeAngle"},{"title":"ParticleEmitter#emitParticle","link":"emitParticle","description":"

Spawn one particle

"},{"title":"ParticleEmitter#emitRate","link":"emitRate"},{"title":"ParticleEmitter#emitSize","link":"emitSize"},{"title":"ParticleEmitter#emitTime","link":"emitTime"},{"title":"ParticleEmitter#emitTimeBuffer","link":"emitTimeBuffer"},{"title":"ParticleEmitter#fadeRate","link":"fadeRate"},{"title":"ParticleEmitter#gravityScale","link":"gravityScale"},{"title":"ParticleEmitter#localSpace","link":"localSpace"},{"title":"ParticleEmitter#particleConeAngle","link":"particleConeAngle"},{"title":"ParticleEmitter#particleCreateCallback","link":"particleCreateCallback"},{"title":"ParticleEmitter#particleDestroyCallback","link":"particleDestroyCallback"},{"title":"ParticleEmitter#particleTime","link":"particleTime"},{"title":"ParticleEmitter#randomColorLinear","link":"randomColorLinear"},{"title":"ParticleEmitter#randomness","link":"randomness"},{"title":"ParticleEmitter#sizeEnd","link":"sizeEnd"},{"title":"ParticleEmitter#sizeStart","link":"sizeStart"},{"title":"ParticleEmitter#speed","link":"speed"},{"title":"ParticleEmitter#trailScale","link":"trailScale"},{"title":"ParticleEmitter#update","link":"update","description":"

Update the emitter to spawn particles, called automatically by engine once each frame

"},{"title":"Random","link":"Random","description":"

Random global functions

"},{"title":"Random.rand","link":"rand","description":"

Returns a random value between the two values passed in

"},{"title":"Random.randColor","link":"randColor","description":"

Returns a random color between the two passed in colors, combine components if linear

"},{"title":"Random.randInCircle","link":"randInCircle","description":"

Returns a random Vector2 within a circular shape

"},{"title":"Random.randInt","link":"randInt","description":"

Returns a floored random value the two values passed in

"},{"title":"Random.randSign","link":"randSign","description":"

Randomly returns either -1 or 1

"},{"title":"Random.randVector","link":"randVector","description":"

Returns a random Vector2 with the passed in length

"},{"title":"RandomGenerator","link":"RandomGenerator","description":"

Create a random number generator with the seed passed in

"},{"title":"RandomGenerator#float","link":"float","description":"

Returns a seeded random value between the two values passed in

"},{"title":"RandomGenerator#int","link":"int","description":"

Returns a floored seeded random value the two values passed in

"},{"title":"RandomGenerator#seed","link":"seed"},{"title":"RandomGenerator#sign","link":"sign","description":"

Randomly returns either -1 or 1 deterministically

"},{"title":"Settings","link":"Settings","description":"

LittleJS Engine Settings

\n"},{"title":"Settings.cameraPos","link":"cameraPos","description":"

Position of camera in world space

"},{"title":"Settings.cameraScale","link":"cameraScale","description":"

Scale of camera in world space

"},{"title":"Settings.canvasFixedSize","link":"canvasFixedSize","description":"

Fixed size of the canvas, if enabled canvas size never changes

\n"},{"title":"Settings.canvasMaxSize","link":"canvasMaxSize","description":"

The max size of the canvas, centered if window is larger

"},{"title":"Settings.canvasPixelated","link":"canvasPixelated","description":"

Disables filtering for crisper pixel art if true

"},{"title":"Settings.enablePhysicsSolver","link":"enablePhysicsSolver","description":"

Enable physics solver for collisions between objects

"},{"title":"Settings.fontDefault","link":"fontDefault","description":"

Default font used for text rendering

"},{"title":"Settings.gamepadDirectionEmulateStick","link":"gamepadDirectionEmulateStick","description":"

If true, the dpad input is also routed to the left analog stick (for better accessability)

"},{"title":"Settings.gamepadsEnable","link":"gamepadsEnable","description":"

Should gamepads be allowed

"},{"title":"Settings.glEnable","link":"glEnable","description":"

Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)

"},{"title":"Settings.glOverlay","link":"glOverlay","description":"

Fixes slow rendering in some browsers by not compositing the WebGL canvas

"},{"title":"Settings.gravity","link":"gravity","description":"

How much gravity to apply to objects along the Y axis, negative is down

"},{"title":"Settings.inputWASDEmulateDirection","link":"inputWASDEmulateDirection","description":"

If true the WASD keys are also routed to the direction keys (for better accessability)

"},{"title":"Settings.medalDisplayIconSize","link":"medalDisplayIconSize","description":"

Size of icon in medal display

"},{"title":"Settings.medalDisplaySize","link":"medalDisplaySize","description":"

Size of medal display

"},{"title":"Settings.medalDisplaySlideTime","link":"medalDisplaySlideTime","description":"

How quickly to slide on/off medals in seconds

"},{"title":"Settings.medalDisplayTime","link":"medalDisplayTime","description":"

How long to show medals for in seconds

"},{"title":"Settings.medalsPreventUnlock","link":"medalsPreventUnlock","description":"

Set to stop medals from being unlockable (like if cheats are enabled)

"},{"title":"Settings.objectDefaultAngleDamping","link":"objectDefaultAngleDamping","description":"

How much to slow angular velocity each frame (0-1)

"},{"title":"Settings.objectDefaultDamping","link":"objectDefaultDamping","description":"

How much to slow velocity by each frame (0-1)

"},{"title":"Settings.objectDefaultElasticity","link":"objectDefaultElasticity","description":"

How much to bounce when a collision occurs (0-1)

"},{"title":"Settings.objectDefaultFriction","link":"objectDefaultFriction","description":"

How much to slow when touching (0-1)

"},{"title":"Settings.objectDefaultMass","link":"objectDefaultMass","description":"

Default object mass for collison calcuations (how heavy objects are)

"},{"title":"Settings.objectMaxSpeed","link":"objectMaxSpeed","description":"

Clamp max speed to avoid fast objects missing collisions

"},{"title":"Settings.particleEmitRateScale","link":"particleEmitRateScale","description":"

Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)

"},{"title":"Settings.setCameraPos","link":"setCameraPos","description":"

Set position of camera in world space

"},{"title":"Settings.setCameraScale","link":"setCameraScale","description":"

Set scale of camera in world space

"},{"title":"Settings.setCanvasFixedSize","link":"setCanvasFixedSize","description":"

Set fixed size of the canvas

"},{"title":"Settings.setCanvasMaxSize","link":"setCanvasMaxSize","description":"

Set max size of the canvas

"},{"title":"Settings.setCanvasPixelated","link":"setCanvasPixelated","description":"

Disables anti aliasing for pixel art if true

"},{"title":"Settings.setEnablePhysicsSolver","link":"setEnablePhysicsSolver","description":"

Set if collisions between objects are enabled

"},{"title":"Settings.setFontDefault","link":"setFontDefault","description":"

Set default font used for text rendering

"},{"title":"Settings.setGamepadDirectionEmulateStick","link":"setGamepadDirectionEmulateStick","description":"

Set if the dpad input is also routed to the left analog stick

"},{"title":"Settings.setGamepadsEnable","link":"setGamepadsEnable","description":"

Set if gamepads are enabled

"},{"title":"Settings.setGlEnable","link":"setGlEnable","description":"

Set if webgl rendering is enabled

"},{"title":"Settings.setGlOverlay","link":"setGlOverlay","description":"

Set to not composite the WebGL canvas

"},{"title":"Settings.setGravity","link":"setGravity","description":"

Set how much gravity to apply to objects along the Y axis

"},{"title":"Settings.setInputWASDEmulateDirection","link":"setInputWASDEmulateDirection","description":"

Set if true the WASD keys are also routed to the direction keys

"},{"title":"Settings.setMedalDisplayIconSize","link":"setMedalDisplayIconSize","description":"

Set size of icon in medal display

"},{"title":"Settings.setMedalDisplaySize","link":"setMedalDisplaySize","description":"

Set size of medal display

"},{"title":"Settings.setMedalDisplaySlideTime","link":"setMedalDisplaySlideTime","description":"

Set how quickly to slide on/off medals in seconds

"},{"title":"Settings.setMedalDisplayTime","link":"setMedalDisplayTime","description":"

Set how long to show medals for in seconds

"},{"title":"Settings.setMedalsPreventUnlock","link":"setMedalsPreventUnlock","description":"

Set to stop medals from being unlockable

"},{"title":"Settings.setObjectDefaultAngleDamping","link":"setObjectDefaultAngleDamping","description":"

Set how much to slow angular velocity each frame

"},{"title":"Settings.setObjectDefaultDamping","link":"setObjectDefaultDamping","description":"

Set how much to slow velocity by each frame

"},{"title":"Settings.setObjectDefaultElasticity","link":"setObjectDefaultElasticity","description":"

Set how much to bounce when a collision occur

"},{"title":"Settings.setObjectDefaultFriction","link":"setObjectDefaultFriction","description":"

Set how much to slow when touching

"},{"title":"Settings.setObjectDefaultMass","link":"setObjectDefaultMass","description":"

Set default object mass for collison calcuations

"},{"title":"Settings.setObjectMaxSpeed","link":"setObjectMaxSpeed","description":"

Set max speed to avoid fast objects missing collisions

"},{"title":"Settings.setParticleEmitRateScale","link":"setParticleEmitRateScale","description":"

Set to scales emit rate of particles

"},{"title":"Settings.setShowSplashScreen","link":"setShowSplashScreen","description":"

Set if the LittleJS splash screen be shown on startup

"},{"title":"Settings.setSoundDefaultRange","link":"setSoundDefaultRange","description":"

Set default range where sound no longer plays

"},{"title":"Settings.setSoundDefaultTaper","link":"setSoundDefaultTaper","description":"

Set default range percent to start tapering off sound

"},{"title":"Settings.setSoundEnable","link":"setSoundEnable","description":"

Set to disable all audio code

"},{"title":"Settings.setSoundVolume","link":"setSoundVolume","description":"

Set volume scale to apply to all sound, music and speech

"},{"title":"Settings.setTileFixBleedScale","link":"setTileFixBleedScale","description":"

Set to prevent tile bleeding from neighbors in pixels

"},{"title":"Settings.setTileSizeDefault","link":"setTileSizeDefault","description":"

Set default size of tiles in pixels

"},{"title":"Settings.setTouchGamepadAlpha","link":"setTouchGamepadAlpha","description":"

Set transparency of touch gamepad overlay

"},{"title":"Settings.setTouchGamepadAnalog","link":"setTouchGamepadAnalog","description":"

Set if touch gamepad should be analog stick or 8 way dpad

"},{"title":"Settings.setTouchGamepadEnable","link":"setTouchGamepadEnable","description":"

Set if touch gamepad should appear on mobile devices

"},{"title":"Settings.setTouchGamepadSize","link":"setTouchGamepadSize","description":"

Set size of virutal gamepad for touch devices in pixels

"},{"title":"Settings.setVibrateEnable","link":"setVibrateEnable","description":"

Set to allow vibration hardware if it exists

"},{"title":"Settings.showSplashScreen","link":"showSplashScreen","description":"

Enable to show the LittleJS splash screen be shown on startup

"},{"title":"Settings.soundDefaultRange","link":"soundDefaultRange","description":"

Default range where sound no longer plays

"},{"title":"Settings.soundDefaultTaper","link":"soundDefaultTaper","description":"

Default range percent to start tapering off sound (0-1)

"},{"title":"Settings.soundEnable","link":"soundEnable","description":"

All audio code can be disabled and removed from build

"},{"title":"Settings.soundVolume","link":"soundVolume","description":"

Volume scale to apply to all sound, music and speech

"},{"title":"Settings.tileFixBleedScale","link":"tileFixBleedScale","description":"

How many pixels smaller to draw tiles to prevent bleeding from neighbors

"},{"title":"Settings.tileSizeDefault","link":"tileSizeDefault","description":"

Default size of tiles in pixels

"},{"title":"Settings.touchGamepadAlpha","link":"touchGamepadAlpha","description":"

Transparency of touch gamepad overlay

"},{"title":"Settings.touchGamepadAnalog","link":"touchGamepadAnalog","description":"

True if touch gamepad should be analog stick or false to use if 8 way dpad

"},{"title":"Settings.touchGamepadEnable","link":"touchGamepadEnable","description":"

True if touch gamepad should appear on mobile devices

\n"},{"title":"Settings.touchGamepadSize","link":"touchGamepadSize","description":"

Size of virutal gamepad for touch devices in pixels

"},{"title":"Settings.vibrateEnable","link":"vibrateEnable","description":"

Allow vibration hardware if it exists

"},{"title":"Sound","link":"Sound","description":"

Create a sound object and cache the zzfx samples for later use

"},{"title":"Sound#getDuration","link":"getDuration","description":"

Get how long this sound is in seconds

"},{"title":"Sound#getSource","link":"getSource","description":"

Get source of most recent instance of this sound that was played

"},{"title":"Sound#isLoading","link":"isLoading","description":"

Check if sound is loading, for sounds fetched from a url

"},{"title":"Sound#play","link":"play","description":"

Play the sound

"},{"title":"Sound#playNote","link":"playNote","description":"

Play the sound as a note with a semitone offset

"},{"title":"Sound#randomness","link":"randomness"},{"title":"Sound#range","link":"range"},{"title":"Sound#stop","link":"stop","description":"

Stop the last instance of this sound that was played

"},{"title":"Sound#taper","link":"taper"},{"title":"SoundWave","link":"SoundWave","description":"

Create a sound object and cache the wave file for later use

"},{"title":"TextureInfo","link":"TextureInfo","description":"

Create a TextureInfo, called automatically by the engine

"},{"title":"TextureInfo#fixBleedSize","link":"fixBleedSize"},{"title":"TextureInfo#glTexture","link":"glTexture"},{"title":"TextureInfo#image","link":"image"},{"title":"TextureInfo#size","link":"size"},{"title":"TileCollision","link":"TileCollision","description":"

LittleJS Tile Layer System

\n"},{"title":"TileCollision.getTileCollisionData","link":"getTileCollisionData","description":"

Get tile collision data

"},{"title":"TileCollision.initTileCollision","link":"initTileCollision","description":"

Clear and initialize tile collision

"},{"title":"TileCollision.setTileCollisionData","link":"setTileCollisionData","description":"

Set tile collision data

"},{"title":"TileCollision.tileCollision","link":"tileCollision","description":"

The tile collision layer array, use setTileCollisionData and getTileCollisionData to access

"},{"title":"TileCollision.tileCollisionRaycast","link":"tileCollisionRaycast","description":"

Return the center of tile if any that is hit (does not return the exact intersection)

"},{"title":"TileCollision.tileCollisionSize","link":"tileCollisionSize","description":"

Size of the tile collision layer

"},{"title":"TileCollision.tileCollisionTest","link":"tileCollisionTest","description":"

Check if collision with another object should occur

"},{"title":"TileInfo","link":"TileInfo","description":"

Create a tile info object

"},{"title":"TileInfo#getTextureInfo","link":"getTextureInfo","description":"

Returns the texture info for this tile

"},{"title":"TileInfo#offset","link":"offset","description":"

Returns an offset copy of this tile, useful for animation

"},{"title":"TileInfo#pos","link":"pos"},{"title":"TileInfo#size","link":"size"},{"title":"TileInfo#textureIndex","link":"textureIndex"},{"title":"TileLayer","link":"TileLayer","description":"

Create a tile layer object

"},{"title":"TileLayer#canvas","link":"canvas"},{"title":"TileLayer#context","link":"context"},{"title":"TileLayer#drawCanvas2D","link":"drawCanvas2D","description":"

Draw directly to the 2D canvas in world space (bipass webgl)

"},{"title":"TileLayer#drawRect","link":"drawRect","description":"

Draw a rectangle directly onto the layer canvas in world space

"},{"title":"TileLayer#drawTile","link":"drawTile","description":"

Draw a tile directly onto the layer canvas in world space

"},{"title":"TileLayer#drawTileData","link":"drawTileData","description":"

Draw the tile at a given position in the tile grid\nThis can be used to clear out tiles when they are destroyed\nTiles can also be redrawn if isinde a redrawStart/End block

"},{"title":"TileLayer#getData","link":"getData","description":"

Get data at a given position in the array

"},{"title":"TileLayer#isOverlay","link":"isOverlay"},{"title":"TileLayer#redraw","link":"redraw","description":"

Draw all the tile data to an offscreen canvas

\n"},{"title":"TileLayer#redrawEnd","link":"redrawEnd","description":"

Call to end the redraw process

"},{"title":"TileLayer#redrawStart","link":"redrawStart","description":"

Call to start the redraw process

\n"},{"title":"TileLayer#savedRenderSettings","link":"savedRenderSettings"},{"title":"TileLayer#scale","link":"scale"},{"title":"TileLayer#setData","link":"setData","description":"

Set data at a given position in the array

"},{"title":"TileLayerData","link":"TileLayerData","description":"

Create a tile layer data object, one for each tile in a TileLayer

"},{"title":"TileLayerData#clear","link":"clear","description":"

Set this tile to clear, it will not be rendered

"},{"title":"TileLayerData#color","link":"color"},{"title":"TileLayerData#direction","link":"direction"},{"title":"TileLayerData#mirror","link":"mirror"},{"title":"TileLayerData#tile","link":"tile"},{"title":"Timer","link":"Timer","description":"

Create a timer object set time passed in

"},{"title":"Timer#active","link":"active","description":"

Returns true if set and has not elapsed

"},{"title":"Timer#elapsed","link":"elapsed","description":"

Returns true if set and elapsed

"},{"title":"Timer#get","link":"get","description":"

Get how long since elapsed, returns 0 if not set (returns negative if currently active)

"},{"title":"Timer#getPercent","link":"getPercent","description":"

Get percentage elapsed based on time it was set to, returns 0 if not set

"},{"title":"Timer#isSet","link":"isSet","description":"

Returns true if set

"},{"title":"Timer#set","link":"set","description":"

Set the timer with seconds passed in

"},{"title":"Timer#toString","link":"toString","description":"

Returns this timer expressed as a string

"},{"title":"Timer#unset","link":"unset","description":"

Unset the timer

"},{"title":"Timer#valueOf","link":"valueOf","description":"

Get how long since elapsed, returns 0 if not set (returns negative if currently active)

"},{"title":"Utilities","link":"Utilities","description":"

LittleJS Utility Classes and Functions

\n"},{"title":"Utilities.PI","link":"PI","description":"

A shortcut to get Math.PI

"},{"title":"Utilities.abs","link":"abs","description":"

Returns absoulte value of value passed in

"},{"title":"Utilities.clamp","link":"clamp","description":"

Clamps the value beween max and min

"},{"title":"Utilities.distanceAngle","link":"distanceAngle","description":"

Returns signed wrapped distance between the two angles passed in

"},{"title":"Utilities.distanceWrap","link":"distanceWrap","description":"

Returns signed wrapped distance between the two values passed in

"},{"title":"Utilities.formatTime","link":"formatTime","description":"

Formats seconds to mm:ss style for display purposes

"},{"title":"Utilities.hsl","link":"hsl","description":"

Create a color object with HSLA values, white by default

"},{"title":"Utilities.isColor","link":"isColor","description":"

Check if object is a valid Color

"},{"title":"Utilities.isOverlapping","link":"isOverlapping","description":"

Returns true if two axis aligned bounding boxes are overlapping

"},{"title":"Utilities.isVector2","link":"isVector2","description":"

Check if object is a valid Vector2

"},{"title":"Utilities.lerp","link":"lerp","description":"

Linearly interpolates between values passed in using percent

"},{"title":"Utilities.lerpAngle","link":"lerpAngle","description":"

Linearly interpolates between the angles passed in with wrappping

"},{"title":"Utilities.lerpWrap","link":"lerpWrap","description":"

Linearly interpolates between values passed in with wrappping

"},{"title":"Utilities.max","link":"max","description":"

Returns highest of two values passed in

"},{"title":"Utilities.min","link":"min","description":"

Returns lowest of two values passed in

"},{"title":"Utilities.mod","link":"mod","description":"

Returns first parm modulo the second param, but adjusted so negative numbers work as expected

"},{"title":"Utilities.nearestPowerOfTwo","link":"nearestPowerOfTwo","description":"

Returns the nearest power of two not less then the value

"},{"title":"Utilities.percent","link":"percent","description":"

Returns what percentage the value is between valueA and valueB

"},{"title":"Utilities.rgb","link":"rgb","description":"

Create a color object with RGBA values, white by default

"},{"title":"Utilities.sign","link":"sign","description":"

Returns the sign of value passed in (also returns 1 if 0)

"},{"title":"Utilities.smoothStep","link":"smoothStep","description":"

Applies smoothstep function to the percentage value

"},{"title":"Utilities.vec2","link":"vec2","description":"

Create a 2d vector, can take another Vector2 to copy, 2 scalars, or 1 scalar

"},{"title":"Utilities.wave","link":"wave","description":"

Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default

"},{"title":"Vector2","link":"Vector2","description":"

Create a 2D vector with the x and y passed in, can also be created with vec2()

"},{"title":"Vector2#add","link":"add","description":"

Returns a copy of this vector plus the vector passed in

"},{"title":"Vector2#angle","link":"angle","description":"

Returns the angle of this vector, up is angle 0

"},{"title":"Vector2#area","link":"area","description":"

Returns the area this vector covers as a rectangle

"},{"title":"Vector2#arrayCheck","link":"arrayCheck","description":"

Returns true if this vector is within the bounds of an array size passed in

"},{"title":"Vector2#clampLength","link":"clampLength","description":"

Returns a new vector clamped to length passed in

"},{"title":"Vector2#copy","link":"copy","description":"

Returns a new vector that is a copy of this

"},{"title":"Vector2#cross","link":"cross","description":"

Returns the cross product of this and the vector passed in

"},{"title":"Vector2#direction","link":"direction","description":"

Returns the integer direction of this vector, corrosponding to multiples of 90 degree rotation (0-3)

"},{"title":"Vector2#distance","link":"distance","description":"

Returns the distance from this vector to vector passed in

"},{"title":"Vector2#distanceSquared","link":"distanceSquared","description":"

Returns the distance squared from this vector to vector passed in

"},{"title":"Vector2#divide","link":"divide","description":"

Returns a copy of this vector divided by the vector passed in

"},{"title":"Vector2#dot","link":"dot","description":"

Returns the dot product of this and the vector passed in

"},{"title":"Vector2#floor","link":"floor","description":"

Returns a copy of this vector with each axis floored

"},{"title":"Vector2#invert","link":"invert","description":"

Returns a copy of this vector that has been inverted

"},{"title":"Vector2#length","link":"length","description":"

Returns the length of this vector

"},{"title":"Vector2#lengthSquared","link":"lengthSquared","description":"

Returns the length of this vector squared

"},{"title":"Vector2#lerp","link":"lerp","description":"

Returns a new vector that is p percent between this and the vector passed in

"},{"title":"Vector2#multiply","link":"multiply","description":"

Returns a copy of this vector times the vector passed in

"},{"title":"Vector2#normalize","link":"normalize","description":"

Returns a new vector in same direction as this one with the length passed in

"},{"title":"Vector2#rotate","link":"rotate","description":"

Returns copy of this vector rotated by the angle passed in

"},{"title":"Vector2#scale","link":"scale","description":"

Returns a copy of this vector scaled by the vector passed in

"},{"title":"Vector2#setAngle","link":"setAngle","description":"

Sets this vector with angle and length passed in

"},{"title":"Vector2#setDirection","link":"setDirection","description":"

Set the integer direction of this vector, corrosponding to multiples of 90 degree rotation (0-3)

"},{"title":"Vector2#subtract","link":"subtract","description":"

Returns a copy of this vector minus the vector passed in

"},{"title":"Vector2#toString","link":"toString","description":"

Returns this vector expressed as a string

"},{"title":"Vector2#x","link":"x"},{"title":"Vector2#y","link":"y"},{"title":"WebGL","link":"WebGL","description":"

LittleJS WebGL Interface

\n"},{"title":"WebGL.glCanvas","link":"glCanvas","description":"

The WebGL canvas which appears above the main canvas and below the overlay canvas

"},{"title":"WebGL.glCompileShader","link":"glCompileShader","description":"

Compile WebGL shader of the given type, will throw errors if in debug mode

"},{"title":"WebGL.glContext","link":"glContext","description":"

2d context for glCanvas

"},{"title":"WebGL.glCopyToContext","link":"glCopyToContext","description":"

Draw any sprites still in the buffer, copy to main canvas and clear

"},{"title":"WebGL.glCreateProgram","link":"glCreateProgram","description":"

Create WebGL program with given shaders

"},{"title":"WebGL.glCreateTexture","link":"glCreateTexture","description":"

Create WebGL texture from an image and init the texture settings

"},{"title":"WebGL.glDraw","link":"glDraw","description":"

Add a sprite to the gl draw list, used by all gl draw functions

"},{"title":"WebGL.glFlush","link":"glFlush","description":"

Draw all sprites and clear out the buffer, called automatically by the system whenever necessary

"},{"title":"WebGL.glInitPostProcess","link":"glInitPostProcess","description":"

Set up a post processing shader

"},{"title":"WebGL.glSetTexture","link":"glSetTexture","description":"

Set the WebGl texture, called automatically if using multiple textures

\n"}]} \ No newline at end of file +{"list":[{"title":"Audio","link":"Audio","description":"

LittleJS Audio System

\n"},{"title":"Audio.audioContext","link":"audioContext","description":"

Audio context used by the engine

"},{"title":"Audio.audioSuspended","link":"audioSuspended","description":"

Keep track if audio was suspended when last sound was played

"},{"title":"Audio.getNoteFrequency","link":"getNoteFrequency","description":"

Get frequency of a note on a musical scale

"},{"title":"Audio.playAudioFile","link":"playAudioFile","description":"

Play an mp3, ogg, or wav audio from a local file or url

"},{"title":"Audio.playSamples","link":"playSamples","description":"

Play cached audio samples with given settings

"},{"title":"Audio.speak","link":"speak","description":"

Speak text with passed in settings

"},{"title":"Audio.speakStop","link":"speakStop","description":"

Stop all queued speech

"},{"title":"Audio.zzfx","link":"zzfx","description":"

Generate and play a ZzFX sound

\n

Create sounds using the ZzFX Sound Designer.

"},{"title":"Audio.zzfxG","link":"zzfxG","description":"

Generate samples for a ZzFX sound

"},{"title":"Audio.zzfxM","link":"zzfxM","description":"

Generate samples for a ZzFM song with given parameters

"},{"title":"Audio.zzfxR","link":"zzfxR","description":"

Sample rate used for all ZzFX sounds

"},{"title":"Color","link":"Color","description":"

Create a color with the rgba components passed in, white by default

"},{"title":"Color#HSLA","link":"HSLA","description":"

Returns this color expressed in hsla format

"},{"title":"Color#a","link":"a"},{"title":"Color#add","link":"add","description":"

Returns a copy of this color plus the color passed in

"},{"title":"Color#b","link":"b"},{"title":"Color#clamp","link":"clamp","description":"

Returns a copy of this color clamped to the valid range between 0 and 1

"},{"title":"Color#copy","link":"copy","description":"

Returns a new color that is a copy of this

"},{"title":"Color#divide","link":"divide","description":"

Returns a copy of this color divided by the color passed in

"},{"title":"Color#g","link":"g"},{"title":"Color#lerp","link":"lerp","description":"

Returns a new color that is p percent between this and the color passed in

"},{"title":"Color#multiply","link":"multiply","description":"

Returns a copy of this color times the color passed in

"},{"title":"Color#mutate","link":"mutate","description":"

Returns a new color that has each component randomly adjusted

"},{"title":"Color#r","link":"r"},{"title":"Color#rgbaInt","link":"rgbaInt","description":"

Returns this color expressed as 32 bit RGBA value

"},{"title":"Color#scale","link":"scale","description":"

Returns a copy of this color scaled by the value passed in, alpha can be scaled separately

"},{"title":"Color#setHSLA","link":"setHSLA","description":"

Sets this color given a hue, saturation, lightness, and alpha

"},{"title":"Color#setHex","link":"setHex","description":"

Set this color from a hex code

"},{"title":"Color#subtract","link":"subtract","description":"

Returns a copy of this color minus the color passed in

"},{"title":"Color#toString","link":"toString","description":"

Returns this color expressed as a hex color code

"},{"title":"Debug","link":"Debug","description":"

LittleJS Debug System

\n"},{"title":"Debug.ASSERT","link":"ASSERT","description":"

Asserts if the expression is false, does not do anything in release builds

"},{"title":"Debug.debug","link":"debug","description":"

True if debug is enabled

"},{"title":"Debug.debugAABB","link":"debugAABB","description":"

Draw a debug axis aligned bounding box in world space

"},{"title":"Debug.debugCircle","link":"debugCircle","description":"

Draw a debug circle in world space

"},{"title":"Debug.debugClear","link":"debugClear","description":"

Clear all debug primitives in the list

"},{"title":"Debug.debugKey","link":"debugKey","description":"

Key code used to toggle debug mode, Esc by default

"},{"title":"Debug.debugLine","link":"debugLine","description":"

Draw a debug line in world space

"},{"title":"Debug.debugOverlay","link":"debugOverlay","description":"

True if the debug overlay is active, always false in release builds

"},{"title":"Debug.debugPoint","link":"debugPoint","description":"

Draw a debug point in world space

"},{"title":"Debug.debugPointSize","link":"debugPointSize","description":"

Size to render debug points by default

"},{"title":"Debug.debugRect","link":"debugRect","description":"

Draw a debug rectangle in world space

"},{"title":"Debug.debugSaveCanvas","link":"debugSaveCanvas","description":"

Save a canvas to disk

"},{"title":"Debug.debugSaveDataURL","link":"debugSaveDataURL","description":"

Save a data url to disk

"},{"title":"Debug.debugSaveText","link":"debugSaveText","description":"

Save a text file to disk

"},{"title":"Debug.debugText","link":"debugText","description":"

Draw a debug axis aligned bounding box in world space

"},{"title":"Debug.enableAsserts","link":"enableAsserts","description":"

True if asserts are enaled

"},{"title":"Debug.setDebugKey","link":"setDebugKey","description":"

Set key code used to toggle debug mode, Esc by default

"},{"title":"Debug.setShowWatermark","link":"setShowWatermark","description":"

Set if watermark with FPS should be shown

"},{"title":"Debug.showWatermark","link":"showWatermark","description":"

True if watermark with FPS should be shown, false in release builds

"},{"title":"Draw","link":"Draw","description":"

LittleJS Drawing System

\n\n

LittleJS uses a hybrid rendering solution with the best of both Canvas2D and WebGL.\nThere are 3 canvas/contexts available to draw to...\nmainCanvas - 2D background canvas, non WebGL stuff like tile layers are drawn here.\nglCanvas - Used by the accelerated WebGL batch rendering system.\noverlayCanvas - Another 2D canvas that appears on top of the other 2 canvases.

\n

The WebGL rendering system is very fast with some caveats...

\n\n

The LittleJS rendering solution is intentionally simple, feel free to adjust it for your needs!

"},{"title":"Draw.drawCanvas2D","link":"drawCanvas2D","description":"

Draw directly to a 2d canvas context in world space

"},{"title":"Draw.drawLine","link":"drawLine","description":"

Draw colored line between two points

"},{"title":"Draw.drawRect","link":"drawRect","description":"

Draw colored rect centered on pos

"},{"title":"Draw.drawText","link":"drawText","description":"

Draw text on overlay canvas in world space\nAutomatically splits new lines into rows

"},{"title":"Draw.drawTextScreen","link":"drawTextScreen","description":"

Draw text on overlay canvas in screen space\nAutomatically splits new lines into rows

"},{"title":"Draw.drawTile","link":"drawTile","description":"

Draw textured tile centered in world space, with color applied if using WebGL

"},{"title":"Draw.getCameraSize","link":"getCameraSize","description":"

Get the camera's visible area in world space

"},{"title":"Draw.isFullscreen","link":"isFullscreen","description":"

Returns true if fullscreen mode is active

"},{"title":"Draw.mainCanvas","link":"mainCanvas","description":"

The primary 2D canvas visible to the user

"},{"title":"Draw.mainCanvasSize","link":"mainCanvasSize","description":"

The size of the main canvas (and other secondary canvases)

"},{"title":"Draw.mainContext","link":"mainContext","description":"

2d context for mainCanvas

"},{"title":"Draw.overlayCanvas","link":"overlayCanvas","description":"

A canvas that appears on top of everything the same size as mainCanvas

"},{"title":"Draw.overlayContext","link":"overlayContext","description":"

2d context for overlayCanvas

"},{"title":"Draw.screenToWorld","link":"screenToWorld","description":"

Convert from screen to world space coordinates

"},{"title":"Draw.setBlendMode","link":"setBlendMode","description":"

Enable normal or additive blend mode

"},{"title":"Draw.textureInfos","link":"textureInfos","description":"

Array containing texture info for batch rendering system

"},{"title":"Draw.tile","link":"tile","description":"

Create a tile info object

\n"},{"title":"Draw.toggleFullscreen","link":"toggleFullscreen","description":"

Toggle fullsceen mode

"},{"title":"Draw.worldToScreen","link":"worldToScreen","description":"

Convert from world to screen space coordinates

"},{"title":"Engine","link":"Engine","description":"

LittleJS - The Tiny Fast JavaScript Game Engine\nMIT License - Copyright 2021 Frank Force

\n

Engine Features

\n"},{"title":"Engine.engineInit","link":"engineInit","description":"

Startup LittleJS engine with your callback functions

"},{"title":"Engine.engineName","link":"engineName","description":"

Name of engine

"},{"title":"Engine.engineObjects","link":"engineObjects","description":"

Array containing all engine objects

"},{"title":"Engine.engineObjectsCallback","link":"engineObjectsCallback","description":"

Triggers a callback for each object within a given area

"},{"title":"Engine.engineObjectsCollide","link":"engineObjectsCollide","description":"

Array with only objects set to collide with other objects this frame (for optimization)

"},{"title":"Engine.engineObjectsDestroy","link":"engineObjectsDestroy","description":"

Destroy and remove all objects

"},{"title":"Engine.engineObjectsUpdate","link":"engineObjectsUpdate","description":"

Update each engine object, remove destroyed objects, and update time

"},{"title":"Engine.engineVersion","link":"engineVersion","description":"

Version of engine

"},{"title":"Engine.frame","link":"frame","description":"

Current update frame, used to calculate time

"},{"title":"Engine.frameRate","link":"frameRate","description":"

Frames per second to update

"},{"title":"Engine.paused","link":"paused","description":"

Is the game paused? Causes time and objects to not be updated

"},{"title":"Engine.setPaused","link":"setPaused","description":"

Set if game is paused

"},{"title":"Engine.time","link":"time","description":"

Current engine time since start in seconds

"},{"title":"Engine.timeDelta","link":"timeDelta","description":"

How many seconds each frame lasts, engine uses a fixed time step

"},{"title":"Engine.timeReal","link":"timeReal","description":"

Actual clock time since start in seconds (not affected by pause or frame rate clamping)

"},{"title":"EngineObject","link":"EngineObject","description":"

Create an engine object and adds it to the list of objects

"},{"title":"EngineObject#addChild","link":"addChild","description":"

Attaches a child to this with a given local transform

"},{"title":"EngineObject#additiveColor","link":"additiveColor"},{"title":"EngineObject#angle","link":"angle"},{"title":"EngineObject#angleDamping","link":"angleDamping"},{"title":"EngineObject#angleVelocity","link":"angleVelocity"},{"title":"EngineObject#applyAcceleration","link":"applyAcceleration","description":"

Apply acceleration to this object (adjust velocity, not affected by mass)

"},{"title":"EngineObject#applyForce","link":"applyForce","description":"

Apply force to this object (adjust velocity, affected by mass)

"},{"title":"EngineObject#children","link":"children"},{"title":"EngineObject#collideSolidObjects","link":"collideSolidObjects"},{"title":"EngineObject#collideTiles","link":"collideTiles"},{"title":"EngineObject#collideWithObject","link":"collideWithObject","description":"

Called to check if a object collision should be resolved

"},{"title":"EngineObject#collideWithTile","link":"collideWithTile","description":"

Called to check if a tile collision should be resolved

"},{"title":"EngineObject#collideWithTileRaycast","link":"collideWithTileRaycast","description":"

Called to check if a tile raycast hit

"},{"title":"EngineObject#color","link":"color"},{"title":"EngineObject#damping","link":"damping"},{"title":"EngineObject#destroy","link":"destroy","description":"

Destroy this object, destroy it's children, detach it's parent, and mark it for removal

"},{"title":"EngineObject#drawSize","link":"drawSize"},{"title":"EngineObject#elasticity","link":"elasticity"},{"title":"EngineObject#friction","link":"friction"},{"title":"EngineObject#getAliveTime","link":"getAliveTime","description":"

How long since the object was created

"},{"title":"EngineObject#getMirrorSign","link":"getMirrorSign","description":"

Get the direction of the mirror

"},{"title":"EngineObject#gravityScale","link":"gravityScale"},{"title":"EngineObject#isSolid","link":"isSolid"},{"title":"EngineObject#localAngle","link":"localAngle"},{"title":"EngineObject#localPos","link":"localPos"},{"title":"EngineObject#mass","link":"mass"},{"title":"EngineObject#mirror","link":"mirror"},{"title":"EngineObject#parent","link":"parent"},{"title":"EngineObject#pos","link":"pos"},{"title":"EngineObject#removeChild","link":"removeChild","description":"

Removes a child from this one

"},{"title":"EngineObject#render","link":"render","description":"

Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder

"},{"title":"EngineObject#renderOrder","link":"renderOrder"},{"title":"EngineObject#setCollision","link":"setCollision","description":"

Set how this object collides

"},{"title":"EngineObject#size","link":"size"},{"title":"EngineObject#spawnTime","link":"spawnTime"},{"title":"EngineObject#tileInfo","link":"tileInfo"},{"title":"EngineObject#toString","link":"toString","description":"

Returns string containg info about this object for debugging

"},{"title":"EngineObject#update","link":"update","description":"

Update the object transform and physics, called automatically by engine once each frame

"},{"title":"EngineObject#velocity","link":"velocity"},{"title":"FontImage","link":"FontImage","description":"

Create an image font

"},{"title":"FontImage#drawText","link":"drawText","description":"

Draw text in world space using the image font

"},{"title":"FontImage#drawTextScreen","link":"drawTextScreen","description":"

Draw text in screen space using the image font

"},{"title":"Input","link":"Input","description":"

LittleJS Input System

\n"},{"title":"Input.clearInput","link":"clearInput","description":"

Clears all input

"},{"title":"Input.gamepadIsDown","link":"gamepadIsDown","description":"

Returns true if gamepad button is down

"},{"title":"Input.gamepadStick","link":"gamepadStick","description":"

Returns gamepad stick value

"},{"title":"Input.gamepadWasPressed","link":"gamepadWasPressed","description":"

Returns true if gamepad button was pressed

"},{"title":"Input.gamepadWasReleased","link":"gamepadWasReleased","description":"

Returns true if gamepad button was released

"},{"title":"Input.isTouchDevice","link":"isTouchDevice","description":"

True if a touch device has been detected

"},{"title":"Input.isUsingGamepad","link":"isUsingGamepad","description":"

Returns true if user is using gamepad (has more recently pressed a gamepad button)

"},{"title":"Input.keyIsDown","link":"keyIsDown","description":"

Returns true if device key is down

"},{"title":"Input.keyWasPressed","link":"keyWasPressed","description":"

Returns true if device key was pressed this frame

"},{"title":"Input.keyWasReleased","link":"keyWasReleased","description":"

Returns true if device key was released this frame

"},{"title":"Input.mouseIsDown","link":"mouseIsDown","description":"

Returns true if mouse button is down

"},{"title":"Input.mousePos","link":"mousePos","description":"

Mouse pos in world space

"},{"title":"Input.mousePosScreen","link":"mousePosScreen","description":"

Mouse pos in screen space

"},{"title":"Input.mouseWasPressed","link":"mouseWasPressed","description":"

Returns true if mouse button was pressed

"},{"title":"Input.mouseWasReleased","link":"mouseWasReleased","description":"

Returns true if mouse button was released

"},{"title":"Input.mouseWheel","link":"mouseWheel","description":"

Mouse wheel delta this frame

"},{"title":"Input.preventDefaultInput","link":"preventDefaultInput","description":"

Prevents input continuing to the default browser handling (false by default)

"},{"title":"Input.vibrate","link":"vibrate","description":"

Pulse the vibration hardware if it exists

"},{"title":"Input.vibrateStop","link":"vibrateStop","description":"

Cancel any ongoing vibration

"},{"title":"Medal","link":"Medal","description":"

Create a medal object and adds it to the list of medals

"},{"title":"Medal#render","link":"render","description":"

Render a medal

"},{"title":"Medal#renderIcon","link":"renderIcon","description":"

Render the icon for a medal

"},{"title":"Medal#unlock","link":"unlock","description":"

Unlocks a medal if not already unlocked

"},{"title":"Medals","link":"Medals","description":"

LittleJS Medal System

\n"},{"title":"Medals.medals","link":"medals","description":"

List of all medals

"},{"title":"Medals.medalsInit","link":"medalsInit","description":"

Initialize medals with a save name used for storage

\n"},{"title":"Medals.newgroundsInit","link":"newgroundsInit","description":"

This can used to enable Newgrounds functionality

"},{"title":"Music","link":"Music","description":"

Create a music object and cache the zzfx music samples for later use

"},{"title":"Music#playMusic","link":"playMusic","description":"

Play the music

"},{"title":"Newgrounds","link":"Newgrounds","description":"

Create a newgrounds object

"},{"title":"Newgrounds#call","link":"call","description":"

Send a message to call a component of the Newgrounds API

"},{"title":"Newgrounds#getScores","link":"getScores","description":"

Get scores from a scoreboard

"},{"title":"Newgrounds#logView","link":"logView","description":"

Send message to log a view

"},{"title":"Newgrounds#postScore","link":"postScore","description":"

Send message to post score

"},{"title":"Newgrounds#unlockMedal","link":"unlockMedal","description":"

Send message to unlock a medal by id

"},{"title":"Particle","link":"Particle","description":"

Create a particle with the given shis.colorStart = undefined;ettings

"},{"title":"Particle#additive","link":"additive"},{"title":"Particle#colorEndDelta","link":"colorEndDelta"},{"title":"Particle#colorStart","link":"colorStart"},{"title":"Particle#destroyCallback","link":"destroyCallback"},{"title":"Particle#fadeRate","link":"fadeRate"},{"title":"Particle#lifeTime","link":"lifeTime"},{"title":"Particle#localSpaceEmitter","link":"localSpaceEmitter"},{"title":"Particle#render","link":"render","description":"

Render the particle, automatically called each frame, sorted by renderOrder

"},{"title":"Particle#sizeEndDelta","link":"sizeEndDelta"},{"title":"Particle#sizeStart","link":"sizeStart"},{"title":"Particle#trailScale","link":"trailScale"},{"title":"ParticleEmitter","link":"ParticleEmitter","description":"

Create a particle system with the given settings

"},{"title":"ParticleEmitter#additive","link":"additive"},{"title":"ParticleEmitter#angleDamping","link":"angleDamping"},{"title":"ParticleEmitter#angleSpeed","link":"angleSpeed"},{"title":"ParticleEmitter#collideTiles","link":"collideTiles"},{"title":"ParticleEmitter#colorEndA","link":"colorEndA"},{"title":"ParticleEmitter#colorEndB","link":"colorEndB"},{"title":"ParticleEmitter#colorStartA","link":"colorStartA"},{"title":"ParticleEmitter#colorStartB","link":"colorStartB"},{"title":"ParticleEmitter#damping","link":"damping"},{"title":"ParticleEmitter#emitConeAngle","link":"emitConeAngle"},{"title":"ParticleEmitter#emitParticle","link":"emitParticle","description":"

Spawn one particle

"},{"title":"ParticleEmitter#emitRate","link":"emitRate"},{"title":"ParticleEmitter#emitSize","link":"emitSize"},{"title":"ParticleEmitter#emitTime","link":"emitTime"},{"title":"ParticleEmitter#emitTimeBuffer","link":"emitTimeBuffer"},{"title":"ParticleEmitter#fadeRate","link":"fadeRate"},{"title":"ParticleEmitter#gravityScale","link":"gravityScale"},{"title":"ParticleEmitter#localSpace","link":"localSpace"},{"title":"ParticleEmitter#particleConeAngle","link":"particleConeAngle"},{"title":"ParticleEmitter#particleCreateCallback","link":"particleCreateCallback"},{"title":"ParticleEmitter#particleDestroyCallback","link":"particleDestroyCallback"},{"title":"ParticleEmitter#particleTime","link":"particleTime"},{"title":"ParticleEmitter#randomColorLinear","link":"randomColorLinear"},{"title":"ParticleEmitter#randomness","link":"randomness"},{"title":"ParticleEmitter#sizeEnd","link":"sizeEnd"},{"title":"ParticleEmitter#sizeStart","link":"sizeStart"},{"title":"ParticleEmitter#speed","link":"speed"},{"title":"ParticleEmitter#trailScale","link":"trailScale"},{"title":"ParticleEmitter#update","link":"update","description":"

Update the emitter to spawn particles, called automatically by engine once each frame

"},{"title":"Random","link":"Random","description":"

Random global functions

"},{"title":"Random.rand","link":"rand","description":"

Returns a random value between the two values passed in

"},{"title":"Random.randColor","link":"randColor","description":"

Returns a random color between the two passed in colors, combine components if linear

"},{"title":"Random.randInCircle","link":"randInCircle","description":"

Returns a random Vector2 within a circular shape

"},{"title":"Random.randInt","link":"randInt","description":"

Returns a floored random value the two values passed in

"},{"title":"Random.randSign","link":"randSign","description":"

Randomly returns either -1 or 1

"},{"title":"Random.randVector","link":"randVector","description":"

Returns a random Vector2 with the passed in length

"},{"title":"RandomGenerator","link":"RandomGenerator","description":"

Create a random number generator with the seed passed in

"},{"title":"RandomGenerator#float","link":"float","description":"

Returns a seeded random value between the two values passed in

"},{"title":"RandomGenerator#int","link":"int","description":"

Returns a floored seeded random value the two values passed in

"},{"title":"RandomGenerator#seed","link":"seed"},{"title":"RandomGenerator#sign","link":"sign","description":"

Randomly returns either -1 or 1 deterministically

"},{"title":"Settings","link":"Settings","description":"

LittleJS Engine Settings

\n"},{"title":"Settings.cameraPos","link":"cameraPos","description":"

Position of camera in world space

"},{"title":"Settings.cameraScale","link":"cameraScale","description":"

Scale of camera in world space

"},{"title":"Settings.canvasFixedSize","link":"canvasFixedSize","description":"

Fixed size of the canvas, if enabled canvas size never changes

\n"},{"title":"Settings.canvasMaxSize","link":"canvasMaxSize","description":"

The max size of the canvas, centered if window is larger

"},{"title":"Settings.canvasPixelated","link":"canvasPixelated","description":"

Disables filtering for crisper pixel art if true

"},{"title":"Settings.enablePhysicsSolver","link":"enablePhysicsSolver","description":"

Enable physics solver for collisions between objects

"},{"title":"Settings.fontDefault","link":"fontDefault","description":"

Default font used for text rendering

"},{"title":"Settings.gamepadDirectionEmulateStick","link":"gamepadDirectionEmulateStick","description":"

If true, the dpad input is also routed to the left analog stick (for better accessability)

"},{"title":"Settings.gamepadsEnable","link":"gamepadsEnable","description":"

Should gamepads be allowed

"},{"title":"Settings.glEnable","link":"glEnable","description":"

Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)

"},{"title":"Settings.glOverlay","link":"glOverlay","description":"

Fixes slow rendering in some browsers by not compositing the WebGL canvas

"},{"title":"Settings.gravity","link":"gravity","description":"

How much gravity to apply to objects along the Y axis, negative is down

"},{"title":"Settings.inputWASDEmulateDirection","link":"inputWASDEmulateDirection","description":"

If true the WASD keys are also routed to the direction keys (for better accessability)

"},{"title":"Settings.medalDisplayIconSize","link":"medalDisplayIconSize","description":"

Size of icon in medal display

"},{"title":"Settings.medalDisplaySize","link":"medalDisplaySize","description":"

Size of medal display

"},{"title":"Settings.medalDisplaySlideTime","link":"medalDisplaySlideTime","description":"

How quickly to slide on/off medals in seconds

"},{"title":"Settings.medalDisplayTime","link":"medalDisplayTime","description":"

How long to show medals for in seconds

"},{"title":"Settings.medalsPreventUnlock","link":"medalsPreventUnlock","description":"

Set to stop medals from being unlockable (like if cheats are enabled)

"},{"title":"Settings.objectDefaultAngleDamping","link":"objectDefaultAngleDamping","description":"

How much to slow angular velocity each frame (0-1)

"},{"title":"Settings.objectDefaultDamping","link":"objectDefaultDamping","description":"

How much to slow velocity by each frame (0-1)

"},{"title":"Settings.objectDefaultElasticity","link":"objectDefaultElasticity","description":"

How much to bounce when a collision occurs (0-1)

"},{"title":"Settings.objectDefaultFriction","link":"objectDefaultFriction","description":"

How much to slow when touching (0-1)

"},{"title":"Settings.objectDefaultMass","link":"objectDefaultMass","description":"

Default object mass for collision calcuations (how heavy objects are)

"},{"title":"Settings.objectMaxSpeed","link":"objectMaxSpeed","description":"

Clamp max speed to avoid fast objects missing collisions

"},{"title":"Settings.particleEmitRateScale","link":"particleEmitRateScale","description":"

Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)

"},{"title":"Settings.setCameraPos","link":"setCameraPos","description":"

Set position of camera in world space

"},{"title":"Settings.setCameraScale","link":"setCameraScale","description":"

Set scale of camera in world space

"},{"title":"Settings.setCanvasFixedSize","link":"setCanvasFixedSize","description":"

Set fixed size of the canvas

"},{"title":"Settings.setCanvasMaxSize","link":"setCanvasMaxSize","description":"

Set max size of the canvas

"},{"title":"Settings.setCanvasPixelated","link":"setCanvasPixelated","description":"

Disables anti aliasing for pixel art if true

"},{"title":"Settings.setEnablePhysicsSolver","link":"setEnablePhysicsSolver","description":"

Set if collisions between objects are enabled

"},{"title":"Settings.setFontDefault","link":"setFontDefault","description":"

Set default font used for text rendering

"},{"title":"Settings.setGamepadDirectionEmulateStick","link":"setGamepadDirectionEmulateStick","description":"

Set if the dpad input is also routed to the left analog stick

"},{"title":"Settings.setGamepadsEnable","link":"setGamepadsEnable","description":"

Set if gamepads are enabled

"},{"title":"Settings.setGlEnable","link":"setGlEnable","description":"

Set if webgl rendering is enabled

"},{"title":"Settings.setGlOverlay","link":"setGlOverlay","description":"

Set to not composite the WebGL canvas

"},{"title":"Settings.setGravity","link":"setGravity","description":"

Set how much gravity to apply to objects along the Y axis

"},{"title":"Settings.setInputWASDEmulateDirection","link":"setInputWASDEmulateDirection","description":"

Set if true the WASD keys are also routed to the direction keys

"},{"title":"Settings.setMedalDisplayIconSize","link":"setMedalDisplayIconSize","description":"

Set size of icon in medal display

"},{"title":"Settings.setMedalDisplaySize","link":"setMedalDisplaySize","description":"

Set size of medal display

"},{"title":"Settings.setMedalDisplaySlideTime","link":"setMedalDisplaySlideTime","description":"

Set how quickly to slide on/off medals in seconds

"},{"title":"Settings.setMedalDisplayTime","link":"setMedalDisplayTime","description":"

Set how long to show medals for in seconds

"},{"title":"Settings.setMedalsPreventUnlock","link":"setMedalsPreventUnlock","description":"

Set to stop medals from being unlockable

"},{"title":"Settings.setObjectDefaultAngleDamping","link":"setObjectDefaultAngleDamping","description":"

Set how much to slow angular velocity each frame

"},{"title":"Settings.setObjectDefaultDamping","link":"setObjectDefaultDamping","description":"

Set how much to slow velocity by each frame

"},{"title":"Settings.setObjectDefaultElasticity","link":"setObjectDefaultElasticity","description":"

Set how much to bounce when a collision occur

"},{"title":"Settings.setObjectDefaultFriction","link":"setObjectDefaultFriction","description":"

Set how much to slow when touching

"},{"title":"Settings.setObjectDefaultMass","link":"setObjectDefaultMass","description":"

Set default object mass for collison calcuations

"},{"title":"Settings.setObjectMaxSpeed","link":"setObjectMaxSpeed","description":"

Set max speed to avoid fast objects missing collisions

"},{"title":"Settings.setParticleEmitRateScale","link":"setParticleEmitRateScale","description":"

Set to scales emit rate of particles

"},{"title":"Settings.setShowSplashScreen","link":"setShowSplashScreen","description":"

Set if the LittleJS splash screen be shown on startup

"},{"title":"Settings.setSoundDefaultRange","link":"setSoundDefaultRange","description":"

Set default range where sound no longer plays

"},{"title":"Settings.setSoundDefaultTaper","link":"setSoundDefaultTaper","description":"

Set default range percent to start tapering off sound

"},{"title":"Settings.setSoundEnable","link":"setSoundEnable","description":"

Set to disable all audio code

"},{"title":"Settings.setSoundVolume","link":"setSoundVolume","description":"

Set volume scale to apply to all sound, music and speech

"},{"title":"Settings.setTileFixBleedScale","link":"setTileFixBleedScale","description":"

Set to prevent tile bleeding from neighbors in pixels

"},{"title":"Settings.setTileSizeDefault","link":"setTileSizeDefault","description":"

Set default size of tiles in pixels

"},{"title":"Settings.setTouchGamepadAlpha","link":"setTouchGamepadAlpha","description":"

Set transparency of touch gamepad overlay

"},{"title":"Settings.setTouchGamepadAnalog","link":"setTouchGamepadAnalog","description":"

Set if touch gamepad should be analog stick or 8 way dpad

"},{"title":"Settings.setTouchGamepadEnable","link":"setTouchGamepadEnable","description":"

Set if touch gamepad should appear on mobile devices

"},{"title":"Settings.setTouchGamepadSize","link":"setTouchGamepadSize","description":"

Set size of virutal gamepad for touch devices in pixels

"},{"title":"Settings.setVibrateEnable","link":"setVibrateEnable","description":"

Set to allow vibration hardware if it exists

"},{"title":"Settings.showSplashScreen","link":"showSplashScreen","description":"

Enable to show the LittleJS splash screen be shown on startup

"},{"title":"Settings.soundDefaultRange","link":"soundDefaultRange","description":"

Default range where sound no longer plays

"},{"title":"Settings.soundDefaultTaper","link":"soundDefaultTaper","description":"

Default range percent to start tapering off sound (0-1)

"},{"title":"Settings.soundEnable","link":"soundEnable","description":"

All audio code can be disabled and removed from build

"},{"title":"Settings.soundVolume","link":"soundVolume","description":"

Volume scale to apply to all sound, music and speech

"},{"title":"Settings.tileFixBleedScale","link":"tileFixBleedScale","description":"

How many pixels smaller to draw tiles to prevent bleeding from neighbors

"},{"title":"Settings.tileSizeDefault","link":"tileSizeDefault","description":"

Default size of tiles in pixels

"},{"title":"Settings.touchGamepadAlpha","link":"touchGamepadAlpha","description":"

Transparency of touch gamepad overlay

"},{"title":"Settings.touchGamepadAnalog","link":"touchGamepadAnalog","description":"

True if touch gamepad should be analog stick or false to use if 8 way dpad

"},{"title":"Settings.touchGamepadEnable","link":"touchGamepadEnable","description":"

True if touch gamepad should appear on mobile devices

\n"},{"title":"Settings.touchGamepadSize","link":"touchGamepadSize","description":"

Size of virtual gamepad for touch devices in pixels

"},{"title":"Settings.vibrateEnable","link":"vibrateEnable","description":"

Allow vibration hardware if it exists

"},{"title":"Sound","link":"Sound","description":"

Create a sound object and cache the zzfx samples for later use

"},{"title":"Sound#getDuration","link":"getDuration","description":"

Get how long this sound is in seconds

"},{"title":"Sound#getSource","link":"getSource","description":"

Get source of most recent instance of this sound that was played

"},{"title":"Sound#isLoading","link":"isLoading","description":"

Check if sound is loading, for sounds fetched from a url

"},{"title":"Sound#play","link":"play","description":"

Play the sound

"},{"title":"Sound#playNote","link":"playNote","description":"

Play the sound as a note with a semitone offset

"},{"title":"Sound#randomness","link":"randomness"},{"title":"Sound#range","link":"range"},{"title":"Sound#stop","link":"stop","description":"

Stop the last instance of this sound that was played

"},{"title":"Sound#taper","link":"taper"},{"title":"SoundWave","link":"SoundWave","description":"

Create a sound object and cache the wave file for later use

"},{"title":"TextureInfo","link":"TextureInfo","description":"

Create a TextureInfo, called automatically by the engine

"},{"title":"TextureInfo#fixBleedSize","link":"fixBleedSize"},{"title":"TextureInfo#glTexture","link":"glTexture"},{"title":"TextureInfo#image","link":"image"},{"title":"TextureInfo#size","link":"size"},{"title":"TileCollision","link":"TileCollision","description":"

LittleJS Tile Layer System

\n"},{"title":"TileCollision.getTileCollisionData","link":"getTileCollisionData","description":"

Get tile collision data

"},{"title":"TileCollision.initTileCollision","link":"initTileCollision","description":"

Clear and initialize tile collision

"},{"title":"TileCollision.setTileCollisionData","link":"setTileCollisionData","description":"

Set tile collision data

"},{"title":"TileCollision.tileCollision","link":"tileCollision","description":"

The tile collision layer array, use setTileCollisionData and getTileCollisionData to access

"},{"title":"TileCollision.tileCollisionRaycast","link":"tileCollisionRaycast","description":"

Return the center of tile if any that is hit (does not return the exact intersection)

"},{"title":"TileCollision.tileCollisionSize","link":"tileCollisionSize","description":"

Size of the tile collision layer

"},{"title":"TileCollision.tileCollisionTest","link":"tileCollisionTest","description":"

Check if collision with another object should occur

"},{"title":"TileInfo","link":"TileInfo","description":"

Create a tile info object

"},{"title":"TileInfo#frame","link":"frame","description":"

Returns a copy of this tile offset by a number of animation frames

"},{"title":"TileInfo#getTextureInfo","link":"getTextureInfo","description":"

Returns the texture info for this tile

"},{"title":"TileInfo#offset","link":"offset","description":"

Returns a copy of this tile offset by a vector

"},{"title":"TileInfo#pos","link":"pos"},{"title":"TileInfo#size","link":"size"},{"title":"TileInfo#textureIndex","link":"textureIndex"},{"title":"TileLayer","link":"TileLayer","description":"

Create a tile layer object

"},{"title":"TileLayer#canvas","link":"canvas"},{"title":"TileLayer#context","link":"context"},{"title":"TileLayer#drawCanvas2D","link":"drawCanvas2D","description":"

Draw directly to the 2D canvas in world space (bipass webgl)

"},{"title":"TileLayer#drawRect","link":"drawRect","description":"

Draw a rectangle directly onto the layer canvas in world space

"},{"title":"TileLayer#drawTile","link":"drawTile","description":"

Draw a tile directly onto the layer canvas in world space

"},{"title":"TileLayer#drawTileData","link":"drawTileData","description":"

Draw the tile at a given position in the tile grid\nThis can be used to clear out tiles when they are destroyed\nTiles can also be redrawn if isinde a redrawStart/End block

"},{"title":"TileLayer#getData","link":"getData","description":"

Get data at a given position in the array

"},{"title":"TileLayer#isOverlay","link":"isOverlay"},{"title":"TileLayer#redraw","link":"redraw","description":"

Draw all the tile data to an offscreen canvas

\n"},{"title":"TileLayer#redrawEnd","link":"redrawEnd","description":"

Call to end the redraw process

"},{"title":"TileLayer#redrawStart","link":"redrawStart","description":"

Call to start the redraw process

\n"},{"title":"TileLayer#savedRenderSettings","link":"savedRenderSettings"},{"title":"TileLayer#scale","link":"scale"},{"title":"TileLayer#setData","link":"setData","description":"

Set data at a given position in the array

"},{"title":"TileLayerData","link":"TileLayerData","description":"

Create a tile layer data object, one for each tile in a TileLayer

"},{"title":"TileLayerData#clear","link":"clear","description":"

Set this tile to clear, it will not be rendered

"},{"title":"TileLayerData#color","link":"color"},{"title":"TileLayerData#direction","link":"direction"},{"title":"TileLayerData#mirror","link":"mirror"},{"title":"TileLayerData#tile","link":"tile"},{"title":"Timer","link":"Timer","description":"

Create a timer object set time passed in

"},{"title":"Timer#active","link":"active","description":"

Returns true if set and has not elapsed

"},{"title":"Timer#elapsed","link":"elapsed","description":"

Returns true if set and elapsed

"},{"title":"Timer#get","link":"get","description":"

Get how long since elapsed, returns 0 if not set (returns negative if currently active)

"},{"title":"Timer#getPercent","link":"getPercent","description":"

Get percentage elapsed based on time it was set to, returns 0 if not set

"},{"title":"Timer#isSet","link":"isSet","description":"

Returns true if set

"},{"title":"Timer#set","link":"set","description":"

Set the timer with seconds passed in

"},{"title":"Timer#toString","link":"toString","description":"

Returns this timer expressed as a string

"},{"title":"Timer#unset","link":"unset","description":"

Unset the timer

"},{"title":"Timer#valueOf","link":"valueOf","description":"

Get how long since elapsed, returns 0 if not set (returns negative if currently active)

"},{"title":"Utilities","link":"Utilities","description":"

LittleJS Utility Classes and Functions

\n"},{"title":"Utilities.PI","link":"PI","description":"

A shortcut to get Math.PI

"},{"title":"Utilities.abs","link":"abs","description":"

Returns absoulte value of value passed in

"},{"title":"Utilities.clamp","link":"clamp","description":"

Clamps the value beween max and min

"},{"title":"Utilities.distanceAngle","link":"distanceAngle","description":"

Returns signed wrapped distance between the two angles passed in

"},{"title":"Utilities.distanceWrap","link":"distanceWrap","description":"

Returns signed wrapped distance between the two values passed in

"},{"title":"Utilities.formatTime","link":"formatTime","description":"

Formats seconds to mm:ss style for display purposes

"},{"title":"Utilities.hsl","link":"hsl","description":"

Create a color object with HSLA values, white by default

"},{"title":"Utilities.isColor","link":"isColor","description":"

Check if object is a valid Color

"},{"title":"Utilities.isOverlapping","link":"isOverlapping","description":"

Returns true if two axis aligned bounding boxes are overlapping

"},{"title":"Utilities.isVector2","link":"isVector2","description":"

Check if object is a valid Vector2

"},{"title":"Utilities.lerp","link":"lerp","description":"

Linearly interpolates between values passed in using percent

"},{"title":"Utilities.lerpAngle","link":"lerpAngle","description":"

Linearly interpolates between the angles passed in with wrapping

"},{"title":"Utilities.lerpWrap","link":"lerpWrap","description":"

Linearly interpolates between values passed in with wrapping

"},{"title":"Utilities.max","link":"max","description":"

Returns highest of two values passed in

"},{"title":"Utilities.min","link":"min","description":"

Returns lowest of two values passed in

"},{"title":"Utilities.mod","link":"mod","description":"

Returns first parm modulo the second param, but adjusted so negative numbers work as expected

"},{"title":"Utilities.nearestPowerOfTwo","link":"nearestPowerOfTwo","description":"

Returns the nearest power of two not less then the value

"},{"title":"Utilities.percent","link":"percent","description":"

Returns what percentage the value is between valueA and valueB

"},{"title":"Utilities.rgb","link":"rgb","description":"

Create a color object with RGBA values, white by default

"},{"title":"Utilities.sign","link":"sign","description":"

Returns the sign of value passed in

"},{"title":"Utilities.smoothStep","link":"smoothStep","description":"

Applies smoothstep function to the percentage value

"},{"title":"Utilities.vec2","link":"vec2","description":"

Create a 2d vector, can take another Vector2 to copy, 2 scalars, or 1 scalar

"},{"title":"Utilities.wave","link":"wave","description":"

Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default

"},{"title":"Vector2","link":"Vector2","description":"

Create a 2D vector with the x and y passed in, can also be created with vec2()

"},{"title":"Vector2#add","link":"add","description":"

Returns a copy of this vector plus the vector passed in

"},{"title":"Vector2#angle","link":"angle","description":"

Returns the angle of this vector, up is angle 0

"},{"title":"Vector2#area","link":"area","description":"

Returns the area this vector covers as a rectangle

"},{"title":"Vector2#arrayCheck","link":"arrayCheck","description":"

Returns true if this vector is within the bounds of an array size passed in

"},{"title":"Vector2#clampLength","link":"clampLength","description":"

Returns a new vector clamped to length passed in

"},{"title":"Vector2#copy","link":"copy","description":"

Returns a new vector that is a copy of this

"},{"title":"Vector2#cross","link":"cross","description":"

Returns the cross product of this and the vector passed in

"},{"title":"Vector2#direction","link":"direction","description":"

Returns the integer direction of this vector, corrosponding to multiples of 90 degree rotation (0-3)

"},{"title":"Vector2#distance","link":"distance","description":"

Returns the distance from this vector to vector passed in

"},{"title":"Vector2#distanceSquared","link":"distanceSquared","description":"

Returns the distance squared from this vector to vector passed in

"},{"title":"Vector2#divide","link":"divide","description":"

Returns a copy of this vector divided by the vector passed in

"},{"title":"Vector2#dot","link":"dot","description":"

Returns the dot product of this and the vector passed in

"},{"title":"Vector2#floor","link":"floor","description":"

Returns a copy of this vector with each axis floored

"},{"title":"Vector2#invert","link":"invert","description":"

Returns a copy of this vector that has been inverted

"},{"title":"Vector2#length","link":"length","description":"

Returns the length of this vector

"},{"title":"Vector2#lengthSquared","link":"lengthSquared","description":"

Returns the length of this vector squared

"},{"title":"Vector2#lerp","link":"lerp","description":"

Returns a new vector that is p percent between this and the vector passed in

"},{"title":"Vector2#multiply","link":"multiply","description":"

Returns a copy of this vector times the vector passed in

"},{"title":"Vector2#normalize","link":"normalize","description":"

Returns a new vector in same direction as this one with the length passed in

"},{"title":"Vector2#rotate","link":"rotate","description":"

Returns copy of this vector rotated by the angle passed in

"},{"title":"Vector2#scale","link":"scale","description":"

Returns a copy of this vector scaled by the vector passed in

"},{"title":"Vector2#setAngle","link":"setAngle","description":"

Sets this vector with angle and length passed in

"},{"title":"Vector2#setDirection","link":"setDirection","description":"

Set the integer direction of this vector, corrosponding to multiples of 90 degree rotation (0-3)

"},{"title":"Vector2#subtract","link":"subtract","description":"

Returns a copy of this vector minus the vector passed in

"},{"title":"Vector2#toString","link":"toString","description":"

Returns this vector expressed as a string

"},{"title":"Vector2#x","link":"x"},{"title":"Vector2#y","link":"y"},{"title":"WebGL","link":"WebGL","description":"

LittleJS WebGL Interface

\n"},{"title":"WebGL.glCanvas","link":"glCanvas","description":"

The WebGL canvas which appears above the main canvas and below the overlay canvas

"},{"title":"WebGL.glCompileShader","link":"glCompileShader","description":"

Compile WebGL shader of the given type, will throw errors if in debug mode

"},{"title":"WebGL.glContext","link":"glContext","description":"

2d context for glCanvas

"},{"title":"WebGL.glCopyToContext","link":"glCopyToContext","description":"

Draw any sprites still in the buffer, copy to main canvas and clear

"},{"title":"WebGL.glCreateProgram","link":"glCreateProgram","description":"

Create WebGL program with given shaders

"},{"title":"WebGL.glCreateTexture","link":"glCreateTexture","description":"

Create WebGL texture from an image and init the texture settings

"},{"title":"WebGL.glDraw","link":"glDraw","description":"

Add a sprite to the gl draw list, used by all gl draw functions

"},{"title":"WebGL.glFlush","link":"glFlush","description":"

Draw all sprites and clear out the buffer, called automatically by the system whenever necessary

"},{"title":"WebGL.glInitPostProcess","link":"glInitPostProcess","description":"

Set up a post processing shader

"},{"title":"WebGL.glSetTexture","link":"glSetTexture","description":"

Set the WebGl texture, called automatically if using multiple textures

\n"}]} \ No newline at end of file diff --git a/docs/engine.js.html b/docs/engine.js.html index 37e3a4ed..0093120d 100644 --- a/docs/engine.js.html +++ b/docs/engine.js.html @@ -1,7 +1,7 @@ Source: engine.js
On this page

engine.js

/** 
- * LittleJS - The Tiny JavaScript Game Engine That Can!
+ * LittleJS - The Tiny Fast JavaScript Game Engine
  * MIT License - Copyright 2021 Frank Force
  * 
  * Engine Features
@@ -32,9 +32,9 @@
  *  @type {String}
  *  @default
  *  @memberof Engine */
-const engineVersion = '1.9.2';
+const engineVersion = '1.9.4';
 
-/** Frames per second to update objects
+/** Frames per second to update
  *  @type {Number}
  *  @default
  *  @memberof Engine */
@@ -51,7 +51,7 @@
  *  @memberof Engine */
 let engineObjects = [];
 
-/** Array containing only objects that are set to collide with other objects this frame (for optimization)
+/** Array with only objects set to collide with other objects this frame (for optimization)
  *  @type {Array}
  *  @memberof Engine */
 let engineObjectsCollide = [];
@@ -61,7 +61,7 @@
  *  @memberof Engine */
 let frame = 0;
 
-/** Current engine time since start in seconds, derived from frame
+/** Current engine time since start in seconds
  *  @type {Number}
  *  @memberof Engine */
 let time = 0;
@@ -87,12 +87,12 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-/** Start up LittleJS engine with your callback functions
- *  @param {Function} gameInit        - Called once after the engine starts up, setup the game
- *  @param {Function} gameUpdate      - Called every frame at 60 frames per second, handle input and update the game state
- *  @param {Function} gameUpdatePost  - Called after physics and objects are updated, setup camera and prepare for render
- *  @param {Function} gameRender      - Called before objects are rendered, draw any background effects that appear behind objects
- *  @param {Function} gameRenderPost  - Called after objects are rendered, draw effects or hud that appear above all objects
+/** Startup LittleJS engine with your callback functions
+ *  @param {Function} gameInit       - Called once after the engine starts up, setup the game
+ *  @param {Function} gameUpdate     - Called every frame at 60 frames per second, handle input and update the game state
+ *  @param {Function} gameUpdatePost - Called after physics and objects are updated, setup camera and prepare for render
+ *  @param {Function} gameRender     - Called before objects are rendered, draw any background effects that appear behind objects
+ *  @param {Function} gameRenderPost - Called after objects are rendered, draw effects or hud that appear above all objects
  *  @param {Array} [imageSources=['tiles.png']] - Image to load
  *  @memberof Engine */
 function engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, imageSources=['tiles.png'])
@@ -114,33 +114,8 @@
         timeReal += frameTimeDeltaMS / 1e3;
         frameTimeBufferMS += paused ? 0 : frameTimeDeltaMS;
         if (!debugSpeedUp)
-            frameTimeBufferMS = min(frameTimeBufferMS, 50); // clamp incase of slow framerate
-
-        if (canvasFixedSize.x)
-        {
-            // clear canvas and set fixed size
-            mainCanvas.width  = canvasFixedSize.x;
-            mainCanvas.height = canvasFixedSize.y;
-            
-            // fit to window by adding space on top or bottom if necessary
-            const aspect = innerWidth / innerHeight;
-            const fixedAspect = mainCanvas.width / mainCanvas.height;
-            (glCanvas||mainCanvas).style.width = mainCanvas.style.width = overlayCanvas.style.width  = aspect < fixedAspect ? '100%' : '';
-            (glCanvas||mainCanvas).style.height = mainCanvas.style.height = overlayCanvas.style.height = aspect < fixedAspect ? '' : '100%';
-        }
-        else
-        {
-            // clear canvas and set size to same as window
-            mainCanvas.width  = min(innerWidth,  canvasMaxSize.x);
-            mainCanvas.height = min(innerHeight, canvasMaxSize.y);
-        }
-        
-        // clear overlay canvas and set size
-        overlayCanvas.width  = mainCanvas.width;
-        overlayCanvas.height = mainCanvas.height;
-
-        // save canvas size
-        mainCanvasSize = vec2(mainCanvas.width, mainCanvas.height);
+            frameTimeBufferMS = min(frameTimeBufferMS, 50); // clamp in case of slow framerate
+        updateCanvas();
 
         if (paused)
         {
@@ -214,6 +189,35 @@
         requestAnimationFrame(engineUpdate);
     }
 
+    function updateCanvas()
+    {
+        if (canvasFixedSize.x)
+        {
+            // clear canvas and set fixed size
+            mainCanvas.width  = canvasFixedSize.x;
+            mainCanvas.height = canvasFixedSize.y;
+            
+            // fit to window by adding space on top or bottom if necessary
+            const aspect = innerWidth / innerHeight;
+            const fixedAspect = mainCanvas.width / mainCanvas.height;
+            (glCanvas||mainCanvas).style.width = mainCanvas.style.width = overlayCanvas.style.width  = aspect < fixedAspect ? '100%' : '';
+            (glCanvas||mainCanvas).style.height = mainCanvas.style.height = overlayCanvas.style.height = aspect < fixedAspect ? '' : '100%';
+        }
+        else
+        {
+            // clear canvas and set size to same as window
+            mainCanvas.width  = min(innerWidth,  canvasMaxSize.x);
+            mainCanvas.height = min(innerHeight, canvasMaxSize.y);
+        }
+        
+        // clear overlay canvas and set size
+        overlayCanvas.width  = mainCanvas.width;
+        overlayCanvas.height = mainCanvas.height;
+
+        // save canvas size
+        mainCanvasSize = vec2(mainCanvas.width, mainCanvas.height);
+    }
+
     // setup html
      const styleBody = 
         'margin:0;overflow:hidden;' + // fill the window
@@ -238,6 +242,7 @@
     const styleCanvas = 'position:absolute;' +             // position
         'top:50%;left:50%;transform:translate(-50%,-50%)'; // center
     (glCanvas||mainCanvas).style.cssText = mainCanvas.style.cssText = overlayCanvas.style.cssText = styleCanvas;
+    updateCanvas();
     
     // create promises for loading images
     const promises = imageSources.map((src, textureIndex)=>
@@ -434,9 +439,9 @@
 
     // big stack
     rect(50,20,10,-10,color(0,1));
-    rect(50,20,6,-10,color(0,2));
-    rect(50,20,3,-10,color(0,3));
-    rect(50,10,10,10);
+    rect(50,20,6.5,-10,color(0,2));
+    rect(50,20,3.5,-10,color(0,3));
+    rect(50,20,10,-10);
     circle(55,2,11.4,.5,PI-.5,color(3,3));
     circle(55,2,11.4,.5,PI/2,color(3,2),1);
     circle(55,2,11.4,.5,PI-.5);
@@ -455,7 +460,7 @@
 
     // engine outline
     circle(36,30,10,PI/2,PI*3/2);
-    circle(47,30,10,PI/2,PI*3/2);
+    circle(48,30,10,PI/2,PI*3/2);
     circle(60,30,10);
     line(36,20,60,20);
 
diff --git a/docs/engineAudio.js.html b/docs/engineAudio.js.html
index 9b733796..3826c424 100644
--- a/docs/engineAudio.js.html
+++ b/docs/engineAudio.js.html
@@ -14,7 +14,7 @@
 'use strict';
 
 /** 
- * Sound Object - Stores a zzfx sound for later use and can be played positionally
+ * Sound Object - Stores a sound for later use and can be played positionally
  * 
  * <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
  * @example
@@ -29,7 +29,7 @@
     /** Create a sound object and cache the zzfx samples for later use
      *  @param {Array}  zzfxSound - Array of zzfx parameters, ex. [.5,.5]
      *  @param {Number} [range=soundDefaultRange] - World space max range of sound, will not play if camera is farther away
-     *  @param {Number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering off
+     *  @param {Number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
      */
     constructor(zzfxSound, range=soundDefaultRange, taper=soundDefaultTaper)
     {
@@ -180,7 +180,7 @@
  *                 1, 0, 9, 1    // channel notes
  *             ], 
  *             [                 // channel 1
- *                 0, 1,         // instrument 1, right speaker
+ *                 0, 1,         // instrument 0, right speaker
  *                 0, 12, 17, -1 // channel notes
  *             ]
  *         ],
@@ -209,24 +209,24 @@
 
     /** Play the music
      *  @param {Number}  [volume=1] - How much to scale volume by
-     *  @param {Boolean} [loop=1] - True if the music should loop
+     *  @param {Boolean} [loop] - True if the music should loop
      *  @return {AudioBufferSourceNode} - The audio source node
      */
-    playMusic(volume, loop = false)
+    playMusic(volume, loop=false)
     { return super.play(undefined, volume, 1, 1, loop); }
 }
 
 /** Play an mp3, ogg, or wav audio from a local file or url
- *  @param {String}  url - Location of sound file to play
+ *  @param {String}  filename - Location of sound file to play
  *  @param {Number}  [volume] - How much to scale volume by
  *  @param {Boolean} [loop] - True if the music should loop
  *  @return {HTMLAudioElement} - The audio element for this sound
  *  @memberof Audio */
-function playAudioFile(url, volume=1, loop=false)
+function playAudioFile(filename, volume=1, loop=false)
 {
     if (!soundEnable) return;
 
-    const audio = new Audio(url);
+    const audio = new Audio(filename);
     audio.volume = soundVolume * volume;
     audio.loop = loop;
     audio.play();
@@ -278,6 +278,11 @@
  *  @memberof Audio */
 let audioContext = new AudioContext;
 
+/** Keep track if audio was suspended when last sound was played
+ *  @type {Boolean}
+ *  @memberof Audio */
+let audioSuspended = false;
+
 /** Play cached audio samples with given settings
  *  @param {Array}   sampleChannels - Array of arrays of samples to play (for stereo playback)
  *  @param {Number}  [volume] - How much to scale volume by
@@ -292,11 +297,15 @@
     if (!soundEnable) return;
 
     // prevent sounds from building up if they can't be played
-    if (audioContext.state != 'running')
+    const audioWasSuspended = audioSuspended;
+    if (audioSuspended = audioContext.state != 'running')
     {
         // fix stalled audio
         audioContext.resume();
-        return;
+
+        // prevent suspended sounds from building up
+        if (audioWasSuspended)
+            return;
     }
 
     // create buffer and source
diff --git a/docs/engineDebug.js.html b/docs/engineDebug.js.html
index 0827d561..10f551f5 100644
--- a/docs/engineDebug.js.html
+++ b/docs/engineDebug.js.html
@@ -54,7 +54,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Debug helper functions
 
-/** Asserts if the experssion is false, does not do anything in release builds
+/** Asserts if the expression is false, does not do anything in release builds
  *  @param {Boolean} assert
  *  @param {Object} [output]
  *  @memberof Debug */
@@ -262,6 +262,10 @@
     {
         const saveContext = mainContext;
         mainContext = overlayContext;
+        
+        // draw red rectangle around screen
+        const cameraSize = getCameraSize();
+        debugRect(cameraPos, cameraSize.subtract(vec2(.1)), '#f008');
 
         // mouse pick
         let bestDistance = Infinity, bestObject;
diff --git a/docs/engineDraw.js.html b/docs/engineDraw.js.html
index 9d3d2b79..5e073355 100644
--- a/docs/engineDraw.js.html
+++ b/docs/engineDraw.js.html
@@ -87,13 +87,9 @@
     if (typeof pos === 'number')
     {
         const textureInfo = textureInfos[textureIndex];
-        if (textureInfo)
-        {
-            const cols = textureInfo.size.x / size.x |0;
-            pos = vec2((pos%cols)*size.x, (pos/cols|0)*size.y);
-        }
-        else
-            pos = vec2();
+        ASSERT(textureInfo, 'Texture not loaded');
+        const cols = textureInfo.size.x / size.x |0;
+        pos = vec2((pos%cols)*size.x, (pos/cols|0)*size.y);
     }
 
     // return a tile info object
@@ -120,13 +116,23 @@
         this.textureIndex = textureIndex;
     }
 
-    /** Returns an offset copy of this tile, useful for animation
+    /** Returns a copy of this tile offset by a vector
     *  @param {Vector2} offset - Offset to apply in pixels
     *  @return {TileInfo}
     */
     offset(offset)
     { return new TileInfo(this.pos.add(offset), this.size, this.textureIndex); }
 
+    /** Returns a copy of this tile offset by a number of animation frames
+    *  @param {Number} frame - Offset to apply in animation frames
+    *  @return {TileInfo}
+    */
+    frame(frame)
+    {
+        ASSERT(typeof frame == 'number');
+        return this.offset(vec2(frame*this.size.x, 0));
+    }
+
     /** Returns the texture info for this tile
     *  @return {TextureInfo}
     */
@@ -182,6 +188,11 @@
     );
 }
 
+/** Get the camera's visible area in world space
+ *  @return {Vector2}
+ *  @memberof Draw */
+function getCameraSize() { return mainCanvasSize.scale(1/cameraScale); }
+
 /** Draw textured tile centered in world space, with color applied if using WebGL
  *  @param {Vector2} pos                        - Center of the tile in world space
  *  @param {Vector2} [size=(1,1)]               - Size of the tile in world space
@@ -272,21 +283,6 @@
     drawTile(pos, size, undefined, color, angle, false, undefined, useWebGL, screenSpace, context); 
 }
 
-/** Draw colored polygon using passed in points
- *  @param {Array}   points - Array of Vector2 points
- *  @param {Color}   [color=(1,1,1,1)]
- *  @param {Boolean} [screenSpace=false]
- *  @param {CanvasRenderingContext2D} [context=mainContext]
- *  @memberof Draw */
-function drawPoly(points, color=new Color, screenSpace, context=mainContext)
-{
-    context.fillStyle = color.toString();
-    context.beginPath();
-    for (const point of screenSpace ? points : points.map(worldToScreen))
-        context.lineTo(point.x, point.y);
-    context.fill();
-}
-
 /** Draw colored line between two points
  *  @param {Vector2} posA
  *  @param {Vector2} posB
diff --git a/docs/engineInput.js.html b/docs/engineInput.js.html
index b306f2d7..cf78202b 100644
--- a/docs/engineInput.js.html
+++ b/docs/engineInput.js.html
@@ -213,9 +213,21 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Gamepad input
 
+// gamepad internal variables
 const stickData = [];
+
+// gamepads are updated by engine every frame automatically
 function gamepadsUpdate()
 {
+    const applyDeadZones = (v)=>
+    {
+        const min=.3, max=.8;
+        const deadZone = (v)=> 
+            v >  min ?  percent( v, min, max) : 
+            v < -min ? -percent(-v, min, max) : 0;
+        return vec2(deadZone(v.x), deadZone(-v.y)).clampLength();
+    }
+
     // update touch gamepad if enabled
     if (touchGamepadEnable && isTouchDevice)
     {
@@ -227,7 +239,16 @@
         {
             // read virtual analog stick
             const sticks = stickData[0] || (stickData[0] = []);
-            sticks[0] = vec2(touchGamepadStick.x, -touchGamepadStick.y); // flip vertical
+            sticks[0] = vec2();
+            if (touchGamepadAnalog)
+                sticks[0] = applyDeadZones(touchGamepadStick);
+            else if (touchGamepadStick.lengthSquared() > .3)
+            {
+                // convert to 8 way dpad
+                sticks[0].x = Math.round(touchGamepadStick.x);
+                sticks[0].y = -Math.round(touchGamepadStick.y);
+                sticks[0] = sticks[0].clampLength();
+            }
 
             // read virtual gamepad buttons
             const data = inputData[1] || (inputData[1] = []);
@@ -239,7 +260,12 @@
         }
     }
 
-    if (!gamepadsEnable || !navigator || !navigator.getGamepads || !document.hasFocus() && !debug)
+    // return if gamepads are disabled or not supported
+    if (!gamepadsEnable || !navigator || !navigator.getGamepads)
+        return;
+
+    // only poll gamepads when focused or in debug mode
+    if (!debug && !document.hasFocus())
         return;
 
     // poll gamepads
@@ -253,14 +279,9 @@
 
         if (gamepad)
         {
-            // read clamp dead zone of analog sticks
-            const deadZone = .3, deadZoneMax = .8, applyDeadZone = (v)=> 
-                v >  deadZone ?  percent( v, deadZone, deadZoneMax) : 
-                v < -deadZone ? -percent(-v, deadZone, deadZoneMax) : 0;
-
             // read analog sticks
             for (let j = 0; j < gamepad.axes.length-1; j+=2)
-                sticks[j>>1] = vec2(applyDeadZone(gamepad.axes[j]), applyDeadZone(-gamepad.axes[j+1])).clampLength();
+                sticks[j>>1] = applyDeadZones(vec2(gamepad.axes[j],gamepad.axes[j+1]));
             
             // read buttons
             for (let j = gamepad.buttons.length; j--;)
@@ -359,7 +380,7 @@
     touchGamepadStick = vec2();
 
     const touchHandler = ontouchstart;
-    ontouchstart = ontouchmove = ontouchend = (e)=> 
+    ontouchstart = ontouchmove = ontouchend = (e)=>
     {
         // clear touch gamepad input
         touchGamepadStick = vec2();
@@ -389,14 +410,7 @@
             if (touchPos.distance(stickCenter) < touchGamepadSize)
             {
                 // virtual analog stick
-                if (touchGamepadAnalog)
-                    touchGamepadStick = touchPos.subtract(stickCenter).scale(2/touchGamepadSize).clampLength();
-                else
-                {
-                    // 8 way dpad
-                    const angle = touchPos.subtract(stickCenter).angle();
-                    touchGamepadStick.setAngle((angle * 4 / PI + 8.5 | 0) * PI / 4);
-                }
+                touchGamepadStick = touchPos.subtract(stickCenter).scale(2/touchGamepadSize).clampLength();
             }
             else if (touchPos.distance(buttonCenter) < touchGamepadSize)
             {
diff --git a/docs/engineMedals.js.html b/docs/engineMedals.js.html
index 20a9321e..753926c5 100644
--- a/docs/engineMedals.js.html
+++ b/docs/engineMedals.js.html
@@ -272,7 +272,7 @@
         }
 
         // build the input object
-        const input = 
+        const input =
         {
             'app_id':     this.app_id,
             'session_id': this.session_id,
diff --git a/docs/engineObject.js.html b/docs/engineObject.js.html
index 39ae6ce1..e8a3a246 100644
--- a/docs/engineObject.js.html
+++ b/docs/engineObject.js.html
@@ -12,7 +12,7 @@
  * - Automatically adds self to object list
  * - Will be updated and rendered each frame
  * - Renders as a sprite from a tilesheet by default
- * - Can have color and addtive color applied
+ * - Can have color and additive color applied
  * - 2D Physics and collision system
  * - Sorted by renderOrder
  * - Objects can have children attached
@@ -291,7 +291,7 @@
     }
     
     /** Destroy this object, destroy it's children, detach it's parent, and mark it for removal */
-    destroy()             
+    destroy()
     { 
         if (this.destroyed)
             return;
diff --git a/docs/engineParticles.js.html b/docs/engineParticles.js.html
index e57a3fbb..cc424413 100644
--- a/docs/engineParticles.js.html
+++ b/docs/engineParticles.js.html
@@ -204,16 +204,17 @@
         
         // build particle
         const particle = new Particle(pos, this.tileInfo, angle, colorStart, colorEnd, particleTime, sizeStart, sizeEnd, this.fadeRate, this.additive,  this.trailScale, this.localSpace && this, this.particleDestroyCallback);
-        particle.velocity     = vec2().setAngle(velocityAngle, speed);
-        particle.fadeRate     = this.fadeRate;
-        particle.damping      = this.damping;
-        particle.angleDamping = this.angleDamping;
-        particle.elasticity   = this.elasticity;
-        particle.friction     = this.friction;
-        particle.gravityScale = this.gravityScale;
-        particle.collideTiles = this.collideTiles;
-        particle.renderOrder  = this.renderOrder;
-        particle.mirror       = !!randInt(2);
+        particle.velocity      = vec2().setAngle(velocityAngle, speed);
+        particle.angleVelocity = angleSpeed;
+        particle.fadeRate      = this.fadeRate;
+        particle.damping       = this.damping;
+        particle.angleDamping  = this.angleDamping;
+        particle.elasticity    = this.elasticity;
+        particle.friction      = this.friction;
+        particle.gravityScale  = this.gravityScale;
+        particle.collideTiles  = this.collideTiles;
+        particle.renderOrder   = this.renderOrder;
+        particle.mirror        = !!randInt(2);
 
         // call particle create callaback
         this.particleCreateCallback && this.particleCreateCallback(particle);
diff --git a/docs/engineSettings.js.html b/docs/engineSettings.js.html
index 10cceb09..35513378 100644
--- a/docs/engineSettings.js.html
+++ b/docs/engineSettings.js.html
@@ -85,7 +85,7 @@
  *  @type {Number}
  *  @default
  *  @memberof Settings */
-let tileFixBleedScale = .3;
+let tileFixBleedScale = .1;
 
 ///////////////////////////////////////////////////////////////////////////////
 // Object settings
@@ -96,7 +96,7 @@
  *  @memberof Settings */
 let enablePhysicsSolver = true;
 
-/** Default object mass for collison calcuations (how heavy objects are)
+/** Default object mass for collision calcuations (how heavy objects are)
  *  @type {Number}
  *  @default
  *  @memberof Settings */
@@ -179,7 +179,7 @@
  *  @memberof Settings */
 let touchGamepadAnalog = true;
 
-/** Size of virutal gamepad for touch devices in pixels
+/** Size of virtual gamepad for touch devices in pixels
  *  @type {Number}
  *  @default
  *  @memberof Settings */
diff --git a/docs/engineTileLayer.js.html b/docs/engineTileLayer.js.html
index 0dc3d2eb..b06df0e4 100644
--- a/docs/engineTileLayer.js.html
+++ b/docs/engineTileLayer.js.html
@@ -3,7 +3,7 @@
     
On this page

engineTileLayer.js

/** 
  * LittleJS Tile Layer System
  * - Caches arrays of tiles to off screen canvas for fast rendering
- * - Unlimted numbers of layers, allocates canvases as needed
+ * - Unlimited numbers of layers, allocates canvases as needed
  * - Interfaces with EngineObject for collision
  * - Collision layer is separate from visible layers
  * - It is recommended to have a visible layer that matches the collision
@@ -55,7 +55,7 @@
 
 /** Check if collision with another object should occur
  *  @param {Vector2}      pos
- *  @param {Vector2}      [size=(1,1)]
+ *  @param {Vector2}      [size=(0,0)]
  *  @param {EngineObject} [object]
  *  @return {Boolean}
  *  @memberof TileCollision */
diff --git a/docs/engineUtilities.js.html b/docs/engineUtilities.js.html
index 74218da2..3f1c2363 100644
--- a/docs/engineUtilities.js.html
+++ b/docs/engineUtilities.js.html
@@ -38,7 +38,7 @@
  *  @memberof Utilities */
 function max(valueA, valueB) { return Math.max(valueA, valueB); }
 
-/** Returns the sign of value passed in (also returns 1 if 0)
+/** Returns the sign of value passed in
  *  @param {Number} value
  *  @return {Number}
  *  @memberof Utilities */
@@ -85,7 +85,7 @@
 function distanceWrap(valueA, valueB, wrapSize=1)
 { const d = (valueA - valueB) % wrapSize; return d*2 % wrapSize - d; }
 
-/** Linearly interpolates between values passed in with wrappping
+/** Linearly interpolates between values passed in with wrapping
  *  @param {Number} percent
  *  @param {Number} valueA
  *  @param {Number} valueB
@@ -102,7 +102,7 @@
  *  @memberof Utilities */
 function distanceAngle(angleA, angleB) { return distanceWrap(angleA, angleB, 2*PI); }
 
-/** Linearly interpolates between the angles passed in with wrappping
+/** Linearly interpolates between the angles passed in with wrapping
  *  @param {Number} percent
  *  @param {Number} angleA
  *  @param {Number} angleB
@@ -632,7 +632,7 @@
 
     /** Returns this color expressed in hsla format
      * @return {Array} */
-    getHSLA()
+    HSLA()
     {
         const r = clamp(this.r);
         const g = clamp(this.g);
diff --git a/docs/engineWebGL.js.html b/docs/engineWebGL.js.html
index f340ebf0..299d3e5b 100644
--- a/docs/engineWebGL.js.html
+++ b/docs/engineWebGL.js.html
@@ -195,8 +195,6 @@
     const filter = canvasPixelated ? gl_NEAREST : gl_LINEAR;
     glContext.texParameteri(gl_TEXTURE_2D, gl_TEXTURE_MIN_FILTER, filter);
     glContext.texParameteri(gl_TEXTURE_2D, gl_TEXTURE_MAG_FILTER, filter);
-    glContext.texParameteri(gl_TEXTURE_2D, gl_TEXTURE_WRAP_S, gl_CLAMP_TO_EDGE);
-    glContext.texParameteri(gl_TEXTURE_2D, gl_TEXTURE_WRAP_T, gl_CLAMP_TO_EDGE);
 
     return texture;
 }
@@ -274,7 +272,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 // post processing - can be enabled to pass other canvases through a final shader
 
-let glPostShader, glPostArrayBuffer, glPostTexture, glPostIncludeOverlay;
+let glPostShader, glPostTexture, glPostIncludeOverlay;
 
 /** Set up a post processing shader
  *  @param {String} shaderCode
@@ -310,7 +308,6 @@
     );
 
     // create buffer and texture
-    glPostArrayBuffer = glContext.createBuffer();
     glPostTexture = glCreateTexture(undefined);
     glPostIncludeOverlay = includeOverlay;
 
@@ -382,10 +379,7 @@
 gl_LINEAR = 9729,
 gl_TEXTURE_MAG_FILTER = 10240,
 gl_TEXTURE_MIN_FILTER = 10241,
-gl_TEXTURE_WRAP_S = 10242,
-gl_TEXTURE_WRAP_T = 10243,
 gl_COLOR_BUFFER_BIT = 16384,
-gl_CLAMP_TO_EDGE = 33071,
 gl_TEXTURE0 = 33984,
 gl_ARRAY_BUFFER = 34962,
 gl_STATIC_DRAW = 35044,
diff --git a/docs/examples/logo.png b/docs/examples/logo.png
index 3db7bca7..23a9938c 100644
Binary files a/docs/examples/logo.png and b/docs/examples/logo.png differ
diff --git a/docs/examples/screenshot.jpg b/docs/examples/screenshot.jpg
index b9c99556..ac94e90d 100644
Binary files a/docs/examples/screenshot.jpg and b/docs/examples/screenshot.jpg differ