Skip to content

Commit

Permalink
rebuild docs
Browse files Browse the repository at this point in the history
  • Loading branch information
KilledByAPixel committed Jul 26, 2024
1 parent 1701c47 commit be57362
Show file tree
Hide file tree
Showing 32 changed files with 266 additions and 164 deletions.
2 changes: 1 addition & 1 deletion docs/Audio.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Color.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Debug.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Draw.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Engine.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/EngineObject.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/FontImage.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Input.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Music.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Particle.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/ParticleEmitter.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Random.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/TileCollision.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/TileInfo.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/TileLayer.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Timer.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Utilities.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Vector2.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/WebGL.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/data/search.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/engine.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @type {String}
* @default
* @memberof Engine */
const engineVersion = '1.9.0';
const engineVersion = '1.9.2';

/** Frames per second to update objects
* @type {Number}
Expand Down
14 changes: 4 additions & 10 deletions docs/engineAudio.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,19 @@
this.randomness = randomness;

if (!soundEnable) return;
if (!soundDecoderContext)
soundDecoderContext = new AudioContext;

fetch(filename)
.then(response => response.arrayBuffer())
.then(arrayBuffer => soundDecoderContext.decodeAudioData(arrayBuffer))
.then(arrayBuffer => audioContext.decodeAudioData(arrayBuffer))
.then(audioBuffer =>
{
this.sampleChannels = [];
for (let i = audioBuffer.numberOfChannels; i--;)
this.sampleChannels[i] = audioBuffer.getChannelData(i);
this.sampleChannels[i] = Array.from(audioBuffer.getChannelData(i));
this.sampleRate = audioBuffer.sampleRate;
});
}
}
let soundDecoderContext; // audio context used only to decode audio files

/**
* Music Object - Stores a zzfx music track for later use
Expand Down Expand Up @@ -277,8 +274,9 @@
///////////////////////////////////////////////////////////////////////////////

/** Audio context used by the engine
* @type {AudioContext}
* @memberof Audio */
let audioContext;
let audioContext = new AudioContext;

/** Play cached audio samples with given settings
* @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
Expand All @@ -293,10 +291,6 @@
{
if (!soundEnable) return;

// create audio context if needed
if (!audioContext)
audioContext = new AudioContext;

// prevent sounds from building up if they can't be played
if (audioContext.state != 'running')
{
Expand Down
8 changes: 6 additions & 2 deletions docs/engineDebug.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@

/** Asserts if the experssion is false, does not do anything in release builds
* @param {Boolean} assert
* @param {Object} output
* @param {Object} [output]
* @memberof Debug */
function ASSERT(assert, output) { enableAsserts && console.assert(assert, output); }
function ASSERT(assert, output)
{
if (enableAsserts)
output ? console.assert(assert, output) : console.assert(assert);
}

/** Draw a debug rectangle in world space
* @param {Vector2} pos
Expand Down
54 changes: 27 additions & 27 deletions docs/engineDraw.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
* 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
* @param {(Number|Vector2)} [pos=Vector2()] - Top left corner of tile in pixels or index
* @param {(Number|Vector2)} [pos=(0,0)] - Top left corner of tile in pixels or index
* @param {(Number|Vector2)} [size=tileSizeDefault] - Size of tile in pixels
* @param {Number} [textureIndex] - Texture index to use
* @return {TileInfo}
Expand Down Expand Up @@ -106,7 +106,7 @@
class TileInfo
{
/** Create a tile info object
* @param {Vector2} [pos=Vector2()] - Top left corner of tile in pixels
* @param {Vector2} [pos=(0,0)] - Top left corner of tile in pixels
* @param {Vector2} [size=tileSizeDefault] - Size of tile in pixels
* @param {Number} [textureIndex] - Texture index to use
*/
Expand Down Expand Up @@ -183,16 +183,16 @@
}

/** 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=Vector2(1,1)] - Size of the tile in world space
* @param {TileInfo}[tileInfo] - Tile info to use, untextured if undefined
* @param {Color} [color=Color()] - Color to modulate with
* @param {Number} [angle] - Angle to rotate by
* @param {Boolean} [mirror] - If true image is flipped along the Y axis
* @param {Color} [additiveColor=Color(0,0,0,0)] - Additive color to be applied
* @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
* @param {Boolean} [screenSpace] - If true the pos and size are in screen space
* @param {CanvasRenderingContext2D} [context] - Canvas 2D context to draw to
* @param {Vector2} pos - Center of the tile in world space
* @param {Vector2} [size=(1,1)] - Size of the tile in world space
* @param {TileInfo}[tileInfo] - Tile info to use, untextured if undefined
* @param {Color} [color=(1,1,1,1)] - Color to modulate with
* @param {Number} [angle] - Angle to rotate by
* @param {Boolean} [mirror] - If true image is flipped along the Y axis
* @param {Color} [additiveColor=(0,0,0,0)] - Additive color to be applied
* @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
* @param {Boolean} [screenSpace=false] - If true the pos and size are in screen space
* @param {CanvasRenderingContext2D} [context] - Canvas 2D context to draw to
* @memberof Draw */
function drawTile(pos, size=vec2(1), tileInfo, color=new Color,
angle=0, mirror, additiveColor=new Color(0,0,0,0), useWebGL=glEnable, screenSpace, context)
Expand Down Expand Up @@ -260,11 +260,11 @@

