Skip to content

Commit

Permalink
build docs
Browse files Browse the repository at this point in the history
  • Loading branch information
KilledByAPixel committed Nov 30, 2024
1 parent c5d65cf commit 6387ea1
Show file tree
Hide file tree
Showing 30 changed files with 121 additions and 94 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/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/Medal.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/Sound.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/SoundWave.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/TileLayer.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/TileLayerData.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.

38 changes: 16 additions & 22 deletions 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.10.1';
const engineVersion = '1.10.6';

/** Frames per second to update
* @type {Number}
Expand Down Expand Up @@ -76,13 +76,6 @@
* @default false
* @memberof Engine */
let paused = false;

/** The root element that engine is attached to
* @type {HTMLElement}
* @default document.body
* @memberof Engine */
let engineRoot;

/** Set if game is paused
* @param {Boolean} isPaused
* @memberof Engine */
Expand All @@ -102,6 +95,8 @@
* @memberof Engine */
function engineAddPlugin(updateFunction, renderFunction)
{
ASSERT(!pluginUpdateList.includes(updateFunction));
ASSERT(!pluginRenderList.includes(renderFunction));
updateFunction && pluginUpdateList.push(updateFunction);
renderFunction && pluginRenderList.push(renderFunction);
}
Expand All @@ -110,12 +105,12 @@
// Main engine functions

/** 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
* @param {Function|function():Promise} gameInit - Called once after the engine starts up
* @param {Function} gameUpdate - Called every frame before objects are updated
* @param {Function} gameUpdatePost - Called after physics and objects are updated, even when paused
* @param {Function} gameRender - Called before objects are rendered, for drawing the background
* @param {Function} gameRenderPost - Called after objects are rendered, useful for drawing UI
* @param {Array} [imageSources=[]] - List of images to load
* @param {HTMLElement} [rootElement] - Root element to attach to, the document body by default
* @memberof Engine */
function engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, imageSources=[], rootElement=document.body)
Expand Down Expand Up @@ -265,8 +260,7 @@

function startEngine()
{
gameInit();
engineUpdate();
new Promise((resolve) => resolve(gameInit())).then(engineUpdate);
}

if (headlessMode)
Expand All @@ -276,7 +270,7 @@
}

// setup html
const styleBody =
const styleRoot =
'margin:0;overflow:hidden;' + // fill the window
'width:100vw;height:100vh;' + // fill the window
'display:flex;' + // use flexbox
Expand All @@ -289,9 +283,8 @@
(!touchInputEnable ? '' : // no touch css setttings
'touch-action:none;' + // prevent mobile pinch to resize
'-webkit-touch-callout:none');// compatibility for ios
engineRoot = rootElement;
engineRoot.style.cssText = styleBody;
engineRoot.appendChild(mainCanvas = document.createElement('canvas'));
rootElement.style.cssText = styleRoot;
rootElement.appendChild(mainCanvas = document.createElement('canvas'));
mainContext = mainCanvas.getContext('2d');

// init stuff and start engine
Expand All @@ -301,7 +294,7 @@
glInit();

// create overlay canvas for hud to appear above gl canvas
engineRoot.appendChild(overlayCanvas = document.createElement('canvas'));
rootElement.appendChild(overlayCanvas = document.createElement('canvas'));
overlayContext = overlayCanvas.getContext('2d');

// set canvas style
Expand Down Expand Up @@ -620,4 +613,5 @@
}

