littlejsengine 1.3.0 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/build.bat +1 -1
- package/docs/Audio.html +2268 -0
- package/docs/Color.html +3376 -0
- package/docs/Debug.html +2933 -0
- package/docs/Draw.html +4480 -0
- package/docs/EngineObject.html +4734 -0
- package/docs/FontImage.html +1055 -0
- package/docs/Input.html +2806 -0
- package/docs/Medal.html +1007 -0
- package/docs/Medals.html +628 -0
- package/docs/Music.html +584 -0
- package/docs/Newgrounds.html +1399 -0
- package/docs/Particle.html +4825 -0
- package/docs/ParticleEmitter.html +8099 -0
- package/docs/Random.html +1774 -0
- package/docs/Settings.html +3140 -0
- package/docs/Sound.html +1249 -0
- package/docs/TileCollision.html +1409 -0
- package/docs/TileLayer.html +7310 -0
- package/docs/TileLayerData.html +1052 -0
- package/docs/Timer.html +1295 -0
- package/docs/Utilities.html +3278 -0
- package/docs/Vector2.html +4266 -0
- package/docs/WebGL.html +2307 -0
- package/docs/engine.js.html +443 -0
- package/docs/engineAudio.js.html +627 -0
- package/docs/engineDebug.js.html +554 -0
- package/docs/engineDraw.js.html +539 -0
- package/docs/engineInput.js.html +571 -0
- package/docs/engineMedals.js.html +460 -0
- package/docs/engineObject.js.html +533 -0
- package/docs/engineParticles.js.html +443 -0
- package/docs/engineSettings.js.html +381 -0
- package/docs/engineTileLayer.js.html +503 -0
- package/docs/engineUtilities.js.html +700 -0
- package/docs/engineWebGL.js.html +511 -0
- package/docs/fonts/MavenPro-Regular.ttf +0 -0
- package/docs/fonts/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Muli-Black.ttf +0 -0
- package/docs/fonts/OFL-hind.txt +93 -0
- package/docs/fonts/OFL-montserrat.txt +93 -0
- package/docs/global.html +1771 -0
- package/docs/index.css +6 -0
- package/docs/index.html +267 -0
- package/docs/scripts/fix-code-block.js +53 -0
- package/docs/scripts/fix-navbar.js +25 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/misc.js +217 -0
- package/docs/scripts/resize.js +85 -0
- package/docs/scripts/search.js +83 -0
- package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/scripts/third-party/fuse.js +9 -0
- package/docs/scripts/third-party/lang-css.js +2 -0
- package/docs/scripts/third-party/prettify.js +28 -0
- package/docs/static/favicon.png +0 -0
- package/docs/static/index.css +4 -0
- package/docs/styles/clean-jsdoc-theme-base.css +393 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +324 -0
- package/docs/styles/clean-jsdoc-theme-light.css +319 -0
- package/docs/styles/reset.css +346 -0
- package/docs/styles/third-party/ionicons.min.css +11 -0
- package/docs/styles/third-party/prettify-jsdoc.css +111 -0
- package/docs/styles/third-party/prettify-tomorrow.css +5 -0
- package/engine/engine.all.js +72 -33
- package/engine/engine.all.min.js +1 -1
- package/engine/engine.all.release.js +72 -33
- package/engine/engine.js +1 -1
- package/engine/engineAudio.js +5 -7
- package/engine/engineBuild.bat +0 -1
- package/engine/engineDraw.js +4 -3
- package/engine/engineInput.js +5 -1
- package/engine/engineMedals.js +1 -1
- package/engine/engineObject.js +19 -16
- package/engine/engineParticles.js +1 -1
- package/engine/engineSettings.js +5 -0
- package/engine/engineUtilities.js +30 -2
- package/engine/engineWebGL.js +1 -1
- package/engine/index.d.ts +15 -5
- package/examples/breakout/index.html +3 -3
- package/examples/particles/index.html +62 -62
- package/examples/platformer/index.html +5 -5
- package/examples/puzzle/game.js +3 -1
- package/examples/puzzle/index.html +2 -2
- package/examples/stress/index.html +1 -1
- package/game.js +3 -14
- package/index.html +13 -13
- package/package.json +1 -1
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
|
|
8
|
+
<!-- Adding favicon -->
|
|
9
|
+
|
|
10
|
+
<link rel="icon" href="./static/favicon.png" />
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<!-- Adding meta -->
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
<!-- Adding external script-->
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
<!-- Adding external style-->
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<!-- Adding scripts-->
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
<!-- Adding style-->
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<!-- Adding overlay script-->
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
<!-- Adding overlay style-->
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
<title>
|
|
36
|
+
engineAudio.js
|
|
37
|
+
</title>
|
|
38
|
+
|
|
39
|
+
<!--[if lt IE 9]>
|
|
40
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
41
|
+
<![endif]-->
|
|
42
|
+
<link type="text/css" rel="stylesheet" href="styles/third-party/ionicons.min.css">
|
|
43
|
+
<link type="text/css" rel="stylesheet" href="styles/third-party/prettify-tomorrow.css">
|
|
44
|
+
<link type="text/css" rel="stylesheet" href="styles/reset.css">
|
|
45
|
+
<link type="text/css" rel="stylesheet" href="styles/clean-jsdoc-theme-base.css">
|
|
46
|
+
<link type="text/css" rel="stylesheet" href="styles/clean-jsdoc-theme-dark.css">
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
.prettyprint code {font-family:monospace}
|
|
50
|
+
</style>
|
|
51
|
+
|
|
52
|
+
<svg aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
53
|
+
style="display:none">
|
|
54
|
+
<defs>
|
|
55
|
+
<symbol id="copy-icon" viewbox="0 0 488.3 488.3">
|
|
56
|
+
<g>
|
|
57
|
+
<path
|
|
58
|
+
d="M314.25,85.4h-227c-21.3,0-38.6,17.3-38.6,38.6v325.7c0,21.3,17.3,38.6,38.6,38.6h227c21.3,0,38.6-17.3,38.6-38.6V124 C352.75,102.7,335.45,85.4,314.25,85.4z M325.75,449.6c0,6.4-5.2,11.6-11.6,11.6h-227c-6.4,0-11.6-5.2-11.6-11.6V124 c0-6.4,5.2-11.6,11.6-11.6h227c6.4,0,11.6,5.2,11.6,11.6V449.6z" />
|
|
59
|
+
<path
|
|
60
|
+
d="M401.05,0h-227c-21.3,0-38.6,17.3-38.6,38.6c0,7.5,6,13.5,13.5,13.5s13.5-6,13.5-13.5c0-6.4,5.2-11.6,11.6-11.6h227 c6.4,0,11.6,5.2,11.6,11.6v325.7c0,6.4-5.2,11.6-11.6,11.6c-7.5,0-13.5,6-13.5,13.5s6,13.5,13.5,13.5c21.3,0,38.6-17.3,38.6-38.6 V38.6C439.65,17.3,422.35,0,401.05,0z" />
|
|
61
|
+
</g>
|
|
62
|
+
</symbol>
|
|
63
|
+
<symbol id='search-icon' viewBox="0 0 512 512">
|
|
64
|
+
<g>
|
|
65
|
+
<g>
|
|
66
|
+
<path
|
|
67
|
+
d="M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z" />
|
|
68
|
+
</g>
|
|
69
|
+
</g>
|
|
70
|
+
<g>
|
|
71
|
+
<g>
|
|
72
|
+
<path
|
|
73
|
+
d="M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z" />
|
|
74
|
+
</g>
|
|
75
|
+
</g>
|
|
76
|
+
</symbol>
|
|
77
|
+
<symbol id="down-icon" viewBox="0 0 16 16">
|
|
78
|
+
<path
|
|
79
|
+
fill-rule="evenodd"
|
|
80
|
+
clip-rule="evenodd"
|
|
81
|
+
d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"
|
|
82
|
+
>
|
|
83
|
+
</path>
|
|
84
|
+
</symbol>
|
|
85
|
+
</defs>
|
|
86
|
+
</svg>
|
|
87
|
+
</head>
|
|
88
|
+
|
|
89
|
+
<body>
|
|
90
|
+
|
|
91
|
+
<nav class="navbar" id="navbar">
|
|
92
|
+
<div class="navbar-heading" id="navbar-heading"><a href="index.html"><h2 class="navbar-heading-text">LittleJS - The Tiny JavaScript Game Engine That Can!</h2></a></div><div class="search-box" id="search-box"><div class="search-box-input-container"><input class="search-box-input" type="text" placeholder="Search..." id="search-box-input" /><svg class="search-icon" alt="search-icon"><use xlink:href="#search-icon"></use></svg></div><div class="search-item-container" id="search-item-container"><ul class="search-item-ul" id="search-item-ul"></ul></div></div><div class="sidebar-main-content" id="sidebar-main-content"><div class="accordion collapsed" id="3563688" > <h3 class="accordion-heading">Classes<svg><use xlink:href="#down-icon"></use></svg></h3><ul class="accordion-content"><li class="accordion collapsed child" id=7746959><div class="accordion-heading child"><a href="Color.html">Color</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Color.html#add">add</a></li><li data-type='method'><a href="Color.html#clamp">clamp</a></li><li data-type='method'><a href="Color.html#copy">copy</a></li><li data-type='method'><a href="Color.html#divide">divide</a></li><li data-type='method'><a href="Color.html#getHSLA">getHSLA</a></li><li data-type='method'><a href="Color.html#hex">hex</a></li><li data-type='method'><a href="Color.html#lerp">lerp</a></li><li data-type='method'><a href="Color.html#multiply">multiply</a></li><li data-type='method'><a href="Color.html#mutate">mutate</a></li><li data-type='method'><a href="Color.html#rgbaInt">rgbaInt</a></li><li data-type='method'><a href="Color.html#scale">scale</a></li><li data-type='method'><a href="Color.html#setHex">setHex</a></li><li data-type='method'><a href="Color.html#setHSLA">setHSLA</a></li><li data-type='method'><a href="Color.html#subtract">subtract</a></li><li data-type='method'><a href="Color.html#toString">toString</a></li></ul></li><li class="accordion collapsed child" id=6307330><div class="accordion-heading child"><a href="EngineObject.html">EngineObject</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="EngineObject.html#addChild">addChild</a></li><li data-type='method'><a href="EngineObject.html#applyAcceleration">applyAcceleration</a></li><li data-type='method'><a href="EngineObject.html#applyForce">applyForce</a></li><li data-type='method'><a href="EngineObject.html#collideWithObject">collideWithObject</a></li><li data-type='method'><a href="EngineObject.html#collideWithTile">collideWithTile</a></li><li data-type='method'><a href="EngineObject.html#collideWithTileRaycast">collideWithTileRaycast</a></li><li data-type='method'><a href="EngineObject.html#destroy">destroy</a></li><li data-type='method'><a href="EngineObject.html#getAliveTime">getAliveTime</a></li><li data-type='method'><a href="EngineObject.html#getMirrorSign">getMirrorSign</a></li><li data-type='method'><a href="EngineObject.html#removeChild">removeChild</a></li><li data-type='method'><a href="EngineObject.html#render">render</a></li><li data-type='method'><a href="EngineObject.html#setCollision">setCollision</a></li><li data-type='method'><a href="EngineObject.html#update">update</a></li></ul></li><li class="accordion collapsed child" id=8508237><div class="accordion-heading child"><a href="FontImage.html">FontImage</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="FontImage.html#drawText">drawText</a></li><li data-type='method'><a href="FontImage.html#drawTextScreen">drawTextScreen</a></li></ul></li><li class="accordion collapsed child" id=2613323><div class="accordion-heading child"><a href="Medal.html">Medal</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Medal.html#render">render</a></li><li data-type='method'><a href="Medal.html#renderIcon">renderIcon</a></li><li data-type='method'><a href="Medal.html#unlock">unlock</a></li></ul></li><li class="accordion collapsed child" id=5931143><div class="accordion-heading child"><a href="Music.html">Music</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Music.html#play">play</a></li></ul></li><li class="accordion collapsed child" id=7102537><div class="accordion-heading child"><a href="Newgrounds.html">Newgrounds</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Newgrounds.html#call">call</a></li><li data-type='method'><a href="Newgrounds.html#getScores">getScores</a></li><li data-type='method'><a href="Newgrounds.html#logView">logView</a></li><li data-type='method'><a href="Newgrounds.html#postScore">postScore</a></li><li data-type='method'><a href="Newgrounds.html#unlockMedal">unlockMedal</a></li></ul></li><li class="accordion collapsed child" id=4104404><div class="accordion-heading child"><a href="Particle.html">Particle</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Particle.html#addChild">addChild</a></li><li data-type='method'><a href="Particle.html#applyAcceleration">applyAcceleration</a></li><li data-type='method'><a href="Particle.html#applyForce">applyForce</a></li><li data-type='method'><a href="Particle.html#collideWithObject">collideWithObject</a></li><li data-type='method'><a href="Particle.html#collideWithTile">collideWithTile</a></li><li data-type='method'><a href="Particle.html#collideWithTileRaycast">collideWithTileRaycast</a></li><li data-type='method'><a href="Particle.html#destroy">destroy</a></li><li data-type='method'><a href="Particle.html#getAliveTime">getAliveTime</a></li><li data-type='method'><a href="Particle.html#getMirrorSign">getMirrorSign</a></li><li data-type='method'><a href="Particle.html#removeChild">removeChild</a></li><li data-type='method'><a href="Particle.html#render">render</a></li><li data-type='method'><a href="Particle.html#setCollision">setCollision</a></li><li data-type='method'><a href="Particle.html#update">update</a></li></ul></li><li class="accordion collapsed child" id=8166593><div class="accordion-heading child"><a href="ParticleEmitter.html">ParticleEmitter</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="ParticleEmitter.html#addChild">addChild</a></li><li data-type='method'><a href="ParticleEmitter.html#applyAcceleration">applyAcceleration</a></li><li data-type='method'><a href="ParticleEmitter.html#applyForce">applyForce</a></li><li data-type='method'><a href="ParticleEmitter.html#collideWithObject">collideWithObject</a></li><li data-type='method'><a href="ParticleEmitter.html#collideWithTile">collideWithTile</a></li><li data-type='method'><a href="ParticleEmitter.html#collideWithTileRaycast">collideWithTileRaycast</a></li><li data-type='method'><a href="ParticleEmitter.html#destroy">destroy</a></li><li data-type='method'><a href="ParticleEmitter.html#emitParticle">emitParticle</a></li><li data-type='method'><a href="ParticleEmitter.html#getAliveTime">getAliveTime</a></li><li data-type='method'><a href="ParticleEmitter.html#getMirrorSign">getMirrorSign</a></li><li data-type='method'><a href="ParticleEmitter.html#removeChild">removeChild</a></li><li data-type='method'><a href="ParticleEmitter.html#render">render</a></li><li data-type='method'><a href="ParticleEmitter.html#setCollision">setCollision</a></li><li data-type='method'><a href="ParticleEmitter.html#update">update</a></li></ul></li><li class="accordion collapsed child" id=1946205><div class="accordion-heading child"><a href="Sound.html">Sound</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Sound.html#play">play</a></li><li data-type='method'><a href="Sound.html#playNote">playNote</a></li></ul></li><li class="accordion collapsed child" id=2790513><div class="accordion-heading child"><a href="TileLayer.html">TileLayer</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="TileLayer.html#addChild">addChild</a></li><li data-type='method'><a href="TileLayer.html#applyAcceleration">applyAcceleration</a></li><li data-type='method'><a href="TileLayer.html#applyForce">applyForce</a></li><li data-type='method'><a href="TileLayer.html#collideWithObject">collideWithObject</a></li><li data-type='method'><a href="TileLayer.html#collideWithTile">collideWithTile</a></li><li data-type='method'><a href="TileLayer.html#collideWithTileRaycast">collideWithTileRaycast</a></li><li data-type='method'><a href="TileLayer.html#destroy">destroy</a></li><li data-type='method'><a href="TileLayer.html#drawAllTileData">drawAllTileData</a></li><li data-type='method'><a href="TileLayer.html#drawCanvas2D">drawCanvas2D</a></li><li data-type='method'><a href="TileLayer.html#drawRect">drawRect</a></li><li data-type='method'><a href="TileLayer.html#drawTile">drawTile</a></li><li data-type='method'><a href="TileLayer.html#drawTileData">drawTileData</a></li><li data-type='method'><a href="TileLayer.html#getAliveTime">getAliveTime</a></li><li data-type='method'><a href="TileLayer.html#getData">getData</a></li><li data-type='method'><a href="TileLayer.html#getMirrorSign">getMirrorSign</a></li><li data-type='method'><a href="TileLayer.html#redraw">redraw</a></li><li data-type='method'><a href="TileLayer.html#redrawEnd">redrawEnd</a></li><li data-type='method'><a href="TileLayer.html#redrawStart">redrawStart</a></li><li data-type='method'><a href="TileLayer.html#removeChild">removeChild</a></li><li data-type='method'><a href="TileLayer.html#render">render</a></li><li data-type='method'><a href="TileLayer.html#setCollision">setCollision</a></li><li data-type='method'><a href="TileLayer.html#setData">setData</a></li><li data-type='method'><a href="TileLayer.html#update">update</a></li></ul></li><li class="accordion collapsed child" id=8451372><div class="accordion-heading child"><a href="TileLayerData.html">TileLayerData</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="TileLayerData.html#clear">clear</a></li></ul></li><li class="accordion collapsed child" id=1385312><div class="accordion-heading child"><a href="Timer.html">Timer</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Timer.html#active">active</a></li><li data-type='method'><a href="Timer.html#elapsed">elapsed</a></li><li data-type='method'><a href="Timer.html#get">get</a></li><li data-type='method'><a href="Timer.html#getPercent">getPercent</a></li><li data-type='method'><a href="Timer.html#isSet">isSet</a></li><li data-type='method'><a href="Timer.html#set">set</a></li><li data-type='method'><a href="Timer.html#toString">toString</a></li><li data-type='method'><a href="Timer.html#unset">unset</a></li></ul></li><li class="accordion collapsed child" id=5094252><div class="accordion-heading child"><a href="Vector2.html">Vector2</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Vector2.html#add">add</a></li><li data-type='method'><a href="Vector2.html#angle">angle</a></li><li data-type='method'><a href="Vector2.html#area">area</a></li><li data-type='method'><a href="Vector2.html#arrayCheck">arrayCheck</a></li><li data-type='method'><a href="Vector2.html#clampLength">clampLength</a></li><li data-type='method'><a href="Vector2.html#copy">copy</a></li><li data-type='method'><a href="Vector2.html#cross">cross</a></li><li data-type='method'><a href="Vector2.html#direction">direction</a></li><li data-type='method'><a href="Vector2.html#distance">distance</a></li><li data-type='method'><a href="Vector2.html#distanceSquared">distanceSquared</a></li><li data-type='method'><a href="Vector2.html#divide">divide</a></li><li data-type='method'><a href="Vector2.html#dot">dot</a></li><li data-type='method'><a href="Vector2.html#floor">floor</a></li><li data-type='method'><a href="Vector2.html#invert">invert</a></li><li data-type='method'><a href="Vector2.html#length">length</a></li><li data-type='method'><a href="Vector2.html#lengthSquared">lengthSquared</a></li><li data-type='method'><a href="Vector2.html#lerp">lerp</a></li><li data-type='method'><a href="Vector2.html#multiply">multiply</a></li><li data-type='method'><a href="Vector2.html#normalize">normalize</a></li><li data-type='method'><a href="Vector2.html#rotate">rotate</a></li><li data-type='method'><a href="Vector2.html#scale">scale</a></li><li data-type='method'><a href="Vector2.html#setAngle">setAngle</a></li><li data-type='method'><a href="Vector2.html#subtract">subtract</a></li><li data-type='method'><a href="Vector2.html#toString">toString</a></li></ul></li></ul> </div><div class="accordion collapsed" id="9985463" > <h3 class="accordion-heading">Namespaces<svg><use xlink:href="#down-icon"></use></svg></h3><ul class="accordion-content"><li class="accordion collapsed child" id=1451135><div class="accordion-heading child"><a href="Debug.html">Debug</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Debug.html#.debugAABB">debugAABB</a></li><li data-type='method'><a href="Debug.html#.debugCircle">debugCircle</a></li><li data-type='method'><a href="Debug.html#.debugClear">debugClear</a></li><li data-type='method'><a href="Debug.html#.debugLine">debugLine</a></li><li data-type='method'><a href="Debug.html#.debugPoint">debugPoint</a></li><li data-type='method'><a href="Debug.html#.debugRect">debugRect</a></li><li data-type='method'><a href="Debug.html#.debugSaveCanvas">debugSaveCanvas</a></li><li data-type='method'><a href="Debug.html#.debugText">debugText</a></li></ul></li><li class="accordion collapsed child" id=3748274><div class="accordion-heading child"><a href="Draw.html">Draw</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Draw.html#.drawCanvas2D">drawCanvas2D</a></li><li data-type='method'><a href="Draw.html#.drawLine">drawLine</a></li><li data-type='method'><a href="Draw.html#.drawRect">drawRect</a></li><li data-type='method'><a href="Draw.html#.drawRectScreenSpace">drawRectScreenSpace</a></li><li data-type='method'><a href="Draw.html#.drawText">drawText</a></li><li data-type='method'><a href="Draw.html#.drawTextScreen">drawTextScreen</a></li><li data-type='method'><a href="Draw.html#.drawTile">drawTile</a></li><li data-type='method'><a href="Draw.html#.drawTileScreenSpace">drawTileScreenSpace</a></li><li data-type='method'><a href="Draw.html#.isFullscreen">isFullscreen</a></li><li data-type='method'><a href="Draw.html#.screenToWorld">screenToWorld</a></li><li data-type='method'><a href="Draw.html#.setBlendMode">setBlendMode</a></li><li data-type='method'><a href="Draw.html#.toggleFullscreen">toggleFullscreen</a></li><li data-type='method'><a href="Draw.html#.worldToScreen">worldToScreen</a></li></ul></li><li class="accordion collapsed child" id=1641359><div class="accordion-heading child"><a href="Input.html">Input</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Input.html#.clearInput">clearInput</a></li><li data-type='method'><a href="Input.html#.gamepadIsDown">gamepadIsDown</a></li><li data-type='method'><a href="Input.html#.gamepadStick">gamepadStick</a></li><li data-type='method'><a href="Input.html#.gamepadWasPressed">gamepadWasPressed</a></li><li data-type='method'><a href="Input.html#.gamepadWasReleased">gamepadWasReleased</a></li><li data-type='method'><a href="Input.html#.keyIsDown">keyIsDown</a></li><li data-type='method'><a href="Input.html#.keyWasPressed">keyWasPressed</a></li><li data-type='method'><a href="Input.html#.keyWasReleased">keyWasReleased</a></li><li data-type='method'><a href="Input.html#.vibrate">vibrate</a></li><li data-type='method'><a href="Input.html#.vibrateStop">vibrateStop</a></li></ul></li><li class="accordion collapsed child" id=9832293><div class="accordion-heading child"><a href="Medals.html">Medals</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Medals.html#.medalsInit">medalsInit</a></li></ul></li><li class="accordion collapsed child" id=219095><div class="accordion-heading child"><a href="Random.html">Random</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Random.html#.rand">rand</a></li><li data-type='method'><a href="Random.html#.randColor">randColor</a></li><li data-type='method'><a href="Random.html#.randInCircle">randInCircle</a></li><li data-type='method'><a href="Random.html#.randInt">randInt</a></li><li data-type='method'><a href="Random.html#.randSeeded">randSeeded</a></li><li data-type='method'><a href="Random.html#.randSign">randSign</a></li><li data-type='method'><a href="Random.html#.randVector">randVector</a></li></ul></li><li class="accordion-list" id=""><a href="Settings.html">Settings</a></li><li class="accordion collapsed child" id=2884620><div class="accordion-heading child"><a href="TileCollision.html">TileCollision</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="TileCollision.html#.getTileCollisionData">getTileCollisionData</a></li><li data-type='method'><a href="TileCollision.html#.initTileCollision">initTileCollision</a></li><li data-type='method'><a href="TileCollision.html#.setTileCollisionData">setTileCollisionData</a></li><li data-type='method'><a href="TileCollision.html#.tileCollisionRaycast">tileCollisionRaycast</a></li><li data-type='method'><a href="TileCollision.html#.tileCollisionTest">tileCollisionTest</a></li></ul></li><li class="accordion collapsed child" id=9516194><div class="accordion-heading child"><a href="Utilities.html">Utilities</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Utilities.html#.abs">abs</a></li><li data-type='method'><a href="Utilities.html#.clamp">clamp</a></li><li data-type='method'><a href="Utilities.html#.formatTime">formatTime</a></li><li data-type='method'><a href="Utilities.html#.isOverlapping">isOverlapping</a></li><li data-type='method'><a href="Utilities.html#.lerp">lerp</a></li><li data-type='method'><a href="Utilities.html#.max">max</a></li><li data-type='method'><a href="Utilities.html#.min">min</a></li><li data-type='method'><a href="Utilities.html#.mod">mod</a></li><li data-type='method'><a href="Utilities.html#.nearestPowerOfTwo">nearestPowerOfTwo</a></li><li data-type='method'><a href="Utilities.html#.percent">percent</a></li><li data-type='method'><a href="Utilities.html#.sign">sign</a></li><li data-type='method'><a href="Utilities.html#.smoothStep">smoothStep</a></li><li data-type='method'><a href="Utilities.html#.vec2">vec2</a></li><li data-type='method'><a href="Utilities.html#.wave">wave</a></li></ul></li><li class="accordion collapsed child" id=228864><div class="accordion-heading child"><a href="WebGL.html">WebGL</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="WebGL.html#.glCompileShader">glCompileShader</a></li><li data-type='method'><a href="WebGL.html#.glCopyToContext">glCopyToContext</a></li><li data-type='method'><a href="WebGL.html#.glCreateBuffer">glCreateBuffer</a></li><li data-type='method'><a href="WebGL.html#.glCreateProgram">glCreateProgram</a></li><li data-type='method'><a href="WebGL.html#.glCreateTexture">glCreateTexture</a></li><li data-type='method'><a href="WebGL.html#.glDraw">glDraw</a></li><li data-type='method'><a href="WebGL.html#.glFlush">glFlush</a></li><li data-type='method'><a href="WebGL.html#.glSetBlendMode">glSetBlendMode</a></li><li data-type='method'><a href="WebGL.html#.glSetTexture">glSetTexture</a></li></ul></li></ul> </div><div class="accordion collapsed" id="4889956" > <h3 class="accordion-heading">Global<svg><use xlink:href="#down-icon"></use></svg></h3><ul class="accordion-content"><li class="accordion-list" id=""><a href="global.html#engineFontImage">engineFontImage</a></li><li class="accordion-list" id=""><a href="global.html#engineInit">engineInit</a></li><li class="accordion-list" id=""><a href="global.html#engineName">engineName</a></li><li class="accordion-list" id=""><a href="global.html#engineObjects">engineObjects</a></li><li class="accordion-list" id=""><a href="global.html#engineObjectsCallback">engineObjectsCallback</a></li><li class="accordion-list" id=""><a href="global.html#engineObjectsCollide">engineObjectsCollide</a></li><li class="accordion-list" id=""><a href="global.html#engineObjectsDestroy">engineObjectsDestroy</a></li><li class="accordion-list" id=""><a href="global.html#engineObjectsUpdate">engineObjectsUpdate</a></li><li class="accordion-list" id=""><a href="global.html#engineVersion">engineVersion</a></li><li class="accordion-list" id=""><a href="global.html#frame">frame</a></li><li class="accordion-list" id=""><a href="global.html#frameRate">frameRate</a></li><li class="accordion-list" id=""><a href="global.html#paused">paused</a></li><li class="accordion-list" id=""><a href="global.html#time">time</a></li><li class="accordion-list" id=""><a href="global.html#timeDelta">timeDelta</a></li><li class="accordion-list" id=""><a href="global.html#timeReal">timeReal</a></li></ul> </div></div>
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
</nav>
|
|
96
|
+
<div class="navbar-ham" id="navbar-ham">
|
|
97
|
+
<div>
|
|
98
|
+
<div class="first"></div>
|
|
99
|
+
<div class="second"></div>
|
|
100
|
+
<div class="third"></div>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<div id="main" class="main-content">
|
|
105
|
+
|
|
106
|
+
<h1 id='page-title' class="page-title">
|
|
107
|
+
engineAudio.js
|
|
108
|
+
</h1>
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
<section>
|
|
117
|
+
<article>
|
|
118
|
+
<pre class="prettyprint source linenums"><code>/**
|
|
119
|
+
* LittleJS Audio System
|
|
120
|
+
* <br> - <a href=https://killedbyapixel.github.io/ZzFX/>ZzFX Sound Effects</a>
|
|
121
|
+
* <br> - <a href=https://keithclark.github.io/ZzFXM/>ZzFXM Music</a>
|
|
122
|
+
* <br> - Caches sounds and music for fast playback
|
|
123
|
+
* <br> - Can attenuate and apply stereo panning to sounds
|
|
124
|
+
* <br> - Ability to play mp3, ogg, and wave files
|
|
125
|
+
* <br> - Speech synthesis wrapper functions
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
'use strict';
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Sound Object - Stores a zzfx sound for later use and can be played positionally
|
|
132
|
+
* <br>
|
|
133
|
+
* <br><b><a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a></b>
|
|
134
|
+
* @example
|
|
135
|
+
* // create a sound
|
|
136
|
+
* const sound_example = new Sound([.5,.5]);
|
|
137
|
+
*
|
|
138
|
+
* // play the sound
|
|
139
|
+
* sound_example.play();
|
|
140
|
+
*/
|
|
141
|
+
class Sound
|
|
142
|
+
{
|
|
143
|
+
/** Create a sound object and cache the zzfx samples for later use
|
|
144
|
+
* @param {Array} zzfxSound - Array of zzfx parameters, ex. [.5,.5]
|
|
145
|
+
* @param {Number} [range=soundDefaultRange] - World space max range of sound, will not play if camera is farther away
|
|
146
|
+
* @param {Number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering off
|
|
147
|
+
*/
|
|
148
|
+
constructor(zzfxSound, range=soundDefaultRange, taper=soundDefaultTaper)
|
|
149
|
+
{
|
|
150
|
+
if (!soundEnable) return;
|
|
151
|
+
|
|
152
|
+
/** @property {Number} - World space max range of sound, will not play if camera is farther away */
|
|
153
|
+
this.range = range;
|
|
154
|
+
|
|
155
|
+
/** @property {Number} - At what percentage of range should it start tapering off */
|
|
156
|
+
this.taper = taper;
|
|
157
|
+
|
|
158
|
+
// get randomness from sound parameters
|
|
159
|
+
this.randomness = zzfxSound[1] || 0;
|
|
160
|
+
zzfxSound[1] = 0;
|
|
161
|
+
|
|
162
|
+
// generate sound now for fast playback
|
|
163
|
+
this.cachedSamples = zzfxG(...zzfxSound);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Play the sound
|
|
167
|
+
* @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
|
|
168
|
+
* @param {Number} [volume=1] - How much to scale volume by (in addition to range fade)
|
|
169
|
+
* @param {Number} [pitch=1] - How much to scale pitch by (also adjusted by this.randomness)
|
|
170
|
+
* @param {Number} [randomnessScale=1] - How much to scale randomness
|
|
171
|
+
* @return {AudioBufferSourceNode} - The audio, can be used to stop sound later
|
|
172
|
+
*/
|
|
173
|
+
play(pos, volume=1, pitch=1, randomnessScale=1)
|
|
174
|
+
{
|
|
175
|
+
if (!soundEnable) return;
|
|
176
|
+
|
|
177
|
+
let pan = 0;
|
|
178
|
+
if (pos)
|
|
179
|
+
{
|
|
180
|
+
const range = this.range;
|
|
181
|
+
if (range)
|
|
182
|
+
{
|
|
183
|
+
// apply range based fade
|
|
184
|
+
const lengthSquared = cameraPos.distanceSquared(pos);
|
|
185
|
+
if (lengthSquared > range*range)
|
|
186
|
+
return; // out of range
|
|
187
|
+
|
|
188
|
+
// attenuate volume by distance
|
|
189
|
+
volume *= percent(lengthSquared**.5, range, range*this.taper);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// get pan from screen space coords
|
|
193
|
+
pan = worldToScreen(pos).x * 2/mainCanvas.width - 1;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// play the sound
|
|
197
|
+
const playbackRate = pitch + pitch * this.randomness*randomnessScale*rand(-1,1);
|
|
198
|
+
return playSamples([this.cachedSamples], volume, playbackRate, pan);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Play the sound as a note with a semitone offset
|
|
202
|
+
* @param {Number} semitoneOffset - How many semitones to offset pitch
|
|
203
|
+
* @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
|
|
204
|
+
* @param {Number} [volume=1] - How much to scale volume by (in addition to range fade)
|
|
205
|
+
* @return {AudioBufferSourceNode} - The audio, can be used to stop sound later
|
|
206
|
+
*/
|
|
207
|
+
playNote(semitoneOffset, pos, volume=1)
|
|
208
|
+
{
|
|
209
|
+
if (!soundEnable) return;
|
|
210
|
+
|
|
211
|
+
return this.play(pos, volume, 2**(semitoneOffset/12), 0);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Music Object - Stores a zzfx music track for later use
|
|
217
|
+
* <br>
|
|
218
|
+
* <br><b><a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a></b>
|
|
219
|
+
* @example
|
|
220
|
+
* // create some music
|
|
221
|
+
* const music_example = new Music(
|
|
222
|
+
* [
|
|
223
|
+
* [ // instruments
|
|
224
|
+
* [,0,400] // simple note
|
|
225
|
+
* ],
|
|
226
|
+
* [ // patterns
|
|
227
|
+
* [ // pattern 1
|
|
228
|
+
* [ // channel 0
|
|
229
|
+
* 0, -1, // instrument 0, left speaker
|
|
230
|
+
* 1, 0, 9, 1 // channel notes
|
|
231
|
+
* ],
|
|
232
|
+
* [ // channel 1
|
|
233
|
+
* 0, 1, // instrument 1, right speaker
|
|
234
|
+
* 0, 12, 17, -1 // channel notes
|
|
235
|
+
* ]
|
|
236
|
+
* ],
|
|
237
|
+
* ],
|
|
238
|
+
* [0, 0, 0, 0], // sequence, play pattern 0 four times
|
|
239
|
+
* 90 // BPM
|
|
240
|
+
* ]);
|
|
241
|
+
*
|
|
242
|
+
* // play the music
|
|
243
|
+
* music_example.play();
|
|
244
|
+
*/
|
|
245
|
+
class Music
|
|
246
|
+
{
|
|
247
|
+
/** Create a music object and cache the zzfx music samples for later use
|
|
248
|
+
* @param {Array} zzfxMusic - Array of zzfx music parameters
|
|
249
|
+
*/
|
|
250
|
+
constructor(zzfxMusic)
|
|
251
|
+
{
|
|
252
|
+
if (!soundEnable) return;
|
|
253
|
+
|
|
254
|
+
this.cachedSamples = zzfxM(...zzfxMusic);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Play the music
|
|
258
|
+
* @param {Number} [volume=1] - How much to scale volume by
|
|
259
|
+
* @param {Boolean} [loop=1] - True if the music should loop when it reaches the end
|
|
260
|
+
* @return {AudioBufferSourceNode} - The audio node, can be used to stop sound later
|
|
261
|
+
*/
|
|
262
|
+
play(volume = 1, loop = 1)
|
|
263
|
+
{
|
|
264
|
+
if (!soundEnable) return;
|
|
265
|
+
|
|
266
|
+
return playSamples(this.cachedSamples, volume, 1, 0, loop);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** Play an mp3 or wav audio from a local file or url
|
|
271
|
+
* @param {String} url - Location of sound file to play
|
|
272
|
+
* @param {Number} [volume=1] - How much to scale volume by
|
|
273
|
+
* @param {Boolean} [loop=1] - True if the music should loop when it reaches the end
|
|
274
|
+
* @return {HTMLAudioElement} - The audio element for this sound
|
|
275
|
+
* @memberof Audio */
|
|
276
|
+
function playAudioFile(url, volume=1, loop=1)
|
|
277
|
+
{
|
|
278
|
+
if (!soundEnable) return;
|
|
279
|
+
|
|
280
|
+
const audio = new Audio(url);
|
|
281
|
+
audio.volume = soundVolume * volume;
|
|
282
|
+
audio.loop = loop;
|
|
283
|
+
audio.play();
|
|
284
|
+
return audio;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** Speak text with passed in settings
|
|
288
|
+
* @param {String} text - The text to speak
|
|
289
|
+
* @param {String} [language] - The language/accent to use (examples: en, it, ru, ja, zh)
|
|
290
|
+
* @param {Number} [volume=1] - How much to scale volume by
|
|
291
|
+
* @param {Number} [rate=1] - How quickly to speak
|
|
292
|
+
* @param {Number} [pitch=1] - How much to change the pitch by
|
|
293
|
+
* @return {SpeechSynthesisUtterance} - The utterance that was spoken
|
|
294
|
+
* @memberof Audio */
|
|
295
|
+
function speak(text, language='', volume=1, rate=1, pitch=1)
|
|
296
|
+
{
|
|
297
|
+
if (!soundEnable || !speechSynthesis) return;
|
|
298
|
+
|
|
299
|
+
// common languages (not supported by all browsers)
|
|
300
|
+
// en - english, it - italian, fr - french, de - german, es - spanish
|
|
301
|
+
// ja - japanese, ru - russian, zh - chinese, hi - hindi, ko - korean
|
|
302
|
+
|
|
303
|
+
// build utterance and speak
|
|
304
|
+
const utterance = new SpeechSynthesisUtterance(text);
|
|
305
|
+
utterance.lang = language;
|
|
306
|
+
utterance.volume = 2*volume*soundVolume;
|
|
307
|
+
utterance.rate = rate;
|
|
308
|
+
utterance.pitch = pitch;
|
|
309
|
+
speechSynthesis.speak(utterance);
|
|
310
|
+
return utterance;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** Stop all queued speech
|
|
314
|
+
* @memberof Audio */
|
|
315
|
+
const speakStop = ()=> speechSynthesis && speechSynthesis.cancel();
|
|
316
|
+
|
|
317
|
+
/** Get frequency of a note on a musical scale
|
|
318
|
+
* @param {Number} semitoneOffset - How many semitones away from the root note
|
|
319
|
+
* @param {Number} [rootNoteFrequency=220] - Frequency at semitone offset 0
|
|
320
|
+
* @return {Number} - The frequency of the note
|
|
321
|
+
* @memberof Audio */
|
|
322
|
+
const getNoteFrequency = (semitoneOffset, rootFrequency=220)=> rootFrequency * 2**(semitoneOffset/12);
|
|
323
|
+
|
|
324
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
325
|
+
|
|
326
|
+
/** Audio context used by the engine
|
|
327
|
+
* @memberof Audio */
|
|
328
|
+
let audioContext;
|
|
329
|
+
|
|
330
|
+
/** Play cached audio samples with given settings
|
|
331
|
+
* @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
|
|
332
|
+
* @param {Number} [volume=1] - How much to scale volume by
|
|
333
|
+
* @param {Number} [rate=1] - The playback rate to use
|
|
334
|
+
* @param {Number} [pan=0] - How much to apply stereo panning
|
|
335
|
+
* @param {Boolean} [loop=0] - True if the sound should loop when it reaches the end
|
|
336
|
+
* @return {AudioBufferSourceNode} - The audio node of the sound played
|
|
337
|
+
* @memberof Audio */
|
|
338
|
+
function playSamples(sampleChannels, volume=1, rate=1, pan=0, loop=0)
|
|
339
|
+
{
|
|
340
|
+
if (!soundEnable) return;
|
|
341
|
+
|
|
342
|
+
// create audio context
|
|
343
|
+
if (!audioContext)
|
|
344
|
+
audioContext = new (window.AudioContext||webkitAudioContext);
|
|
345
|
+
|
|
346
|
+
// fix stalled audio
|
|
347
|
+
audioContext.resume();
|
|
348
|
+
|
|
349
|
+
// prevent sounds from building up if they can't be played
|
|
350
|
+
if (audioContext.state != 'running')
|
|
351
|
+
return;
|
|
352
|
+
|
|
353
|
+
// create buffer and source
|
|
354
|
+
const buffer = audioContext.createBuffer(sampleChannels.length, sampleChannels[0].length, zzfxR),
|
|
355
|
+
source = audioContext.createBufferSource();
|
|
356
|
+
|
|
357
|
+
// copy samples to buffer and setup source
|
|
358
|
+
sampleChannels.forEach((c,i)=> buffer.getChannelData(i).set(c));
|
|
359
|
+
source.buffer = buffer;
|
|
360
|
+
source.playbackRate.value = rate;
|
|
361
|
+
source.loop = loop;
|
|
362
|
+
|
|
363
|
+
// create and connect gain node (createGain is more widley spported then GainNode construtor)
|
|
364
|
+
const gainNode = audioContext.createGain();
|
|
365
|
+
gainNode.gain.value = soundVolume*volume;
|
|
366
|
+
gainNode.connect(audioContext.destination);
|
|
367
|
+
|
|
368
|
+
// connect source to gain
|
|
369
|
+
(
|
|
370
|
+
window.StereoPannerNode ? // create pan node if possible
|
|
371
|
+
source.connect(new StereoPannerNode(audioContext, {'pan':clamp(pan, -1, 1)}))
|
|
372
|
+
: source
|
|
373
|
+
)
|
|
374
|
+
.connect(gainNode);
|
|
375
|
+
|
|
376
|
+
// play and return sound
|
|
377
|
+
source.start();
|
|
378
|
+
return source;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
382
|
+
// ZzFXMicro - Zuper Zmall Zound Zynth - v1.1.8 by Frank Force
|
|
383
|
+
|
|
384
|
+
/** Generate and play a ZzFX sound
|
|
385
|
+
* <br>
|
|
386
|
+
* <br><b><a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a></b>
|
|
387
|
+
* @param {Array} zzfxSound - Array of ZzFX parameters, ex. [.5,.5]
|
|
388
|
+
* @return {Array} - Array of audio samples
|
|
389
|
+
* @memberof Audio */
|
|
390
|
+
const zzfx = (...zzfxSound) => playSamples([zzfxG(...zzfxSound)]);
|
|
391
|
+
|
|
392
|
+
/** Sample rate used for all ZzFX sounds
|
|
393
|
+
* @default 44100
|
|
394
|
+
* @memberof Audio */
|
|
395
|
+
const zzfxR = 44100;
|
|
396
|
+
|
|
397
|
+
/** Generate samples for a ZzFX sound
|
|
398
|
+
* @memberof Audio */
|
|
399
|
+
function zzfxG
|
|
400
|
+
(
|
|
401
|
+
// parameters
|
|
402
|
+
volume = 1, randomness = .05, frequency = 220, attack = 0, sustain = 0,
|
|
403
|
+
release = .1, shape = 0, shapeCurve = 1, slide = 0, deltaSlide = 0,
|
|
404
|
+
pitchJump = 0, pitchJumpTime = 0, repeatTime = 0, noise = 0, modulation = 0,
|
|
405
|
+
bitCrush = 0, delay = 0, sustainVolume = 1, decay = 0, tremolo = 0
|
|
406
|
+
)
|
|
407
|
+
{
|
|
408
|
+
// init parameters
|
|
409
|
+
let PI2 = PI*2, startSlide = slide *= 500 * PI2 / zzfxR / zzfxR, b=[],
|
|
410
|
+
startFrequency = frequency *= (1 + randomness*rand(-1,1)) * PI2 / zzfxR,
|
|
411
|
+
t=0, tm=0, i=0, j=1, r=0, c=0, s=0, f, length;
|
|
412
|
+
|
|
413
|
+
// scale by sample rate
|
|
414
|
+
attack = attack * zzfxR + 9; // minimum attack to prevent pop
|
|
415
|
+
decay *= zzfxR;
|
|
416
|
+
sustain *= zzfxR;
|
|
417
|
+
release *= zzfxR;
|
|
418
|
+
delay *= zzfxR;
|
|
419
|
+
deltaSlide *= 500 * PI2 / zzfxR**3;
|
|
420
|
+
modulation *= PI2 / zzfxR;
|
|
421
|
+
pitchJump *= PI2 / zzfxR;
|
|
422
|
+
pitchJumpTime *= zzfxR;
|
|
423
|
+
repeatTime = repeatTime * zzfxR | 0;
|
|
424
|
+
|
|
425
|
+
// generate waveform
|
|
426
|
+
for (length = attack + decay + sustain + release + delay | 0;
|
|
427
|
+
i < length; b[i++] = s)
|
|
428
|
+
{
|
|
429
|
+
if (!(++c%(bitCrush*100|0))) // bit crush
|
|
430
|
+
{
|
|
431
|
+
s = shape? shape>1? shape>2? shape>3? // wave shape
|
|
432
|
+
Math.sin((t%PI2)**3) : // 4 noise
|
|
433
|
+
max(min(Math.tan(t),1),-1): // 3 tan
|
|
434
|
+
1-(2*t/PI2%2+2)%2: // 2 saw
|
|
435
|
+
1-4*abs(Math.round(t/PI2)-t/PI2): // 1 triangle
|
|
436
|
+
Math.sin(t); // 0 sin
|
|
437
|
+
|
|
438
|
+
s = (repeatTime ?
|
|
439
|
+
1 - tremolo + tremolo*Math.sin(PI2*i/repeatTime) // tremolo
|
|
440
|
+
: 1) *
|
|
441
|
+
sign(s)*(abs(s)**shapeCurve) * // curve 0=square, 2=pointy
|
|
442
|
+
volume * soundVolume * ( // envelope
|
|
443
|
+
i < attack ? i/attack : // attack
|
|
444
|
+
i < attack + decay ? // decay
|
|
445
|
+
1-((i-attack)/decay)*(1-sustainVolume) : // decay falloff
|
|
446
|
+
i < attack + decay + sustain ? // sustain
|
|
447
|
+
sustainVolume : // sustain volume
|
|
448
|
+
i < length - delay ? // release
|
|
449
|
+
(length - i - delay)/release * // release falloff
|
|
450
|
+
sustainVolume : // release volume
|
|
451
|
+
0); // post release
|
|
452
|
+
|
|
453
|
+
s = delay ? s/2 + (delay > i ? 0 : // delay
|
|
454
|
+
(i<length-delay? 1 : (length-i)/delay) * // release delay
|
|
455
|
+
b[i-delay|0]/2) : s; // sample delay
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
f = (frequency += slide += deltaSlide) * // frequency
|
|
459
|
+
Math.cos(modulation*tm++); // modulation
|
|
460
|
+
t += f - f*noise*(1 - (Math.sin(i)+1)*1e9%2); // noise
|
|
461
|
+
|
|
462
|
+
if (j && ++j > pitchJumpTime) // pitch jump
|
|
463
|
+
{
|
|
464
|
+
frequency += pitchJump; // apply pitch jump
|
|
465
|
+
startFrequency += pitchJump; // also apply to start
|
|
466
|
+
j = 0; // reset pitch jump time
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (repeatTime && !(++r % repeatTime)) // repeat
|
|
470
|
+
{
|
|
471
|
+
frequency = startFrequency; // reset frequency
|
|
472
|
+
slide = startSlide; // reset slide
|
|
473
|
+
j = j || 1; // reset pitch jump time
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return b;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
481
|
+
// ZzFX Music Renderer v2.0.3 by Keith Clark and Frank Force
|
|
482
|
+
|
|
483
|
+
/** Generate samples for a ZzFM song with given parameters
|
|
484
|
+
* @param {Array} instruments - Array of ZzFX sound paramaters
|
|
485
|
+
* @param {Array} patterns - Array of pattern data
|
|
486
|
+
* @param {Array} sequence - Array of pattern indexes
|
|
487
|
+
* @param {Number} [BPM=125] - Playback speed of the song in BPM
|
|
488
|
+
* @returns {Array} - Left and right channel sample data
|
|
489
|
+
* @memberof Audio */
|
|
490
|
+
function zzfxM(instruments, patterns, sequence, BPM = 125)
|
|
491
|
+
{
|
|
492
|
+
let instrumentParameters;
|
|
493
|
+
let i;
|
|
494
|
+
let j;
|
|
495
|
+
let k;
|
|
496
|
+
let note;
|
|
497
|
+
let sample;
|
|
498
|
+
let patternChannel;
|
|
499
|
+
let notFirstBeat;
|
|
500
|
+
let stop;
|
|
501
|
+
let instrument;
|
|
502
|
+
let attenuation;
|
|
503
|
+
let outSampleOffset;
|
|
504
|
+
let isSequenceEnd;
|
|
505
|
+
let sampleOffset = 0;
|
|
506
|
+
let nextSampleOffset;
|
|
507
|
+
let sampleBuffer = [];
|
|
508
|
+
let leftChannelBuffer = [];
|
|
509
|
+
let rightChannelBuffer = [];
|
|
510
|
+
let channelIndex = 0;
|
|
511
|
+
let panning = 0;
|
|
512
|
+
let hasMore = 1;
|
|
513
|
+
let sampleCache = {};
|
|
514
|
+
let beatLength = zzfxR / BPM * 60 >> 2;
|
|
515
|
+
|
|
516
|
+
// for each channel in order until there are no more
|
|
517
|
+
for (; hasMore; channelIndex++) {
|
|
518
|
+
|
|
519
|
+
// reset current values
|
|
520
|
+
sampleBuffer = [hasMore = notFirstBeat = outSampleOffset = 0];
|
|
521
|
+
|
|
522
|
+
// for each pattern in sequence
|
|
523
|
+
sequence.forEach((patternIndex, sequenceIndex) => {
|
|
524
|
+
// get pattern for current channel, use empty 1 note pattern if none found
|
|
525
|
+
patternChannel = patterns[patternIndex][channelIndex] || [0, 0, 0];
|
|
526
|
+
|
|
527
|
+
// check if there are more channels
|
|
528
|
+
hasMore |= !!patterns[patternIndex][channelIndex];
|
|
529
|
+
|
|
530
|
+
// get next offset, use the length of first channel
|
|
531
|
+
nextSampleOffset = outSampleOffset + (patterns[patternIndex][0].length - 2 - !notFirstBeat) * beatLength;
|
|
532
|
+
// for each beat in pattern, plus one extra if end of sequence
|
|
533
|
+
isSequenceEnd = sequenceIndex == sequence.length - 1;
|
|
534
|
+
for (i = 2, k = outSampleOffset; i < patternChannel.length + isSequenceEnd; notFirstBeat = ++i) {
|
|
535
|
+
|
|
536
|
+
// <channel-note>
|
|
537
|
+
note = patternChannel[i];
|
|
538
|
+
|
|
539
|
+
// stop if end, different instrument or new note
|
|
540
|
+
stop = i == patternChannel.length + isSequenceEnd - 1 && isSequenceEnd ||
|
|
541
|
+
instrument != (patternChannel[0] || 0) | note | 0;
|
|
542
|
+
|
|
543
|
+
// fill buffer with samples for previous beat, most cpu intensive part
|
|
544
|
+
for (j = 0; j < beatLength && notFirstBeat;
|
|
545
|
+
|
|
546
|
+
// fade off attenuation at end of beat if stopping note, prevents clicking
|
|
547
|
+
j++ > beatLength - 99 && stop ? attenuation += (attenuation < 1) / 99 : 0
|
|
548
|
+
) {
|
|
549
|
+
// copy sample to stereo buffers with panning
|
|
550
|
+
sample = (1 - attenuation) * sampleBuffer[sampleOffset++] / 2 || 0;
|
|
551
|
+
leftChannelBuffer[k] = (leftChannelBuffer[k] || 0) - sample * panning + sample;
|
|
552
|
+
rightChannelBuffer[k] = (rightChannelBuffer[k++] || 0) + sample * panning + sample;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// set up for next note
|
|
556
|
+
if (note) {
|
|
557
|
+
// set attenuation
|
|
558
|
+
attenuation = note % 1;
|
|
559
|
+
panning = patternChannel[1] || 0;
|
|
560
|
+
if (note |= 0) {
|
|
561
|
+
// get cached sample
|
|
562
|
+
sampleBuffer = sampleCache[
|
|
563
|
+
[
|
|
564
|
+
instrument = patternChannel[sampleOffset = 0] || 0,
|
|
565
|
+
note
|
|
566
|
+
]
|
|
567
|
+
] = sampleCache[[instrument, note]] || (
|
|
568
|
+
// add sample to cache
|
|
569
|
+
instrumentParameters = [...instruments[instrument]],
|
|
570
|
+
instrumentParameters[2] *= 2 ** ((note - 12) / 12),
|
|
571
|
+
|
|
572
|
+
// allow negative values to stop notes
|
|
573
|
+
note > 0 ? zzfxG(...instrumentParameters) : []
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// update the sample offset
|
|
580
|
+
outSampleOffset = nextSampleOffset;
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
return [leftChannelBuffer, rightChannelBuffer];
|
|
585
|
+
}</code></pre>
|
|
586
|
+
</article>
|
|
587
|
+
</section>
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
</div>
|
|
593
|
+
|
|
594
|
+
<footer class="footer" id="footer">
|
|
595
|
+
<a href=https://github.com/KilledByAPixel/LittleJS>LittleJS - MIT License - Copyright 2021 Frank Force</a>
|
|
596
|
+
</footer>
|
|
597
|
+
|
|
598
|
+
<script src="scripts/third-party/prettify.js"></script>
|
|
599
|
+
<script src="scripts/third-party/lang-css.js"></script>
|
|
600
|
+
<script type="text/javascript" src="scripts/misc.js"></script>
|
|
601
|
+
|
|
602
|
+
<script>prettyPrint();</script>
|
|
603
|
+
<script src="scripts/linenumber.js"></script>
|
|
604
|
+
<script src="scripts/fix-code-block.js"></script>
|
|
605
|
+
<script src="scripts/fix-navbar.js"></script>
|
|
606
|
+
|
|
607
|
+
<script src="scripts/search.js"></script>
|
|
608
|
+
<script src="scripts/third-party/fuse.js"></script>
|
|
609
|
+
<script>
|
|
610
|
+
var list = [{"title":"Color","link":"<a href=\"Color.html\">Color</a>"},{"title":"Color#add","link":"<a href=\"Color.html#add\">Color ▸ add</a>"},{"title":"Color#clamp","link":"<a href=\"Color.html#clamp\">Color ▸ clamp</a>"},{"title":"Color#copy","link":"<a href=\"Color.html#copy\">Color ▸ copy</a>"},{"title":"Color#divide","link":"<a href=\"Color.html#divide\">Color ▸ divide</a>"},{"title":"Color#getHSLA","link":"<a href=\"Color.html#getHSLA\">Color ▸ getHSLA</a>"},{"title":"Color#hex","link":"<a href=\"Color.html#hex\">Color ▸ hex</a>"},{"title":"Color#lerp","link":"<a href=\"Color.html#lerp\">Color ▸ lerp</a>"},{"title":"Color#multiply","link":"<a href=\"Color.html#multiply\">Color ▸ multiply</a>"},{"title":"Color#mutate","link":"<a href=\"Color.html#mutate\">Color ▸ mutate</a>"},{"title":"Color#rgbaInt","link":"<a href=\"Color.html#rgbaInt\">Color ▸ rgbaInt</a>"},{"title":"Color#scale","link":"<a href=\"Color.html#scale\">Color ▸ scale</a>"},{"title":"Color#setHex","link":"<a href=\"Color.html#setHex\">Color ▸ setHex</a>"},{"title":"Color#setHSLA","link":"<a href=\"Color.html#setHSLA\">Color ▸ setHSLA</a>"},{"title":"Color#subtract","link":"<a href=\"Color.html#subtract\">Color ▸ subtract</a>"},{"title":"Color#toString","link":"<a href=\"Color.html#toString\">Color ▸ toString</a>"},{"title":"EngineObject","link":"<a href=\"EngineObject.html\">EngineObject</a>"},{"title":"EngineObject#addChild","link":"<a href=\"EngineObject.html#addChild\">EngineObject ▸ addChild</a>"},{"title":"EngineObject#applyAcceleration","link":"<a href=\"EngineObject.html#applyAcceleration\">EngineObject ▸ applyAcceleration</a>"},{"title":"EngineObject#applyForce","link":"<a href=\"EngineObject.html#applyForce\">EngineObject ▸ applyForce</a>"},{"title":"EngineObject#collideWithObject","link":"<a href=\"EngineObject.html#collideWithObject\">EngineObject ▸ collideWithObject</a>"},{"title":"EngineObject#collideWithTile","link":"<a href=\"EngineObject.html#collideWithTile\">EngineObject ▸ collideWithTile</a>"},{"title":"EngineObject#collideWithTileRaycast","link":"<a href=\"EngineObject.html#collideWithTileRaycast\">EngineObject ▸ collideWithTileRaycast</a>"},{"title":"EngineObject#destroy","link":"<a href=\"EngineObject.html#destroy\">EngineObject ▸ destroy</a>"},{"title":"EngineObject#getAliveTime","link":"<a href=\"EngineObject.html#getAliveTime\">EngineObject ▸ getAliveTime</a>"},{"title":"EngineObject#getMirrorSign","link":"<a href=\"EngineObject.html#getMirrorSign\">EngineObject ▸ getMirrorSign</a>"},{"title":"EngineObject#removeChild","link":"<a href=\"EngineObject.html#removeChild\">EngineObject ▸ removeChild</a>"},{"title":"EngineObject#render","link":"<a href=\"EngineObject.html#render\">EngineObject ▸ render</a>"},{"title":"EngineObject#setCollision","link":"<a href=\"EngineObject.html#setCollision\">EngineObject ▸ setCollision</a>"},{"title":"EngineObject#update","link":"<a href=\"EngineObject.html#update\">EngineObject ▸ update</a>"},{"title":"FontImage","link":"<a href=\"FontImage.html\">FontImage</a>"},{"title":"FontImage#drawText","link":"<a href=\"FontImage.html#drawText\">FontImage ▸ drawText</a>"},{"title":"FontImage#drawTextScreen","link":"<a href=\"FontImage.html#drawTextScreen\">FontImage ▸ drawTextScreen</a>"},{"title":"Medal","link":"<a href=\"Medal.html\">Medal</a>"},{"title":"Medal#render","link":"<a href=\"Medal.html#render\">Medal ▸ render</a>"},{"title":"Medal#renderIcon","link":"<a href=\"Medal.html#renderIcon\">Medal ▸ renderIcon</a>"},{"title":"Medal#unlock","link":"<a href=\"Medal.html#unlock\">Medal ▸ unlock</a>"},{"title":"Music","link":"<a href=\"Music.html\">Music</a>"},{"title":"Music#play","link":"<a href=\"Music.html#play\">Music ▸ play</a>"},{"title":"Newgrounds","link":"<a href=\"Newgrounds.html\">Newgrounds</a>"},{"title":"Newgrounds#call","link":"<a href=\"Newgrounds.html#call\">Newgrounds ▸ call</a>"},{"title":"Newgrounds#getScores","link":"<a href=\"Newgrounds.html#getScores\">Newgrounds ▸ getScores</a>"},{"title":"Newgrounds#logView","link":"<a href=\"Newgrounds.html#logView\">Newgrounds ▸ logView</a>"},{"title":"Newgrounds#postScore","link":"<a href=\"Newgrounds.html#postScore\">Newgrounds ▸ postScore</a>"},{"title":"Newgrounds#unlockMedal","link":"<a href=\"Newgrounds.html#unlockMedal\">Newgrounds ▸ unlockMedal</a>"},{"title":"Particle","link":"<a href=\"Particle.html\">Particle</a>"},{"title":"Particle#addChild","link":"<a href=\"Particle.html#addChild\">Particle ▸ addChild</a>"},{"title":"Particle#applyAcceleration","link":"<a href=\"Particle.html#applyAcceleration\">Particle ▸ applyAcceleration</a>"},{"title":"Particle#applyForce","link":"<a href=\"Particle.html#applyForce\">Particle ▸ applyForce</a>"},{"title":"Particle#collideWithObject","link":"<a href=\"Particle.html#collideWithObject\">Particle ▸ collideWithObject</a>"},{"title":"Particle#collideWithTile","link":"<a href=\"Particle.html#collideWithTile\">Particle ▸ collideWithTile</a>"},{"title":"Particle#collideWithTileRaycast","link":"<a href=\"Particle.html#collideWithTileRaycast\">Particle ▸ collideWithTileRaycast</a>"},{"title":"Particle#destroy","link":"<a href=\"Particle.html#destroy\">Particle ▸ destroy</a>"},{"title":"Particle#getAliveTime","link":"<a href=\"Particle.html#getAliveTime\">Particle ▸ getAliveTime</a>"},{"title":"Particle#getMirrorSign","link":"<a href=\"Particle.html#getMirrorSign\">Particle ▸ getMirrorSign</a>"},{"title":"Particle#removeChild","link":"<a href=\"Particle.html#removeChild\">Particle ▸ removeChild</a>"},{"title":"Particle#render","link":"<a href=\"Particle.html#render\">Particle ▸ render</a>"},{"title":"Particle#setCollision","link":"<a href=\"Particle.html#setCollision\">Particle ▸ setCollision</a>"},{"title":"Particle#update","link":"<a href=\"Particle.html#update\">Particle ▸ update</a>"},{"title":"ParticleEmitter","link":"<a href=\"ParticleEmitter.html\">ParticleEmitter</a>"},{"title":"ParticleEmitter#addChild","link":"<a href=\"ParticleEmitter.html#addChild\">ParticleEmitter ▸ addChild</a>"},{"title":"ParticleEmitter#applyAcceleration","link":"<a href=\"ParticleEmitter.html#applyAcceleration\">ParticleEmitter ▸ applyAcceleration</a>"},{"title":"ParticleEmitter#applyForce","link":"<a href=\"ParticleEmitter.html#applyForce\">ParticleEmitter ▸ applyForce</a>"},{"title":"ParticleEmitter#collideWithObject","link":"<a href=\"ParticleEmitter.html#collideWithObject\">ParticleEmitter ▸ collideWithObject</a>"},{"title":"ParticleEmitter#collideWithTile","link":"<a href=\"ParticleEmitter.html#collideWithTile\">ParticleEmitter ▸ collideWithTile</a>"},{"title":"ParticleEmitter#collideWithTileRaycast","link":"<a href=\"ParticleEmitter.html#collideWithTileRaycast\">ParticleEmitter ▸ collideWithTileRaycast</a>"},{"title":"ParticleEmitter#destroy","link":"<a href=\"ParticleEmitter.html#destroy\">ParticleEmitter ▸ destroy</a>"},{"title":"ParticleEmitter#emitParticle","link":"<a href=\"ParticleEmitter.html#emitParticle\">ParticleEmitter ▸ emitParticle</a>"},{"title":"ParticleEmitter#getAliveTime","link":"<a href=\"ParticleEmitter.html#getAliveTime\">ParticleEmitter ▸ getAliveTime</a>"},{"title":"ParticleEmitter#getMirrorSign","link":"<a href=\"ParticleEmitter.html#getMirrorSign\">ParticleEmitter ▸ getMirrorSign</a>"},{"title":"ParticleEmitter#removeChild","link":"<a href=\"ParticleEmitter.html#removeChild\">ParticleEmitter ▸ removeChild</a>"},{"title":"ParticleEmitter#render","link":"<a href=\"ParticleEmitter.html#render\">ParticleEmitter ▸ render</a>"},{"title":"ParticleEmitter#setCollision","link":"<a href=\"ParticleEmitter.html#setCollision\">ParticleEmitter ▸ setCollision</a>"},{"title":"ParticleEmitter#update","link":"<a href=\"ParticleEmitter.html#update\">ParticleEmitter ▸ update</a>"},{"title":"Sound","link":"<a href=\"Sound.html\">Sound</a>"},{"title":"Sound#play","link":"<a href=\"Sound.html#play\">Sound ▸ play</a>"},{"title":"Sound#playNote","link":"<a href=\"Sound.html#playNote\">Sound ▸ playNote</a>"},{"title":"TileLayer","link":"<a href=\"TileLayer.html\">TileLayer</a>"},{"title":"TileLayer#addChild","link":"<a href=\"TileLayer.html#addChild\">TileLayer ▸ addChild</a>"},{"title":"TileLayer#applyAcceleration","link":"<a href=\"TileLayer.html#applyAcceleration\">TileLayer ▸ applyAcceleration</a>"},{"title":"TileLayer#applyForce","link":"<a href=\"TileLayer.html#applyForce\">TileLayer ▸ applyForce</a>"},{"title":"TileLayer#collideWithObject","link":"<a href=\"TileLayer.html#collideWithObject\">TileLayer ▸ collideWithObject</a>"},{"title":"TileLayer#collideWithTile","link":"<a href=\"TileLayer.html#collideWithTile\">TileLayer ▸ collideWithTile</a>"},{"title":"TileLayer#collideWithTileRaycast","link":"<a href=\"TileLayer.html#collideWithTileRaycast\">TileLayer ▸ collideWithTileRaycast</a>"},{"title":"TileLayer#destroy","link":"<a href=\"TileLayer.html#destroy\">TileLayer ▸ destroy</a>"},{"title":"TileLayer#drawAllTileData","link":"<a href=\"TileLayer.html#drawAllTileData\">TileLayer ▸ drawAllTileData</a>"},{"title":"TileLayer#drawCanvas2D","link":"<a href=\"TileLayer.html#drawCanvas2D\">TileLayer ▸ drawCanvas2D</a>"},{"title":"TileLayer#drawRect","link":"<a href=\"TileLayer.html#drawRect\">TileLayer ▸ drawRect</a>"},{"title":"TileLayer#drawTile","link":"<a href=\"TileLayer.html#drawTile\">TileLayer ▸ drawTile</a>"},{"title":"TileLayer#drawTileData","link":"<a href=\"TileLayer.html#drawTileData\">TileLayer ▸ drawTileData</a>"},{"title":"TileLayer#getAliveTime","link":"<a href=\"TileLayer.html#getAliveTime\">TileLayer ▸ getAliveTime</a>"},{"title":"TileLayer#getData","link":"<a href=\"TileLayer.html#getData\">TileLayer ▸ getData</a>"},{"title":"TileLayer#getMirrorSign","link":"<a href=\"TileLayer.html#getMirrorSign\">TileLayer ▸ getMirrorSign</a>"},{"title":"TileLayer#redraw","link":"<a href=\"TileLayer.html#redraw\">TileLayer ▸ redraw</a>"},{"title":"TileLayer#redrawEnd","link":"<a href=\"TileLayer.html#redrawEnd\">TileLayer ▸ redrawEnd</a>"},{"title":"TileLayer#redrawStart","link":"<a href=\"TileLayer.html#redrawStart\">TileLayer ▸ redrawStart</a>"},{"title":"TileLayer#removeChild","link":"<a href=\"TileLayer.html#removeChild\">TileLayer ▸ removeChild</a>"},{"title":"TileLayer#render","link":"<a href=\"TileLayer.html#render\">TileLayer ▸ render</a>"},{"title":"TileLayer#setCollision","link":"<a href=\"TileLayer.html#setCollision\">TileLayer ▸ setCollision</a>"},{"title":"TileLayer#setData","link":"<a href=\"TileLayer.html#setData\">TileLayer ▸ setData</a>"},{"title":"TileLayer#update","link":"<a href=\"TileLayer.html#update\">TileLayer ▸ update</a>"},{"title":"TileLayerData","link":"<a href=\"TileLayerData.html\">TileLayerData</a>"},{"title":"TileLayerData#clear","link":"<a href=\"TileLayerData.html#clear\">TileLayerData ▸ clear</a>"},{"title":"Timer","link":"<a href=\"Timer.html\">Timer</a>"},{"title":"Timer#active","link":"<a href=\"Timer.html#active\">Timer ▸ active</a>"},{"title":"Timer#elapsed","link":"<a href=\"Timer.html#elapsed\">Timer ▸ elapsed</a>"},{"title":"Timer#get","link":"<a href=\"Timer.html#get\">Timer ▸ get</a>"},{"title":"Timer#getPercent","link":"<a href=\"Timer.html#getPercent\">Timer ▸ getPercent</a>"},{"title":"Timer#isSet","link":"<a href=\"Timer.html#isSet\">Timer ▸ isSet</a>"},{"title":"Timer#set","link":"<a href=\"Timer.html#set\">Timer ▸ set</a>"},{"title":"Timer#toString","link":"<a href=\"Timer.html#toString\">Timer ▸ toString</a>"},{"title":"Timer#unset","link":"<a href=\"Timer.html#unset\">Timer ▸ unset</a>"},{"title":"Vector2","link":"<a href=\"Vector2.html\">Vector2</a>"},{"title":"Vector2#add","link":"<a href=\"Vector2.html#add\">Vector2 ▸ add</a>"},{"title":"Vector2#angle","link":"<a href=\"Vector2.html#angle\">Vector2 ▸ angle</a>"},{"title":"Vector2#area","link":"<a href=\"Vector2.html#area\">Vector2 ▸ area</a>"},{"title":"Vector2#arrayCheck","link":"<a href=\"Vector2.html#arrayCheck\">Vector2 ▸ arrayCheck</a>"},{"title":"Vector2#clampLength","link":"<a href=\"Vector2.html#clampLength\">Vector2 ▸ clampLength</a>"},{"title":"Vector2#copy","link":"<a href=\"Vector2.html#copy\">Vector2 ▸ copy</a>"},{"title":"Vector2#cross","link":"<a href=\"Vector2.html#cross\">Vector2 ▸ cross</a>"},{"title":"Vector2#direction","link":"<a href=\"Vector2.html#direction\">Vector2 ▸ direction</a>"},{"title":"Vector2#distance","link":"<a href=\"Vector2.html#distance\">Vector2 ▸ distance</a>"},{"title":"Vector2#distanceSquared","link":"<a href=\"Vector2.html#distanceSquared\">Vector2 ▸ distanceSquared</a>"},{"title":"Vector2#divide","link":"<a href=\"Vector2.html#divide\">Vector2 ▸ divide</a>"},{"title":"Vector2#dot","link":"<a href=\"Vector2.html#dot\">Vector2 ▸ dot</a>"},{"title":"Vector2#floor","link":"<a href=\"Vector2.html#floor\">Vector2 ▸ floor</a>"},{"title":"Vector2#invert","link":"<a href=\"Vector2.html#invert\">Vector2 ▸ invert</a>"},{"title":"Vector2#length","link":"<a href=\"Vector2.html#length\">Vector2 ▸ length</a>"},{"title":"Vector2#lengthSquared","link":"<a href=\"Vector2.html#lengthSquared\">Vector2 ▸ lengthSquared</a>"},{"title":"Vector2#lerp","link":"<a href=\"Vector2.html#lerp\">Vector2 ▸ lerp</a>"},{"title":"Vector2#multiply","link":"<a href=\"Vector2.html#multiply\">Vector2 ▸ multiply</a>"},{"title":"Vector2#normalize","link":"<a href=\"Vector2.html#normalize\">Vector2 ▸ normalize</a>"},{"title":"Vector2#rotate","link":"<a href=\"Vector2.html#rotate\">Vector2 ▸ rotate</a>"},{"title":"Vector2#scale","link":"<a href=\"Vector2.html#scale\">Vector2 ▸ scale</a>"},{"title":"Vector2#setAngle","link":"<a href=\"Vector2.html#setAngle\">Vector2 ▸ setAngle</a>"},{"title":"Vector2#subtract","link":"<a href=\"Vector2.html#subtract\">Vector2 ▸ subtract</a>"},{"title":"Vector2#toString","link":"<a href=\"Vector2.html#toString\">Vector2 ▸ toString</a>"},{"title":"Debug","link":"<a href=\"Debug.html\">Debug</a>"},{"title":"Debug.debugAABB","link":"<a href=\"Debug.html#.debugAABB\">Debug.debugAABB ▸ undefined</a>"},{"title":"Debug.debugCircle","link":"<a href=\"Debug.html#.debugCircle\">Debug.debugCircle ▸ undefined</a>"},{"title":"Debug.debugClear","link":"<a href=\"Debug.html#.debugClear\">Debug.debugClear ▸ undefined</a>"},{"title":"Debug.debugLine","link":"<a href=\"Debug.html#.debugLine\">Debug.debugLine ▸ undefined</a>"},{"title":"Debug.debugPoint","link":"<a href=\"Debug.html#.debugPoint\">Debug.debugPoint ▸ undefined</a>"},{"title":"Debug.debugRect","link":"<a href=\"Debug.html#.debugRect\">Debug.debugRect ▸ undefined</a>"},{"title":"Debug.debugSaveCanvas","link":"<a href=\"Debug.html#.debugSaveCanvas\">Debug.debugSaveCanvas ▸ undefined</a>"},{"title":"Debug.debugText","link":"<a href=\"Debug.html#.debugText\">Debug.debugText ▸ undefined</a>"},{"title":"Draw","link":"<a href=\"Draw.html\">Draw</a>"},{"title":"Draw.drawCanvas2D","link":"<a href=\"Draw.html#.drawCanvas2D\">Draw.drawCanvas2D ▸ undefined</a>"},{"title":"Draw.drawLine","link":"<a href=\"Draw.html#.drawLine\">Draw.drawLine ▸ undefined</a>"},{"title":"Draw.drawRect","link":"<a href=\"Draw.html#.drawRect\">Draw.drawRect ▸ undefined</a>"},{"title":"Draw.drawRectScreenSpace","link":"<a href=\"Draw.html#.drawRectScreenSpace\">Draw.drawRectScreenSpace ▸ undefined</a>"},{"title":"Draw.drawText","link":"<a href=\"Draw.html#.drawText\">Draw.drawText ▸ undefined</a>"},{"title":"Draw.drawTextScreen","link":"<a href=\"Draw.html#.drawTextScreen\">Draw.drawTextScreen ▸ undefined</a>"},{"title":"Draw.drawTile","link":"<a href=\"Draw.html#.drawTile\">Draw.drawTile ▸ undefined</a>"},{"title":"Draw.drawTileScreenSpace","link":"<a href=\"Draw.html#.drawTileScreenSpace\">Draw.drawTileScreenSpace ▸ undefined</a>"},{"title":"Draw.isFullscreen","link":"<a href=\"Draw.html#.isFullscreen\">Draw.isFullscreen ▸ undefined</a>"},{"title":"Draw.screenToWorld","link":"<a href=\"Draw.html#.screenToWorld\">Draw.screenToWorld ▸ undefined</a>"},{"title":"Draw.setBlendMode","link":"<a href=\"Draw.html#.setBlendMode\">Draw.setBlendMode ▸ undefined</a>"},{"title":"Draw.toggleFullscreen","link":"<a href=\"Draw.html#.toggleFullscreen\">Draw.toggleFullscreen ▸ undefined</a>"},{"title":"Draw.worldToScreen","link":"<a href=\"Draw.html#.worldToScreen\">Draw.worldToScreen ▸ undefined</a>"},{"title":"Input","link":"<a href=\"Input.html\">Input</a>"},{"title":"Input.clearInput","link":"<a href=\"Input.html#.clearInput\">Input.clearInput ▸ undefined</a>"},{"title":"Input.gamepadIsDown","link":"<a href=\"Input.html#.gamepadIsDown\">Input.gamepadIsDown ▸ undefined</a>"},{"title":"Input.gamepadStick","link":"<a href=\"Input.html#.gamepadStick\">Input.gamepadStick ▸ undefined</a>"},{"title":"Input.gamepadWasPressed","link":"<a href=\"Input.html#.gamepadWasPressed\">Input.gamepadWasPressed ▸ undefined</a>"},{"title":"Input.gamepadWasReleased","link":"<a href=\"Input.html#.gamepadWasReleased\">Input.gamepadWasReleased ▸ undefined</a>"},{"title":"Input.keyIsDown","link":"<a href=\"Input.html#.keyIsDown\">Input.keyIsDown ▸ undefined</a>"},{"title":"Input.keyWasPressed","link":"<a href=\"Input.html#.keyWasPressed\">Input.keyWasPressed ▸ undefined</a>"},{"title":"Input.keyWasReleased","link":"<a href=\"Input.html#.keyWasReleased\">Input.keyWasReleased ▸ undefined</a>"},{"title":"Input.vibrate","link":"<a href=\"Input.html#.vibrate\">Input.vibrate ▸ undefined</a>"},{"title":"Input.vibrateStop","link":"<a href=\"Input.html#.vibrateStop\">Input.vibrateStop ▸ undefined</a>"},{"title":"Medals","link":"<a href=\"Medals.html\">Medals</a>"},{"title":"Medals.medalsInit","link":"<a href=\"Medals.html#.medalsInit\">Medals.medalsInit ▸ undefined</a>"},{"title":"Random","link":"<a href=\"Random.html\">Random</a>"},{"title":"Random.rand","link":"<a href=\"Random.html#.rand\">Random.rand ▸ undefined</a>"},{"title":"Random.randColor","link":"<a href=\"Random.html#.randColor\">Random.randColor ▸ undefined</a>"},{"title":"Random.randInCircle","link":"<a href=\"Random.html#.randInCircle\">Random.randInCircle ▸ undefined</a>"},{"title":"Random.randInt","link":"<a href=\"Random.html#.randInt\">Random.randInt ▸ undefined</a>"},{"title":"Random.randSeeded","link":"<a href=\"Random.html#.randSeeded\">Random.randSeeded ▸ undefined</a>"},{"title":"Random.randSign","link":"<a href=\"Random.html#.randSign\">Random.randSign ▸ undefined</a>"},{"title":"Random.randVector","link":"<a href=\"Random.html#.randVector\">Random.randVector ▸ undefined</a>"},{"title":"Settings","link":"<a href=\"Settings.html\">Settings</a>"},{"title":"TileCollision","link":"<a href=\"TileCollision.html\">TileCollision</a>"},{"title":"TileCollision.getTileCollisionData","link":"<a href=\"TileCollision.html#.getTileCollisionData\">TileCollision.getTileCollisionData ▸ undefined</a>"},{"title":"TileCollision.initTileCollision","link":"<a href=\"TileCollision.html#.initTileCollision\">TileCollision.initTileCollision ▸ undefined</a>"},{"title":"TileCollision.setTileCollisionData","link":"<a href=\"TileCollision.html#.setTileCollisionData\">TileCollision.setTileCollisionData ▸ undefined</a>"},{"title":"TileCollision.tileCollisionRaycast","link":"<a href=\"TileCollision.html#.tileCollisionRaycast\">TileCollision.tileCollisionRaycast ▸ undefined</a>"},{"title":"TileCollision.tileCollisionTest","link":"<a href=\"TileCollision.html#.tileCollisionTest\">TileCollision.tileCollisionTest ▸ undefined</a>"},{"title":"Utilities","link":"<a href=\"Utilities.html\">Utilities</a>"},{"title":"Utilities.abs","link":"<a href=\"Utilities.html#.abs\">Utilities.abs ▸ undefined</a>"},{"title":"Utilities.clamp","link":"<a href=\"Utilities.html#.clamp\">Utilities.clamp ▸ undefined</a>"},{"title":"Utilities.formatTime","link":"<a href=\"Utilities.html#.formatTime\">Utilities.formatTime ▸ undefined</a>"},{"title":"Utilities.isOverlapping","link":"<a href=\"Utilities.html#.isOverlapping\">Utilities.isOverlapping ▸ undefined</a>"},{"title":"Utilities.lerp","link":"<a href=\"Utilities.html#.lerp\">Utilities.lerp ▸ undefined</a>"},{"title":"Utilities.max","link":"<a href=\"Utilities.html#.max\">Utilities.max ▸ undefined</a>"},{"title":"Utilities.min","link":"<a href=\"Utilities.html#.min\">Utilities.min ▸ undefined</a>"},{"title":"Utilities.mod","link":"<a href=\"Utilities.html#.mod\">Utilities.mod ▸ undefined</a>"},{"title":"Utilities.nearestPowerOfTwo","link":"<a href=\"Utilities.html#.nearestPowerOfTwo\">Utilities.nearestPowerOfTwo ▸ undefined</a>"},{"title":"Utilities.percent","link":"<a href=\"Utilities.html#.percent\">Utilities.percent ▸ undefined</a>"},{"title":"Utilities.sign","link":"<a href=\"Utilities.html#.sign\">Utilities.sign ▸ undefined</a>"},{"title":"Utilities.smoothStep","link":"<a href=\"Utilities.html#.smoothStep\">Utilities.smoothStep ▸ undefined</a>"},{"title":"Utilities.vec2","link":"<a href=\"Utilities.html#.vec2\">Utilities.vec2 ▸ undefined</a>"},{"title":"Utilities.wave","link":"<a href=\"Utilities.html#.wave\">Utilities.wave ▸ undefined</a>"},{"title":"WebGL","link":"<a href=\"WebGL.html\">WebGL</a>"},{"title":"WebGL.glCompileShader","link":"<a href=\"WebGL.html#.glCompileShader\">WebGL.glCompileShader ▸ undefined</a>"},{"title":"WebGL.glCopyToContext","link":"<a href=\"WebGL.html#.glCopyToContext\">WebGL.glCopyToContext ▸ undefined</a>"},{"title":"WebGL.glCreateBuffer","link":"<a href=\"WebGL.html#.glCreateBuffer\">WebGL.glCreateBuffer ▸ undefined</a>"},{"title":"WebGL.glCreateProgram","link":"<a href=\"WebGL.html#.glCreateProgram\">WebGL.glCreateProgram ▸ undefined</a>"},{"title":"WebGL.glCreateTexture","link":"<a href=\"WebGL.html#.glCreateTexture\">WebGL.glCreateTexture ▸ undefined</a>"},{"title":"WebGL.glDraw","link":"<a href=\"WebGL.html#.glDraw\">WebGL.glDraw ▸ undefined</a>"},{"title":"WebGL.glFlush","link":"<a href=\"WebGL.html#.glFlush\">WebGL.glFlush ▸ undefined</a>"},{"title":"WebGL.glSetBlendMode","link":"<a href=\"WebGL.html#.glSetBlendMode\">WebGL.glSetBlendMode ▸ undefined</a>"},{"title":"WebGL.glSetTexture","link":"<a href=\"WebGL.html#.glSetTexture\">WebGL.glSetTexture ▸ undefined</a>"},{"title":"engineFontImage","link":"<a href=\"global.html#engineFontImage\">engineFontImage</a>"},{"title":"engineInit","link":"<a href=\"global.html#engineInit\">engineInit</a>"},{"title":"engineName","link":"<a href=\"global.html#engineName\">engineName</a>"},{"title":"engineObjects","link":"<a href=\"global.html#engineObjects\">engineObjects</a>"},{"title":"engineObjectsCallback","link":"<a href=\"global.html#engineObjectsCallback\">engineObjectsCallback</a>"},{"title":"engineObjectsCollide","link":"<a href=\"global.html#engineObjectsCollide\">engineObjectsCollide</a>"},{"title":"engineObjectsDestroy","link":"<a href=\"global.html#engineObjectsDestroy\">engineObjectsDestroy</a>"},{"title":"engineObjectsUpdate","link":"<a href=\"global.html#engineObjectsUpdate\">engineObjectsUpdate</a>"},{"title":"engineVersion","link":"<a href=\"global.html#engineVersion\">engineVersion</a>"},{"title":"frame","link":"<a href=\"global.html#frame\">frame</a>"},{"title":"frameRate","link":"<a href=\"global.html#frameRate\">frameRate</a>"},{"title":"paused","link":"<a href=\"global.html#paused\">paused</a>"},{"title":"time","link":"<a href=\"global.html#time\">time</a>"},{"title":"timeDelta","link":"<a href=\"global.html#timeDelta\">timeDelta</a>"},{"title":"timeReal","link":"<a href=\"global.html#timeReal\">timeReal</a>"}];
|
|
611
|
+
var options =
|
|
612
|
+
setupSearch(list, options)
|
|
613
|
+
</script>
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
</body>
|
|
626
|
+
|
|
627
|
+
</html>
|