littlejsengine 1.1.6 → 1.1.8
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/docs/Audio.html +2268 -0
- package/docs/Color.html +2989 -0
- package/docs/Debug.html +2933 -0
- package/docs/Draw.html +4092 -0
- package/docs/EngineObject.html +4458 -0
- package/docs/Input.html +2482 -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 +4535 -0
- package/docs/ParticleEmitter.html +7770 -0
- package/docs/Random.html +1774 -0
- package/docs/Settings.html +2679 -0
- package/docs/Sound.html +1249 -0
- package/docs/TileCollision.html +1409 -0
- package/docs/TileLayer.html +6948 -0
- package/docs/TileLayerData.html +1052 -0
- package/docs/Timer.html +1183 -0
- package/docs/Utilities.html +3281 -0
- package/docs/Vector2.html +4207 -0
- package/docs/WebGL.html +2327 -0
- package/docs/engine.js.html +429 -0
- package/docs/engineAudio.js.html +609 -0
- package/docs/engineDebug.js.html +725 -0
- package/docs/engineDraw.js.html +419 -0
- package/docs/engineInput.js.html +401 -0
- package/docs/engineMedals.js.html +461 -0
- package/docs/engineObject.js.html +518 -0
- package/docs/engineParticles.js.html +441 -0
- package/docs/engineSettings.js.html +349 -0
- package/docs/engineTileLayer.js.html +513 -0
- package/docs/engineUtilities.js.html +647 -0
- package/docs/engineWebGL.js.html +522 -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 +1691 -0
- package/docs/index.css +6 -0
- package/docs/index.html +247 -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 +94 -110
- package/engine/engine.all.min.js +1 -1
- package/engine/engine.all.release.js +94 -110
- package/engine/engine.js +14 -17
- package/engine/engineAudio.js +7 -7
- package/engine/engineDraw.js +6 -6
- package/engine/engineInput.js +7 -7
- package/engine/engineMedals.js +3 -3
- package/engine/engineObject.js +15 -15
- package/engine/engineParticles.js +3 -3
- package/engine/engineSettings.js +30 -43
- package/engine/engineTileLayer.js +5 -5
- package/engine/engineUtilities.js +4 -4
- package/examples/breakout/game.js +1 -1
- package/examples/breakout/gameObjects.js +1 -1
- package/examples/breakout/index.html +3 -3
- package/examples/platformer/gameObjects.js +1 -1
- package/examples/platformer/gamePlayer.js +1 -1
- package/examples/platformer/index.html +6 -6
- package/examples/puzzle/game.js +1 -1
- package/examples/puzzle/index.html +2 -2
- package/examples/stress/index.html +1 -1
- package/index.html +13 -13
- package/package.json +1 -1
|
@@ -0,0 +1,647 @@
|
|
|
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
|
+
engineUtilities.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="3026681" > <h3 class="accordion-heading">Classes<svg><use xlink:href="#down-icon"></use></svg></h3><ul class="accordion-content"><li class="accordion collapsed child" id=864267><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#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#rgba">rgba</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#setHSLA">setHSLA</a></li><li data-type='method'><a href="Color.html#subtract">subtract</a></li></ul></li><li class="accordion collapsed child" id=3569399><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=2970668><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=2533015><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=5490011><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=5370538><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=4983401><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=4102019><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=3455641><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=1570904><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=3515045><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#unset">unset</a></li></ul></li><li class="accordion collapsed child" id=7852068><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#flip">flip</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></ul></li></ul> </div><div class="accordion collapsed" id="813939" > <h3 class="accordion-heading">Namespaces<svg><use xlink:href="#down-icon"></use></svg></h3><ul class="accordion-content"><li class="accordion collapsed child" id=2717358><div class="accordion-heading child"><a href="Audio.html">Audio</a><svg><use xlink:href="#down-icon"></use></svg></div><ul class='methods accordion-content'><li data-type='method'><a href="Audio.html#.getNoteFrequency">getNoteFrequency</a></li><li data-type='method'><a href="Audio.html#.playAudioFile">playAudioFile</a></li><li data-type='method'><a href="Audio.html#.playSamples">playSamples</a></li><li data-type='method'><a href="Audio.html#.speak">speak</a></li><li data-type='method'><a href="Audio.html#.stopSpeech">stopSpeech</a></li><li data-type='method'><a href="Audio.html#.zzfx">zzfx</a></li><li data-type='method'><a href="Audio.html#.zzfxG">zzfxG</a></li><li data-type='method'><a href="Audio.html#.zzfxM">zzfxM</a></li></ul></li><li class="accordion collapsed child" id=8015982><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=3886530><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#.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=2344392><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></ul></li><li class="accordion collapsed child" id=4725200><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=7676165><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=2840044><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=6238309><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=6305592><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="9475387" > <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#engineCollideObjects">engineCollideObjects</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#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#FPS">FPS</a></li><li class="accordion-list" id=""><a href="global.html#frame">frame</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
|
+
engineUtilities.js
|
|
108
|
+
</h1>
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
<section>
|
|
117
|
+
<article>
|
|
118
|
+
<pre class="prettyprint source linenums"><code>/**
|
|
119
|
+
* LittleJS Utility Classes and Functions
|
|
120
|
+
* <br> - General purpose math library
|
|
121
|
+
* <br> - Vector2 - fast, simple, easy 2D vector class
|
|
122
|
+
* <br> - Color - holds a rgba color with some math functions
|
|
123
|
+
* <br> - Timer - tracks time automatically
|
|
124
|
+
* @namespace Utilities
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
'use strict';
|
|
128
|
+
|
|
129
|
+
/** A shortcut to get Math.PI
|
|
130
|
+
* @const
|
|
131
|
+
* @memberof Utilities */
|
|
132
|
+
const PI = Math.PI;
|
|
133
|
+
|
|
134
|
+
/** True if running a Chromium based browser
|
|
135
|
+
* @const
|
|
136
|
+
* @memberof Utilities */
|
|
137
|
+
const isChrome = window['chrome'];
|
|
138
|
+
|
|
139
|
+
/** Returns absoulte value of value passed in
|
|
140
|
+
* @param {Number} value
|
|
141
|
+
* @return {Number}
|
|
142
|
+
* @memberof Utilities */
|
|
143
|
+
const abs = (a)=> a < 0 ? -a : a;
|
|
144
|
+
|
|
145
|
+
/** Returns the sign of value passed in
|
|
146
|
+
* @param {Number} value
|
|
147
|
+
* @return {Number}
|
|
148
|
+
* @memberof Utilities */
|
|
149
|
+
const sign = (a)=> a < 0 ? -1 : 1;
|
|
150
|
+
|
|
151
|
+
/** Returns lowest of two values passed in
|
|
152
|
+
* @param {Number} valueA
|
|
153
|
+
* @param {Number} valueB
|
|
154
|
+
* @return {Number}
|
|
155
|
+
* @memberof Utilities */
|
|
156
|
+
const min = (a, b)=> a < b ? a : b;
|
|
157
|
+
|
|
158
|
+
/** Returns highest of two values passed in
|
|
159
|
+
* @param {Number} valueA
|
|
160
|
+
* @param {Number} valueB
|
|
161
|
+
* @return {Number}
|
|
162
|
+
* @memberof Utilities */
|
|
163
|
+
const max = (a, b)=> a > b ? a : b;
|
|
164
|
+
|
|
165
|
+
/** Returns first parm modulo the second param, but adjusted so negative numbers work as expected
|
|
166
|
+
* @param {Number} dividend
|
|
167
|
+
* @param {Number} divisor
|
|
168
|
+
* @return {Number}
|
|
169
|
+
* @memberof Utilities */
|
|
170
|
+
const mod = (a, b)=> ((a % b) + b) % b;
|
|
171
|
+
|
|
172
|
+
/** Clamps the value beween max and min
|
|
173
|
+
* @param {Number} value
|
|
174
|
+
* @param {Number} [max=1]
|
|
175
|
+
* @param {Number} [min=0]
|
|
176
|
+
* @return {Number}
|
|
177
|
+
* @memberof Utilities */
|
|
178
|
+
const clamp = (v, max=1, min=0)=> (ASSERT(max > min), v < min ? min : v > max ? max : v);
|
|
179
|
+
|
|
180
|
+
/** Returns what percentage the value is between max and min
|
|
181
|
+
* @param {Number} value
|
|
182
|
+
* @param {Number} [max=1]
|
|
183
|
+
* @param {Number} [min=0]
|
|
184
|
+
* @return {Number}
|
|
185
|
+
* @memberof Utilities */
|
|
186
|
+
const percent = (v, max=1, min=0)=> max-min ? clamp((v-min) / (max-min)) : 0;
|
|
187
|
+
|
|
188
|
+
/** Linearly interpolates the percent value between max and min
|
|
189
|
+
* @param {Number} percent
|
|
190
|
+
* @param {Number} [max=1]
|
|
191
|
+
* @param {Number} [min=0]
|
|
192
|
+
* @return {Number}
|
|
193
|
+
* @memberof Utilities */
|
|
194
|
+
const lerp = (p, max=1, min=0)=> min + clamp(p) * (max-min);
|
|
195
|
+
|
|
196
|
+
/** Formats seconds to mm:ss style for display purposes
|
|
197
|
+
* @param {Number} t - time in seconds
|
|
198
|
+
* @return {String}
|
|
199
|
+
* @memberof Utilities */
|
|
200
|
+
const formatTime = (t)=> (t/60|0)+':'+(t%60<10?'0':'')+(t%60|0);
|
|
201
|
+
|
|
202
|
+
/** Returns the nearest power of two not less then the value
|
|
203
|
+
* @param {Number} value
|
|
204
|
+
* @return {Number}
|
|
205
|
+
* @memberof Utilities */
|
|
206
|
+
const nearestPowerOfTwo = (v)=> 2**Math.ceil(Math.log2(v));
|
|
207
|
+
|
|
208
|
+
/** Applies smoothstep function to the percentage value
|
|
209
|
+
* @param {Number} value
|
|
210
|
+
* @return {Number}
|
|
211
|
+
* @memberof Utilities */
|
|
212
|
+
const smoothStep = (p)=> p * p * (3 - 2 * p);
|
|
213
|
+
|
|
214
|
+
/** Returns true if two axis aligned bounding boxes are overlapping
|
|
215
|
+
* @param {Vector2} pointA - Center of box A
|
|
216
|
+
* @param {Vector2} sizeA - Size of box A
|
|
217
|
+
* @param {Vector2} pointB - Center of box B
|
|
218
|
+
* @param {Vector2} sizeB - Size of box B
|
|
219
|
+
* @return {Boolean} - True if overlapping
|
|
220
|
+
* @memberof Utilities */
|
|
221
|
+
const isOverlapping = (pA, sA, pB, sB)=> abs(pA.x - pB.x)*2 < sA.x + sB.x & abs(pA.y - pB.y)*2 < sA.y + sB.y;
|
|
222
|
+
|
|
223
|
+
/** Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default
|
|
224
|
+
* @param {Number} [frequency=1] - Frequency of the wave in Hz
|
|
225
|
+
* @param {Number} [amplitude=1] - Amplitude (max height) of the wave
|
|
226
|
+
* @param {Number} [t=time] - Value to use for time of the wave
|
|
227
|
+
* @return {Number} - Value waving between 0 and amplitude
|
|
228
|
+
* @memberof Utilities */
|
|
229
|
+
const wave = (frequency=1, amplitude=1, t=time)=> amplitude/2 * (1 - Math.cos(t*frequency*2*PI));
|
|
230
|
+
|
|
231
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
232
|
+
|
|
233
|
+
/** Random global functions
|
|
234
|
+
* @namespace Random */
|
|
235
|
+
|
|
236
|
+
/** Returns a random value between the two values passed in
|
|
237
|
+
* @param {Number} [valueA=1]
|
|
238
|
+
* @param {Number} [valueB=0]
|
|
239
|
+
* @return {Number}
|
|
240
|
+
* @memberof Random */
|
|
241
|
+
const rand = (a=1, b=0)=> b + (a-b)*Math.random();
|
|
242
|
+
|
|
243
|
+
/** Returns a floored random value the two values passed in
|
|
244
|
+
* @param {Number} [valueA=1]
|
|
245
|
+
* @param {Number} [valueB=0]
|
|
246
|
+
* @return {Number}
|
|
247
|
+
* @memberof Random */
|
|
248
|
+
const randInt = (a=1, b=0)=> rand(a,b)|0;
|
|
249
|
+
|
|
250
|
+
/** Randomly returns either -1 or 1
|
|
251
|
+
* @return {Number}
|
|
252
|
+
* @memberof Random */
|
|
253
|
+
const randSign = ()=> (rand(2)|0)*2-1;
|
|
254
|
+
|
|
255
|
+
/** Returns a random Vector2 within a circular shape
|
|
256
|
+
* @param {Number} [radius=1]
|
|
257
|
+
* @param {Number} [minRadius=0]
|
|
258
|
+
* @return {Vector2}
|
|
259
|
+
* @memberof Random */
|
|
260
|
+
const randInCircle = (radius=1, minRadius=0)=> radius > 0 ? randVector(radius * rand(minRadius / radius, 1)**.5) : new Vector2;
|
|
261
|
+
|
|
262
|
+
/** Returns a random Vector2 with the passed in length
|
|
263
|
+
* @param {Number} [length=1]
|
|
264
|
+
* @return {Vector2}
|
|
265
|
+
* @memberof Random */
|
|
266
|
+
const randVector = (length=1)=> new Vector2().setAngle(rand(2*PI), length);
|
|
267
|
+
|
|
268
|
+
/** Returns a random color between the two passed in colors, combine components if linear
|
|
269
|
+
* @param {Color} [colorA=new Color(1,1,1,1)]
|
|
270
|
+
* @param {Color} [colorB=new Color(0,0,0,1)]
|
|
271
|
+
* @param {Boolean} [linear]
|
|
272
|
+
* @return {Color}
|
|
273
|
+
* @memberof Random */
|
|
274
|
+
const randColor = (cA = new Color, cB = new Color(0,0,0,1), linear)=>
|
|
275
|
+
linear ? cA.lerp(cB, rand()) : new Color(rand(cA.r,cB.r),rand(cA.g,cB.g),rand(cA.b,cB.b),rand(cA.a,cB.a));
|
|
276
|
+
|
|
277
|
+
/** The seed used by the randSeeded function, should not be 0
|
|
278
|
+
* @memberof Random */
|
|
279
|
+
let randSeed = 1;
|
|
280
|
+
|
|
281
|
+
/** Returns a seeded random value between the two values passed in using randSeed
|
|
282
|
+
* @param {Number} [valueA=1]
|
|
283
|
+
* @param {Number} [valueB=0]
|
|
284
|
+
* @return {Number}
|
|
285
|
+
* @memberof Random */
|
|
286
|
+
const randSeeded = (a=1, b=0)=>
|
|
287
|
+
{
|
|
288
|
+
randSeed ^= randSeed << 13; randSeed ^= randSeed >>> 17; randSeed ^= randSeed << 5; // xorshift
|
|
289
|
+
return b + (a-b)*abs(randSeed % 1e9)/1e9;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Create a 2d vector, can take another Vector2 to copy, 2 scalars, or 1 scalar
|
|
296
|
+
* @param {Number} [x=0]
|
|
297
|
+
* @param {Number} [y=0]
|
|
298
|
+
* @return {Vector2}
|
|
299
|
+
* @example
|
|
300
|
+
* let a = vec2(0, 1); // vector with coordinates (0, 1)
|
|
301
|
+
* let b = vec2(a); // copy a into b
|
|
302
|
+
* a = vec2(5); // set a to (5, 5)
|
|
303
|
+
* b = vec2(); // set b to (0, 0)
|
|
304
|
+
* @memberof Utilities
|
|
305
|
+
*/
|
|
306
|
+
const vec2 = (x=0, y)=> x.x == undefined ? new Vector2(x, y == undefined? x : y) : new Vector2(x.x, x.y);
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* 2D Vector object with vector math library
|
|
310
|
+
* @example
|
|
311
|
+
* let a = new Vector2(2, 3); // vector with coordinates (2, 3)
|
|
312
|
+
* let b = new Vector2; // vector with coordinates (0, 0)
|
|
313
|
+
* let c = vec2(4, 2); // use the vec2 function to make a Vector2
|
|
314
|
+
*/
|
|
315
|
+
class Vector2
|
|
316
|
+
{
|
|
317
|
+
/** Create a 2D vector with the x and y passed in, can also be created with vec2()
|
|
318
|
+
* @param {Number} [x=0] - X axis location
|
|
319
|
+
* @param {Number} [y=0] - Y axis location */
|
|
320
|
+
constructor(x=0, y=0)
|
|
321
|
+
{
|
|
322
|
+
/** @property {Number} - X axis location */
|
|
323
|
+
this.x = x;
|
|
324
|
+
/** @property {Number} - Y axis location */
|
|
325
|
+
this.y = y;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** Returns a new vector that is a copy of this
|
|
329
|
+
* @return {Vector2} */
|
|
330
|
+
copy() { return new Vector2(this.x, this.y); }
|
|
331
|
+
|
|
332
|
+
/** Returns a copy of this vector plus the vector passed in
|
|
333
|
+
* @param {Vector2} vector
|
|
334
|
+
* @return {Vector2} */
|
|
335
|
+
add(v) { ASSERT(v.x!=undefined); return new Vector2(this.x + v.x, this.y + v.y); }
|
|
336
|
+
|
|
337
|
+
/** Returns a copy of this vector minus the vector passed in
|
|
338
|
+
* @param {Vector2} vector
|
|
339
|
+
* @return {Vector2} */
|
|
340
|
+
subtract(v) { ASSERT(v.x!=undefined); return new Vector2(this.x - v.x, this.y - v.y); }
|
|
341
|
+
|
|
342
|
+
/** Returns a copy of this vector times the vector passed in
|
|
343
|
+
* @param {Vector2} vector
|
|
344
|
+
* @return {Vector2} */
|
|
345
|
+
multiply(v) { ASSERT(v.x!=undefined); return new Vector2(this.x * v.x, this.y * v.y); }
|
|
346
|
+
|
|
347
|
+
/** Returns a copy of this vector divided by the vector passed in
|
|
348
|
+
* @param {Vector2} vector
|
|
349
|
+
* @return {Vector2} */
|
|
350
|
+
divide(v) { ASSERT(v.x!=undefined); return new Vector2(this.x / v.x, this.y / v.y); }
|
|
351
|
+
|
|
352
|
+
/** Returns a copy of this vector scaled by the vector passed in
|
|
353
|
+
* @param {Number} scale
|
|
354
|
+
* @return {Vector2} */
|
|
355
|
+
scale(s) { ASSERT(s.x==undefined); return new Vector2(this.x * s, this.y * s); }
|
|
356
|
+
|
|
357
|
+
/** Returns the length of this vector
|
|
358
|
+
* @return {Number} */
|
|
359
|
+
length() { return this.lengthSquared()**.5; }
|
|
360
|
+
|
|
361
|
+
/** Returns the length of this vector squared
|
|
362
|
+
* @return {Number} */
|
|
363
|
+
lengthSquared() { return this.x**2 + this.y**2; }
|
|
364
|
+
|
|
365
|
+
/** Returns the distance from this vector to vector passed in
|
|
366
|
+
* @param {Vector2} vector
|
|
367
|
+
* @return {Number} */
|
|
368
|
+
distance(v) { return this.distanceSquared(v)**.5; }
|
|
369
|
+
|
|
370
|
+
/** Returns the distance squared from this vector to vector passed in
|
|
371
|
+
* @param {Vector2} vector
|
|
372
|
+
* @return {Number} */
|
|
373
|
+
distanceSquared(v) { return (this.x - v.x)**2 + (this.y - v.y)**2; }
|
|
374
|
+
|
|
375
|
+
/** Returns a new vector in same direction as this one with the length passed in
|
|
376
|
+
* @param {Number} [length=1]
|
|
377
|
+
* @return {Vector2} */
|
|
378
|
+
normalize(length=1) { const l = this.length(); return l ? this.scale(length/l) : new Vector2(length); }
|
|
379
|
+
|
|
380
|
+
/** Returns a new vector clamped to length passed in
|
|
381
|
+
* @param {Number} [length=1]
|
|
382
|
+
* @return {Vector2} */
|
|
383
|
+
clampLength(length=1) { const l = this.length(); return l > length ? this.scale(length/l) : this; }
|
|
384
|
+
|
|
385
|
+
/** Returns the dot product of this and the vector passed in
|
|
386
|
+
* @param {Vector2} vector
|
|
387
|
+
* @return {Number} */
|
|
388
|
+
dot(v) { ASSERT(v.x!=undefined); return this.x*v.x + this.y*v.y; }
|
|
389
|
+
|
|
390
|
+
/** Returns the cross product of this and the vector passed in
|
|
391
|
+
* @param {Vector2} vector
|
|
392
|
+
* @return {Number} */
|
|
393
|
+
cross(v) { ASSERT(v.x!=undefined); return this.x*v.y - this.y*v.x; }
|
|
394
|
+
|
|
395
|
+
/** Returns the angle of this vector, up is angle 0
|
|
396
|
+
* @return {Number} */
|
|
397
|
+
angle() { return Math.atan2(this.x, this.y); }
|
|
398
|
+
|
|
399
|
+
/** Sets this vector with angle and length passed in
|
|
400
|
+
* @param {Number} [angle=0]
|
|
401
|
+
* @param {Number} [length=1] */
|
|
402
|
+
setAngle(a=0, length=1) { this.x = length*Math.sin(a); this.y = length*Math.cos(a); return this; }
|
|
403
|
+
|
|
404
|
+
/** Returns copy of this vector rotated by the angle passed in
|
|
405
|
+
* @param {Number} angle
|
|
406
|
+
* @return {Vector2} */
|
|
407
|
+
rotate(a) { const c = Math.cos(a), s = Math.sin(a); return new Vector2(this.x*c-this.y*s, this.x*s+this.y*c); }
|
|
408
|
+
|
|
409
|
+
/** Returns the integer direction of this vector, corrosponding to multiples of 90 degree rotation (0-3)
|
|
410
|
+
* @return {Number} */
|
|
411
|
+
direction() { return abs(this.x) > abs(this.y) ? this.x < 0 ? 3 : 1 : this.y < 0 ? 2 : 0; }
|
|
412
|
+
|
|
413
|
+
/** Returns a copy of this vector that has been inverted
|
|
414
|
+
* @return {Vector2} */
|
|
415
|
+
invert() { return new Vector2(this.y, -this.x); }
|
|
416
|
+
|
|
417
|
+
/** Returns a copy of this vector with the axies flipped
|
|
418
|
+
* @return {Vector2} */
|
|
419
|
+
flip() { return new Vector2(this.y, this.x); }
|
|
420
|
+
|
|
421
|
+
/** Returns a copy of this vector with each axis floored
|
|
422
|
+
* @return {Vector2} */
|
|
423
|
+
floor() { return new Vector2(Math.floor(this.x), Math.floor(this.y)); }
|
|
424
|
+
|
|
425
|
+
/** Returns the area this vector covers as a rectangle
|
|
426
|
+
* @return {Number} */
|
|
427
|
+
area() { return this.x * this.y; }
|
|
428
|
+
|
|
429
|
+
/** Returns a new vector that is p percent between this and the vector passed in
|
|
430
|
+
* @param {Vector2} vector
|
|
431
|
+
* @param {Number} percent
|
|
432
|
+
* @return {Vector2} */
|
|
433
|
+
lerp(v, p) { ASSERT(v.x!=undefined); return this.add(v.subtract(this).scale(clamp(p))); }
|
|
434
|
+
|
|
435
|
+
/** Returns true if this vector is within the bounds of an array size passed in
|
|
436
|
+
* @param {Vector2} arraySize
|
|
437
|
+
* @return {Boolean} */
|
|
438
|
+
arrayCheck(arraySize) { return this.x >= 0 && this.y >= 0 && this.x < arraySize.x && this.y < arraySize.y; }
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Color object (red, green, blue, alpha) with some helpful functions
|
|
445
|
+
* @example
|
|
446
|
+
* let a = new Color; // white
|
|
447
|
+
* let b = new Color(1, 0, 0); // red
|
|
448
|
+
* let c = new Color(0, 0, 0, 0); // transparent black
|
|
449
|
+
*/
|
|
450
|
+
class Color
|
|
451
|
+
{
|
|
452
|
+
/** Create a color with the components passed in, white by default
|
|
453
|
+
* @param {Number} [red=1]
|
|
454
|
+
* @param {Number} [green=1]
|
|
455
|
+
* @param {Number} [blue=1]
|
|
456
|
+
* @param {Number} [alpha=1] */
|
|
457
|
+
constructor(r=1, g=1, b=1, a=1)
|
|
458
|
+
{
|
|
459
|
+
/** @property {Number} - Red */
|
|
460
|
+
this.r = r;
|
|
461
|
+
/** @property {Number} - Green */
|
|
462
|
+
this.g = g;
|
|
463
|
+
/** @property {Number} - Blue */
|
|
464
|
+
this.b = b;
|
|
465
|
+
/** @property {Number} - Alpha */
|
|
466
|
+
this.a = a;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/** Returns a new color that is a copy of this
|
|
470
|
+
* @return {Color} */
|
|
471
|
+
copy() { return new Color(this.r, this.g, this.b, this.a); }
|
|
472
|
+
|
|
473
|
+
/** Returns a copy of this color plus the color passed in
|
|
474
|
+
* @param {Color} color
|
|
475
|
+
* @return {Color} */
|
|
476
|
+
add(c) { return new Color(this.r+c.r, this.g+c.g, this.b+c.b, this.a+c.a); }
|
|
477
|
+
|
|
478
|
+
/** Returns a copy of this color minus the color passed in
|
|
479
|
+
* @param {Color} color
|
|
480
|
+
* @return {Color} */
|
|
481
|
+
subtract(c) { return new Color(this.r-c.r, this.g-c.g, this.b-c.b, this.a-c.a); }
|
|
482
|
+
|
|
483
|
+
/** Returns a copy of this color times the color passed in
|
|
484
|
+
* @param {Color} color
|
|
485
|
+
* @return {Color} */
|
|
486
|
+
multiply(c) { return new Color(this.r*c.r, this.g*c.g, this.b*c.b, this.a*c.a); }
|
|
487
|
+
|
|
488
|
+
/** Returns a copy of this color divided by the color passed in
|
|
489
|
+
* @param {Color} color
|
|
490
|
+
* @return {Color} */
|
|
491
|
+
divide(c) { return new Color(this.r/c.r, this.g/c.g, this.b/c.b, this.a/c.a); }
|
|
492
|
+
|
|
493
|
+
/** Returns a copy of this color scaled by the value passed in, alpha can be scaled separately
|
|
494
|
+
* @param {Number} scale
|
|
495
|
+
* @param {Number} [alphaScale=scale]
|
|
496
|
+
* @return {Color} */
|
|
497
|
+
scale(s, a=s) { return new Color(this.r*s, this.g*s, this.b*s, this.a*a); }
|
|
498
|
+
|
|
499
|
+
/** Returns a copy of this color clamped to the valid range between 0 and 1
|
|
500
|
+
* @return {Color} */
|
|
501
|
+
clamp() { return new Color(clamp(this.r), clamp(this.g), clamp(this.b), clamp(this.a)); }
|
|
502
|
+
|
|
503
|
+
/** Returns a new color that is p percent between this and the color passed in
|
|
504
|
+
* @param {Color} color
|
|
505
|
+
* @param {Number} percent
|
|
506
|
+
* @return {Color} */
|
|
507
|
+
lerp(c, p) { return this.add(c.subtract(this).scale(clamp(p))); }
|
|
508
|
+
|
|
509
|
+
/** Sets this color given a hue, saturation, lightness , and alpha
|
|
510
|
+
* @param {Number} [hue=0]
|
|
511
|
+
* @param {Number} [saturation=0]
|
|
512
|
+
* @param {Number} [lightness=1]
|
|
513
|
+
* @param {Number} [alpha=1]
|
|
514
|
+
* @return {Color} */
|
|
515
|
+
setHSLA(h=0, s=0, l=1, a=1)
|
|
516
|
+
{
|
|
517
|
+
const q = l < .5 ? l*(1+s) : l+s-l*s, p = 2*l-q,
|
|
518
|
+
f = (p, q, t)=>
|
|
519
|
+
(t = ((t%1)+1)%1) < 1/6 ? p+(q-p)*6*t :
|
|
520
|
+
t < 1/2 ? q :
|
|
521
|
+
t < 2/3 ? p+(q-p)*(2/3-t)*6 : p;
|
|
522
|
+
|
|
523
|
+
this.r = f(p, q, h + 1/3);
|
|
524
|
+
this.g = f(p, q, h);
|
|
525
|
+
this.b = f(p, q, h - 1/3);
|
|
526
|
+
this.a = a;
|
|
527
|
+
return this;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/** Returns a new color that has each component randomly adjusted
|
|
531
|
+
* @param {Number} [amount=.05]
|
|
532
|
+
* @param {Number} [alphaAmount=0]
|
|
533
|
+
* @return {Color} */
|
|
534
|
+
mutate(amount=.05, alphaAmount=0)
|
|
535
|
+
{
|
|
536
|
+
return new Color
|
|
537
|
+
(
|
|
538
|
+
this.r + rand(amount, -amount),
|
|
539
|
+
this.g + rand(amount, -amount),
|
|
540
|
+
this.b + rand(amount, -amount),
|
|
541
|
+
this.a + rand(alphaAmount, -alphaAmount)
|
|
542
|
+
).clamp();
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/** Returns this color expressed as an rgba string
|
|
546
|
+
* @return {String} */
|
|
547
|
+
rgba()
|
|
548
|
+
{
|
|
549
|
+
ASSERT(this.r>=0 && this.r<=1 && this.g>=0 && this.g<=1 && this.b>=0 && this.b<=1 && this.a>=0 && this.a<=1);
|
|
550
|
+
return `rgb(${this.r*255|0},${this.g*255|0},${this.b*255|0},${this.a})`;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** Returns this color expressed as 32 bit integer value
|
|
554
|
+
* @return {Number} */
|
|
555
|
+
rgbaInt()
|
|
556
|
+
{
|
|
557
|
+
ASSERT(this.r>=0 && this.r<=1 && this.g>=0 && this.g<=1 && this.b>=0 && this.b<=1 && this.a>=0 && this.a<=1);
|
|
558
|
+
return (this.r*255|0) + (this.g*255<<8) + (this.b*255<<16) + (this.a*255<<24);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Timer object tracks how long has passed since it was set
|
|
566
|
+
* @example
|
|
567
|
+
* let a = new Timer; // creates a timer that is not set
|
|
568
|
+
* a.set(3); // sets the timer to 3 seconds
|
|
569
|
+
*
|
|
570
|
+
* let b = new Timer(1); // creates a timer with 1 second left
|
|
571
|
+
* b.unset(); // unsets the timer
|
|
572
|
+
*/
|
|
573
|
+
class Timer
|
|
574
|
+
{
|
|
575
|
+
/** Create a timer object set time passed in
|
|
576
|
+
* @param {Number} [timeLeft] - How much time left before the timer elapses in seconds */
|
|
577
|
+
constructor(timeLeft) { this.time = timeLeft == undefined ? undefined : time + timeLeft; this.setTime = timeLeft; }
|
|
578
|
+
|
|
579
|
+
/** Set the timer with seconds passed in
|
|
580
|
+
* @param {Number} [timeLeft=0] - How much time left before the timer is elapsed in seconds */
|
|
581
|
+
set(timeLeft=0) { this.time = time + timeLeft; this.setTime = timeLeft; }
|
|
582
|
+
|
|
583
|
+
/** Unset the timer */
|
|
584
|
+
unset() { this.time = undefined; }
|
|
585
|
+
|
|
586
|
+
/** Returns true if set
|
|
587
|
+
* @return {Boolean} */
|
|
588
|
+
isSet() { return this.time != undefined; }
|
|
589
|
+
|
|
590
|
+
/** Returns true if set and has not elapsed
|
|
591
|
+
* @return {Boolean} */
|
|
592
|
+
active() { return time <= this.time; }
|
|
593
|
+
|
|
594
|
+
/** Returns true if set and elapsed
|
|
595
|
+
* @return {Boolean} */
|
|
596
|
+
elapsed() { return time > this.time; }
|
|
597
|
+
|
|
598
|
+
/** Get how long since elapsed, returns 0 if not set
|
|
599
|
+
* @return {Number} */
|
|
600
|
+
get() { return this.isSet()? time - this.time : 0; }
|
|
601
|
+
|
|
602
|
+
/** Get percentage elapsed based on time it was set to, returns 0 if not set
|
|
603
|
+
* @return {Number} */
|
|
604
|
+
getPercent() { return this.isSet()? percent(this.time - time, 0, this.setTime) : 0; }
|
|
605
|
+
}</code></pre>
|
|
606
|
+
</article>
|
|
607
|
+
</section>
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
</div>
|
|
613
|
+
|
|
614
|
+
<footer class="footer" id="footer">
|
|
615
|
+
<a href=https://github.com/KilledByAPixel/LittleJS>LittleJS - MIT License - Copyright 2021 Frank Force</a>
|
|
616
|
+
</footer>
|
|
617
|
+
|
|
618
|
+
<script src="scripts/third-party/prettify.js"></script>
|
|
619
|
+
<script src="scripts/third-party/lang-css.js"></script>
|
|
620
|
+
<script type="text/javascript" src="scripts/misc.js"></script>
|
|
621
|
+
|
|
622
|
+
<script>prettyPrint();</script>
|
|
623
|
+
<script src="scripts/linenumber.js"></script>
|
|
624
|
+
<script src="scripts/fix-code-block.js"></script>
|
|
625
|
+
<script src="scripts/fix-navbar.js"></script>
|
|
626
|
+
|
|
627
|
+
<script src="scripts/search.js"></script>
|
|
628
|
+
<script src="scripts/third-party/fuse.js"></script>
|
|
629
|
+
<script>
|
|
630
|
+
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#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#rgba","link":"<a href=\"Color.html#rgba\">Color ▸ rgba</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#setHSLA","link":"<a href=\"Color.html#setHSLA\">Color ▸ setHSLA</a>"},{"title":"Color#subtract","link":"<a href=\"Color.html#subtract\">Color ▸ subtract</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":"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#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#flip","link":"<a href=\"Vector2.html#flip\">Vector2 ▸ flip</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":"Audio","link":"<a href=\"Audio.html\">Audio</a>"},{"title":"Audio.getNoteFrequency","link":"<a href=\"Audio.html#.getNoteFrequency\">Audio.getNoteFrequency ▸ undefined</a>"},{"title":"Audio.playAudioFile","link":"<a href=\"Audio.html#.playAudioFile\">Audio.playAudioFile ▸ undefined</a>"},{"title":"Audio.playSamples","link":"<a href=\"Audio.html#.playSamples\">Audio.playSamples ▸ undefined</a>"},{"title":"Audio.speak","link":"<a href=\"Audio.html#.speak\">Audio.speak ▸ undefined</a>"},{"title":"Audio.stopSpeech","link":"<a href=\"Audio.html#.stopSpeech\">Audio.stopSpeech ▸ undefined</a>"},{"title":"Audio.zzfx","link":"<a href=\"Audio.html#.zzfx\">Audio.zzfx ▸ undefined</a>"},{"title":"Audio.zzfxG","link":"<a href=\"Audio.html#.zzfxG\">Audio.zzfxG ▸ undefined</a>"},{"title":"Audio.zzfxM","link":"<a href=\"Audio.html#.zzfxM\">Audio.zzfxM ▸ undefined</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.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":"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":"engineCollideObjects","link":"<a href=\"global.html#engineCollideObjects\">engineCollideObjects</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":"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":"FPS","link":"<a href=\"global.html#FPS\">FPS</a>"},{"title":"frame","link":"<a href=\"global.html#frame\">frame</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>"}];
|
|
631
|
+
var options =
|
|
632
|
+
setupSearch(list, options)
|
|
633
|
+
</script>
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
</body>
|
|
646
|
+
|
|
647
|
+
</html>
|