x.restore();
}</code></pre></article></section><footer class="footer" id="PeOAagUepe"><div class="wrapper"><a href="https://github.com/KilledByAPixel/LittleJS">LittleJS - MIT License - Copyright 2021 Frank Force</a></div></footer></div></div></div><div class="search-container" id="PkfLWpAbet" style="display:none"><div class="wrapper" id="iCxFxjkHbP"><button class="icon-button search-close-button" id="VjLlGakifb" aria-label="close search"><svg><use xlink:href="#close-icon"></use></svg></button><div class="search-box-c"><svg><use xlink:href="#search-icon"></use></svg> <input type="text" id="vpcKVYIppa" class="search-input" placeholder="Search..." autofocus></div><div class="search-result-c" id="fWwVHRuDuN"><span class="search-result-c-text">Type anything to view search result</span></div></div></div><div class="mobile-menu-icon-container"><button class="icon-button" id="mobile-menu" data-isopen="false" aria-label="menu"><svg><use xlink:href="#menu-icon"></use></svg></button></div><div id="mobile-sidebar" class="mobile-sidebar-container"><div class="mobile-sidebar-wrapper"><a href="/" class="sidebar-title sidebar-title-anchor">LittleJS - The Tiny JavaScript Game Engine That Can!</a><div class="mobile-nav-links"></div><div class="mobile-sidebar-items-c"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="Color.html">Color</a></div><div class="sidebar-section-children"><a href="EngineObject.html">EngineObject</a></div><div class="sidebar-section-children"><a href="FontImage.html">FontImage</a></div><div class="sidebar-section-children"><a href="Medal.html">Medal</a></div><div class="sidebar-section-children"><a href="Music.html">Music</a></div><div class="sidebar-section-children"><a href="Particle.html">Particle</a></div><div class="sidebar-section-children"><a href="ParticleEmitter.html">ParticleEmitter</a></div><div class="sidebar-section-children"><a href="RandomGenerator.html">RandomGenerator</a></div><div class="sidebar-section-children"><a href="Sound.html">Sound</a></div><div class="sidebar-section-children"><a href="SoundWave.html">SoundWave</a></div><div class="sidebar-section-children"><a href="TextureInfo.html">TextureInfo</a></div><div class="sidebar-section-children"><a href="TileInfo.html">TileInfo</a></div><div class="sidebar-section-children"><a href="TileLayer.html">TileLayer</a></div><div class="sidebar-section-children"><a href="TileLayerData.html">TileLayerData</a></div><div class="sidebar-section-children"><a href="Timer.html">Timer</a></div><div class="sidebar-section-children"><a href="Vector2.html">Vector2</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-namespaces"><div>Namespaces</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="Audio.html">Audio</a></div><div class="sidebar-section-children"><a href="Debug.html">Debug</a></div><div class="sidebar-section-children"><a href="Draw.html">Draw</a></div><div class="sidebar-section-children"><a href="Engine.html">Engine</a></div><div class="sidebar-section-children"><a href="Input.html">Input</a></div><div class="sidebar-section-children"><a href="Medals.html">Medals</a></div><div class="sidebar-section-children"><a href="Random.html">Random</a></div><div class="sidebar-section-children"><a href="Settings.html">Settings</a></div><div class="sidebar-section-children"><a href="TileCollision.html">TileCollision</a></div><div class="sidebar-section-children"><a href="Utilities.html">Utilities</a></div><div class="sidebar-section-children"><a href="WebGL.html">WebGL</a></div></div></div><div class="mobile-navbar-actions"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#light-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div></div></div><script type="text/javascript" src="scripts/core.min.js"></script><script src="scripts/search.min.js" defer="defer"></script><script src="scripts/third-party/fuse.js" defer="defer"></script><script type="text/javascript">var tocbotInstance=tocbot.init({tocSelector:"#eed4d2a0bfd64539bb9df78095dec881",contentSelector:".main-content",headingSelector:"h1, h2, h3",hasInnerContainers:!0,scrollContainer:".main-content",headingsOffset:130,onClick:bringLinkToView})</script></body></html>
}
</code></pre></article></section><footer class="footer" id="PeOAagUepe"><div class="wrapper"><a href="https://github.com/KilledByAPixel/LittleJS">LittleJS - MIT License - Copyright 2021 Frank Force</a></div></footer></div></div></div><div class="search-container" id="PkfLWpAbet" style="display:none"><div class="wrapper" id="iCxFxjkHbP"><button class="icon-button search-close-button" id="VjLlGakifb" aria-label="close search"><svg><use xlink:href="#close-icon"></use></svg></button><div class="search-box-c"><svg><use xlink:href="#search-icon"></use></svg> <input type="text" id="vpcKVYIppa" class="search-input" placeholder="Search..." autofocus></div><div class="search-result-c" id="fWwVHRuDuN"><span class="search-result-c-text">Type anything to view search result</span></div></div></div><div class="mobile-menu-icon-container"><button class="icon-button" id="mobile-menu" data-isopen="false" aria-label="menu"><svg><use xlink:href="#menu-icon"></use></svg></button></div><div id="mobile-sidebar" class="mobile-sidebar-container"><div class="mobile-sidebar-wrapper"><a href="/" class="sidebar-title sidebar-title-anchor">LittleJS - The Tiny JavaScript Game Engine That Can!</a><div class="mobile-nav-links"></div><div class="mobile-sidebar-items-c"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="Color.html">Color</a></div><div class="sidebar-section-children"><a href="EngineObject.html">EngineObject</a></div><div class="sidebar-section-children"><a href="FontImage.html">FontImage</a></div><div class="sidebar-section-children"><a href="Medal.html">Medal</a></div><div class="sidebar-section-children"><a href="Music.html">Music</a></div><div class="sidebar-section-children"><a href="Particle.html">Particle</a></div><div class="sidebar-section-children"><a href="ParticleEmitter.html">ParticleEmitter</a></div><div class="sidebar-section-children"><a href="RandomGenerator.html">RandomGenerator</a></div><div class="sidebar-section-children"><a href="Sound.html">Sound</a></div><div class="sidebar-section-children"><a href="SoundWave.html">SoundWave</a></div><div class="sidebar-section-children"><a href="TextureInfo.html">TextureInfo</a></div><div class="sidebar-section-children"><a href="TileInfo.html">TileInfo</a></div><div class="sidebar-section-children"><a href="TileLayer.html">TileLayer</a></div><div class="sidebar-section-children"><a href="TileLayerData.html">TileLayerData</a></div><div class="sidebar-section-children"><a href="Timer.html">Timer</a></div><div class="sidebar-section-children"><a href="Vector2.html">Vector2</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-namespaces"><div>Namespaces</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="Audio.html">Audio</a></div><div class="sidebar-section-children"><a href="Debug.html">Debug</a></div><div class="sidebar-section-children"><a href="Draw.html">Draw</a></div><div class="sidebar-section-children"><a href="Engine.html">Engine</a></div><div class="sidebar-section-children"><a href="Input.html">Input</a></div><div class="sidebar-section-children"><a href="Medals.html">Medals</a></div><div class="sidebar-section-children"><a href="Random.html">Random</a></div><div class="sidebar-section-children"><a href="Settings.html">Settings</a></div><div class="sidebar-section-children"><a href="TileCollision.html">TileCollision</a></div><div class="sidebar-section-children"><a href="Utilities.html">Utilities</a></div><div class="sidebar-section-children"><a href="WebGL.html">WebGL</a></div></div></div><div class="mobile-navbar-actions"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#light-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div></div></div><script type="text/javascript" src="scripts/core.min.js"></script><script src="scripts/search.min.js" defer="defer"></script><script src="scripts/third-party/fuse.js" defer="defer"></script><script type="text/javascript">var tocbotInstance=tocbot.init({tocSelector:"#eed4d2a0bfd64539bb9df78095dec881",contentSelector:".main-content",headingSelector:"h1, h2, h3",hasInnerContainers:!0,scrollContainer:".main-content",headingsOffset:130,onClick:bringLinkToView})</script></body></html>
20 changes: 7 additions & 13 deletions docs/engineAudio.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/** Audio context used by the engine
* @type {AudioContext}
* @memberof Audio */
let audioContext;
let audioContext = new AudioContext;