/** Draw colored rect centered on pos
* @param {Vector2} pos
* @param {Vector2} [size=Vector2(1,1)]
* @param {Color} [color=Color()]
* @param {Vector2} [size=(1,1)]
* @param {Color} [color=(1,1,1,1)]
* @param {Number} [angle]
* @param {Boolean} [useWebGL=glEnable]
* @param {Boolean} [screenSpace]
* @param {Boolean} [screenSpace=false]
* @param {CanvasRenderingContext2D} [context]
* @memberof Draw */
function drawRect(pos, size, color, angle, useWebGL, screenSpace, context)
Expand All @@ -274,8 +274,8 @@

/** Draw colored polygon using passed in points
* @param {Array} points - Array of Vector2 points
* @param {Color} [color=Color()]
* @param {Boolean} [screenSpace]
* @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)
Expand All @@ -291,9 +291,9 @@
* @param {Vector2} posA
* @param {Vector2} posB
* @param {Number} [thickness]
* @param {Color} [color=Color()]
* @param {Color} [color=(1,1,1,1)]
* @param {Boolean} [useWebGL=glEnable]
* @param {Boolean} [screenSpace]
* @param {Boolean} [screenSpace=false]
* @param {CanvasRenderingContext2D} [context]
* @memberof Draw */
function drawLine(posA, posB, thickness=.1, color, useWebGL, screenSpace, context)
Expand All @@ -309,7 +309,7 @@
* @param {Number} angle
* @param {Boolean} mirror
* @param {Function} drawFunction
* @param {Boolean} [screenSpace]
* @param {Boolean} [screenSpace=false]
* @param {CanvasRenderingContext2D} [context=mainContext]
* @memberof Draw */
function drawCanvas2D(pos, size, angle, mirror, drawFunction, screenSpace, context=mainContext)
Expand Down Expand Up @@ -351,9 +351,9 @@
* @param {String} text
* @param {Vector2} pos
* @param {Number} [size]
* @param {Color} [color=Color()]
* @param {Color} [color=(1,1,1,1)]
* @param {Number} [lineWidth]
* @param {Color} [lineColor=Color(0,0,0)]
* @param {Color} [lineColor=(0,0,0,1)]
* @param {CanvasTextAlign} [textAlign='center']
* @param {String} [font=fontDefault]
* @param {CanvasRenderingContext2D} [context=overlayContext]
Expand All @@ -368,9 +368,9 @@
* @param {String} text
* @param {Vector2} pos
* @param {Number} [size]
* @param {Color} [color=Color()]
* @param {Color} [color=(1,1,1,1)]
* @param {Number} [lineWidth]
* @param {Color} [lineColor=Color(0,0,0)]
* @param {Color} [lineColor=(0,0,0,1)]
* @param {CanvasTextAlign} [textAlign]
* @param {String} [font=fontDefault]
* @param {CanvasRenderingContext2D} [context=overlayContext]
Expand Down Expand Up @@ -413,9 +413,9 @@
class FontImage
{
/** Create an image font
* @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
* @param {Vector2} [tileSize=Vector2(8)] - Size of the font source tiles
* @param {Vector2} [paddingSize=Vector2(0,1)] - How much extra space to add between characters
* @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
* @param {Vector2} [tileSize=(8,8)] - Size of the font source tiles
* @param {Vector2} [paddingSize=(0,1)] - How much extra space to add between characters
* @param {CanvasRenderingContext2D} [context=overlayContext] - context to draw to
*/
constructor(image, tileSize=vec2(8), paddingSize=vec2(0,1), context=overlayContext)
Expand Down
14 changes: 7 additions & 7 deletions docs/engineInput.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@
///////////////////////////////////////////////////////////////////////////////
// Mouse event handlers

onmousedown = (e)=> {isUsingGamepad = false; inputData[0][e.button] = 3; window.onmousemove(e); e.button && e.preventDefault();}
onmousedown = (e)=> {isUsingGamepad = false; inputData[0][e.button] = 3; mousePosScreen = mouseToScreen(e); e.button && e.preventDefault();}
onmouseup = (e)=> inputData[0][e.button] = inputData[0][e.button] & 2 | 4;
onmousemove = (e)=> mousePosScreen = mouseToScreen(e);
onwheel = (e)=> e.ctrlKey || (mouseWheel = sign(e.deltaY));
onwheel = (e)=> mouseWheel = e.ctrlKey ? 0 : sign(e.deltaY);
oncontextmenu = (e)=> false; // prevent right click menu

// convert a mouse or touch event position to screen space
Expand Down Expand Up @@ -290,7 +290,7 @@
///////////////////////////////////////////////////////////////////////////////

/** Pulse the vibration hardware if it exists
* @param {Number} [pattern] - a single value in miliseconds or vibration interval array
* @param {Number|Array} [pattern] - single value in ms or vibration interval array
* @memberof Input */
function vibrate(pattern=100)
{ vibrateEnable && navigator && navigator.vibrate && navigator.vibrate(pattern); }
Expand All @@ -316,9 +316,9 @@
// handle all touch events the same way
ontouchstart = ontouchmove = ontouchend = (e)=>
{
// fix stalled audio on mobile
if (soundEnable)
audioContext ? audioContext.resume() : zzfx(0);
// fix stalled audio requiring user interaction
if (soundEnable && audioContext && audioContext.state != 'running')
zzfx(0);

// check if touching and pass to mouse events
const touching = e.touches.length;
Expand Down Expand Up @@ -464,7 +464,7 @@
const rightCenter = vec2(mainCanvasSize.x-touchGamepadSize, mainCanvasSize.y-touchGamepadSize);
for (let i=4; i--;)
{
const pos = rightCenter.add(vec2().setAngle(i*PI/2, touchGamepadSize/2));
const pos = rightCenter.add(vec2().setDirection(i, touchGamepadSize/2));
overlayContext.fillStyle = touchGamepadButtons[i] ? '#fff' : '#000';
overlayContext.beginPath();
overlayContext.arc(pos.x, pos.y, touchGamepadSize/4, 0,9);
Expand Down
4 changes: 2 additions & 2 deletions docs/engineMedals.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
// draw containing rect and clip to that region
context.save();
context.beginPath();
context.fillStyle = rgb(.9,.9,.9).toString();
context.strokeStyle = rgb(0,0,0).toString();
context.fillStyle = new Color(.9,.9,.9).toString();
context.strokeStyle = new Color(0,0,0).toString();
context.lineWidth = 3;
context.rect(x, y, width, medalDisplaySize.y);
context.fill();
Expand Down
14 changes: 7 additions & 7 deletions docs/engineObject.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
class EngineObject
{
/** Create an engine object and adds it to the list of objects
* @param {Vector2} [pos=Vector2()] - World space position of the object
* @param {Vector2} [size=Vector2(1,1)] - World space size of the object
* @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
* @param {Number} [angle] - Angle the object is rotated by
* @param {Color} [color=Color()] - Color to apply to tile when rendered
* @param {Number} [renderOrder] - Objects sorted by renderOrder before being rendered
* @param {Vector2} [pos=(0,0)] - World space position of the object
* @param {Vector2} [size=(1,1)] - World space size of the object
* @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
* @param {Number} [angle] - Angle the object is rotated by
* @param {Color} [color=(1,1,1,1)] - Color to apply to tile when rendered
* @param {Number} [renderOrder] - Objects sorted by renderOrder before being rendered
*/
constructor(pos=vec2(), size=vec2(1), tileInfo, angle=0, color, renderOrder=0)
{
Expand Down Expand Up @@ -339,7 +339,7 @@

/** Attaches a child to this with a given local transform
* @param {EngineObject} child
* @param {Vector2} [localPos=Vector2()]
* @param {Vector2} [localPos=(0,0)]
* @param {Number} [localAngle] */
addChild(child, localPos=vec2(), localAngle=0)
{
Expand Down
18 changes: 9 additions & 9 deletions docs/engineParticles.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
* @example
* // create a particle emitter
* let pos = vec2(2,3);
* let particleEmiter = new ParticleEmitter
* let particleEmitter = new ParticleEmitter
* (
* pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
* tile(0, 16), // tileInfo
* new Color(1,1,1), new Color(0,0,0), // colorStartA, colorStartB
* new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
* pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
* tile(0, 16), // tileInfo
* rgb(1,1,1), rgb(0,0,0), // colorStartA, colorStartB
* rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB
* 2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
* .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
* .5, 1 // randomness, collide, additive, randomColorLinear, renderOrder
Expand All @@ -33,10 +33,10 @@
* @param {Number} [emitRate] - How many particles per second to spawn, does not emit if 0
* @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
* @param {TileInfo} [tileInfo] - Tile info to render particles (undefined is untextured)
* @param {Color} [colorStartA=Color()] - Color at start of life 1, randomized between start colors
* @param {Color} [colorStartB=Color()] - Color at start of life 2, randomized between start colors
* @param {Color} [colorEndA=Color(1,1,1,0)] - Color at end of life 1, randomized between end colors
* @param {Color} [colorEndB=Color(1,1,1,0)] - Color at end of life 2, randomized between end colors
* @param {Color} [colorStartA=(1,1,1,1)] - Color at start of life 1, randomized between start colors
* @param {Color} [colorStartB=(1,1,1,1)] - Color at start of life 2, randomized between start colors
* @param {Color} [colorEndA=(1,1,1,0)] - Color at end of life 1, randomized between end colors
* @param {Color} [colorEndB=(1,1,1,0)] - Color at end of life 2, randomized between end colors
* @param {Number} [particleTime] - How long particles live
* @param {Number} [sizeStart] - How big are particles at start
* @param {Number} [sizeEnd] - How big are particles at end
Expand Down
Loading

0 comments on commit be57362

Please sign in to comment.