/** Master gain node for all audio to pass through
* @type {GainNode}
Expand All @@ -27,14 +27,10 @@
{
if (!soundEnable || headlessMode) return;

// create audio context
audioContext = new AudioContext;

// create and connect gain node
// (createGain is more widely spported then GainNode construtor)
audioGainNode = audioContext.createGain();
audioGainNode.connect(audioContext.destination);
setSoundVolume(soundVolume); // update gain volume
audioGainNode.gain.value = soundVolume; // set starting value
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -69,12 +65,15 @@

/** @property {Number} - How much to randomize frequency each time sound plays */
this.randomness = 0;

/** @property {GainNode} - Gain node for this sound */
this.gainNode = audioContext.createGain();

if (zzfxSound)
{
// generate zzfx sound now for fast playback
const defaultRandomness = .05;
this.randomness = zzfxSound[1] || defaultRandomness;
this.randomness = zzfxSound[1] != undefined ? zzfxSound[1] : defaultRandomness;
zzfxSound[1] = 0; // generate without randomness
this.sampleChannels = [zzfxG(...zzfxSound)];
this.sampleRate = zzfxR;
Expand Down Expand Up @@ -115,18 +114,13 @@

// play the sound
const playbackRate = pitch + pitch * this.randomness*randomnessScale*rand(-1,1);
this.gainNode = audioContext.createGain();
return this.source = playSamples(this.sampleChannels, volume, playbackRate, pan, loop, this.sampleRate, this.gainNode);
}

/** Set the sound volume
* @param {Number} [volume] - How much to scale volume by
*/
setVolume(volume=1)
{
if (this.gainNode)
this.gainNode.gain.value = volume;
}
setVolume(volume=1) { this.gainNode.gain.value = volume; }

/** Stop the last instance of this sound that was played */
stop()
Expand Down
Loading

0 comments on commit 6387ea1

Please sign in to comment.