littlejsengine 1.0.14 → 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/build.bat +5 -1
- 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 +1997 -744
- package/engine/engine.all.min.js +1 -1
- package/engine/engine.all.release.js +1743 -569
- package/engine/engine.js +107 -39
- package/engine/engineAudio.js +152 -34
- package/engine/{build.bat → engineBuild.bat} +10 -10
- package/engine/{buildSetup.bat → engineBuildSetup.bat} +0 -0
- package/engine/engineDebug.js +105 -32
- package/engine/engineDraw.js +137 -32
- package/engine/engineInput.js +111 -37
- package/engine/{engineMedal.js → engineMedals.js} +129 -56
- package/engine/engineObject.js +117 -67
- package/engine/engineParticles.js +282 -0
- package/engine/engineRelease.js +3 -9
- package/engine/engineSettings.js +190 -0
- package/engine/engineTileLayer.js +147 -44
- package/engine/engineUtilities.js +488 -0
- package/engine/engineWebGL.js +113 -74
- package/examples/breakout/game.js +1 -1
- package/examples/breakout/gameObjects.js +3 -3
- package/examples/breakout/index.html +3 -3
- package/examples/platformer/game.js +5 -7
- package/examples/platformer/gameEffects.js +7 -7
- package/examples/platformer/gameLevel.js +2 -2
- package/examples/platformer/gameObjects.js +4 -5
- package/examples/platformer/gamePlayer.js +3 -3
- package/examples/platformer/index.html +6 -6
- package/examples/puzzle/game.js +1 -2
- package/examples/puzzle/index.html +2 -2
- package/examples/stress/index.html +2 -8
- package/game.js +5 -11
- package/index.html +13 -13
- package/package.json +4 -4
- package/tiles.png +0 -0
- package/engine/engineConfig.js +0 -64
- package/engine/engineParticle.js +0 -199
- package/engine/engineUtil.js +0 -147
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/*
|
|
2
|
+
LittleJS Particle System
|
|
3
|
+
- Spawns particles with randomness from parameters
|
|
4
|
+
- Updates particle physics
|
|
5
|
+
- Fast particle rendering
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Particle Emitter - Spawns particles with the given settings
|
|
12
|
+
* @extends EngineObject
|
|
13
|
+
* @example
|
|
14
|
+
* // create a particle emitter
|
|
15
|
+
* let pos = vec2(2,3);
|
|
16
|
+
* let particleEmiter = new ParticleEmitter
|
|
17
|
+
* (
|
|
18
|
+
* pos, 1, 0, 500, PI, // pos, emitSize, emitTime, emitRate, emiteCone
|
|
19
|
+
* 0, vec2(16), // tileIndex, tileSize
|
|
20
|
+
* new Color, new Color(0,0,0), // colorStartA, colorStartB
|
|
21
|
+
* new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
|
|
22
|
+
* 2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
|
|
23
|
+
* .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
|
|
24
|
+
* .5, 1 // randomness, collide, additive, randomColorLinear, renderOrder
|
|
25
|
+
* );
|
|
26
|
+
*/
|
|
27
|
+
class ParticleEmitter extends EngineObject
|
|
28
|
+
{
|
|
29
|
+
/** Create a particle system with the given settings
|
|
30
|
+
* @param {Vector2} position - World space position of the emitter
|
|
31
|
+
* @param {Number} [emitSize=0] - World space size of the emitter (float for circle diameter, vec2 for rect)
|
|
32
|
+
* @param {Number} [emitTime=0] - How long to stay alive (0 is forever)
|
|
33
|
+
* @param {Number} [emitRate=100] - How many particles per second to spawn, does not emit if 0
|
|
34
|
+
* @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
|
|
35
|
+
* @param {Number} [tileIndex=-1] - Index into tile sheet, if <0 no texture is applied
|
|
36
|
+
* @param {Number} [tileSize=tileSizeDefault] - Tile size for particles
|
|
37
|
+
* @param {Color} [colorStartA=new Color(1,1,1)] - Color at start of life 1, randomized between start colors
|
|
38
|
+
* @param {Color} [colorStartB=new Color(1,1,1)] - Color at start of life 2, randomized between start colors
|
|
39
|
+
* @param {Color} [colorEndA=new Color(1,1,1,0)] - Color at end of life 1, randomized between end colors
|
|
40
|
+
* @param {Color} [colorEndB=new Color(1,1,1,0)] - Color at end of life 2, randomized between end colors
|
|
41
|
+
* @param {Number} [particleTime=.5] - How long particles live
|
|
42
|
+
* @param {Number} [sizeStart=.1] - How big are particles at start
|
|
43
|
+
* @param {Number} [sizeEnd=1] - How big are particles at end
|
|
44
|
+
* @param {Number} [speed=.1] - How fast are particles when spawned
|
|
45
|
+
* @param {Number} [angleSpeed=.05] - How fast are particles rotating
|
|
46
|
+
* @param {Number} [damping=1] - How much to dampen particle speed
|
|
47
|
+
* @param {Number} [angleDamping=1] - How much to dampen particle angular speed
|
|
48
|
+
* @param {Number} [gravityScale=0] - How much does gravity effect particles
|
|
49
|
+
* @param {Number} [particleConeAngle=PI] - Cone for start particle angle
|
|
50
|
+
* @param {Number} [fadeRate=.1] - How quick to fade in particles at start/end in percent of life
|
|
51
|
+
* @param {Number} [randomness=.2] - Apply extra randomness percent
|
|
52
|
+
* @param {Boolean} [collideTiles=0] - Do particles collide against tiles
|
|
53
|
+
* @param {Boolean} [additive=0] - Should particles use addtive blend
|
|
54
|
+
* @param {Boolean} [randomColorLinear=0] - Should color be randomized linearly or across each component
|
|
55
|
+
* @param {Number} [renderOrder=0] - Render order for particles (additive is above other stuff by default)
|
|
56
|
+
*/
|
|
57
|
+
constructor
|
|
58
|
+
(
|
|
59
|
+
pos,
|
|
60
|
+
emitSize = 0,
|
|
61
|
+
emitTime = 0,
|
|
62
|
+
emitRate = 100,
|
|
63
|
+
emitConeAngle = PI,
|
|
64
|
+
tileIndex = -1,
|
|
65
|
+
tileSize = tileSizeDefault,
|
|
66
|
+
colorStartA = new Color,
|
|
67
|
+
colorStartB = new Color,
|
|
68
|
+
colorEndA = new Color(1,1,1,0),
|
|
69
|
+
colorEndB = new Color(1,1,1,0),
|
|
70
|
+
particleTime = .5,
|
|
71
|
+
sizeStart = .1,
|
|
72
|
+
sizeEnd = 1,
|
|
73
|
+
speed = .1,
|
|
74
|
+
angleSpeed = .05,
|
|
75
|
+
damping = 1,
|
|
76
|
+
angleDamping = 1,
|
|
77
|
+
gravityScale = 0,
|
|
78
|
+
particleConeAngle = PI,
|
|
79
|
+
fadeRate = .1,
|
|
80
|
+
randomness = .2,
|
|
81
|
+
collideTiles,
|
|
82
|
+
additive,
|
|
83
|
+
randomColorLinear = 1,
|
|
84
|
+
renderOrder = additive ? 1e9 : 0
|
|
85
|
+
)
|
|
86
|
+
{
|
|
87
|
+
super(pos, new Vector2, tileIndex, tileSize, 0, undefined, renderOrder);
|
|
88
|
+
|
|
89
|
+
// emitter settings
|
|
90
|
+
/** @property {Number} - World space size of the emitter (float for circle diameter, vec2 for rect) */
|
|
91
|
+
this.emitSize = emitSize
|
|
92
|
+
/** @property {Number} - How long to stay alive (0 is forever) */
|
|
93
|
+
this.emitTime = emitTime;
|
|
94
|
+
/** @property {Number} - How many particles per second to spawn, does not emit if 0 */
|
|
95
|
+
this.emitRate = emitRate;
|
|
96
|
+
/** @property {Number} - Local angle to apply velocity to particles from emitter */
|
|
97
|
+
this.emitConeAngle = emitConeAngle;
|
|
98
|
+
|
|
99
|
+
// color settings
|
|
100
|
+
/** @property {Color} - Color at start of life 1, randomized between start colors */
|
|
101
|
+
this.colorStartA = colorStartA;
|
|
102
|
+
/** @property {Color} - Color at start of life 2, randomized between start colors */
|
|
103
|
+
this.colorStartB = colorStartB;
|
|
104
|
+
/** @property {Color} - Color at end of life 1, randomized between end colors */
|
|
105
|
+
this.colorEndA = colorEndA;
|
|
106
|
+
/** @property {Color} - Color at end of life 2, randomized between end colors */
|
|
107
|
+
this.colorEndB = colorEndB;
|
|
108
|
+
/** @property {Boolean} - Should color be randomized linearly or across each component */
|
|
109
|
+
this.randomColorLinear = randomColorLinear;
|
|
110
|
+
|
|
111
|
+
// particle settings
|
|
112
|
+
/** @property {Number} - How long particles live */
|
|
113
|
+
this.particleTime = particleTime;
|
|
114
|
+
/** @property {Number} - How big are particles at start */
|
|
115
|
+
this.sizeStart = sizeStart;
|
|
116
|
+
/** @property {Number} - How big are particles at end */
|
|
117
|
+
this.sizeEnd = sizeEnd;
|
|
118
|
+
/** @property {Number} - How fast are particles when spawned */
|
|
119
|
+
this.speed = speed;
|
|
120
|
+
/** @property {Number} - How fast are particles rotating */
|
|
121
|
+
this.angleSpeed = angleSpeed;
|
|
122
|
+
/** @property {Number} - How much to dampen particle speed */
|
|
123
|
+
this.damping = damping;
|
|
124
|
+
/** @property {Number} - How much to dampen particle angular speed */
|
|
125
|
+
this.angleDamping = angleDamping;
|
|
126
|
+
/** @property {Number} - How much does gravity effect particles */
|
|
127
|
+
this.gravityScale = gravityScale;
|
|
128
|
+
/** @property {Number} - Cone for start particle angle */
|
|
129
|
+
this.particleConeAngle = particleConeAngle;
|
|
130
|
+
/** @property {Number} - How quick to fade in particles at start/end in percent of life */
|
|
131
|
+
this.fadeRate = fadeRate;
|
|
132
|
+
/** @property {Number} - Apply extra randomness percent */
|
|
133
|
+
this.randomness = randomness;
|
|
134
|
+
/** @property {Number} - Do particles collide against tiles */
|
|
135
|
+
this.collideTiles = collideTiles;
|
|
136
|
+
/** @property {Number} - Should particles use addtive blend */
|
|
137
|
+
this.additive = additive;
|
|
138
|
+
/** @property {Number} - If set the partile is drawn as a trail, stretched in the drection of velocity */
|
|
139
|
+
this.trailScale = 0;
|
|
140
|
+
|
|
141
|
+
// internal variables
|
|
142
|
+
this.emitTimeBuffer = 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Update the emitter to spawn particles, called automatically by engine once each frame */
|
|
146
|
+
update()
|
|
147
|
+
{
|
|
148
|
+
// only do default update to apply parent transforms
|
|
149
|
+
this.parent && super.update();
|
|
150
|
+
|
|
151
|
+
// update emitter
|
|
152
|
+
if (!this.emitTime || this.getAliveTime() <= this.emitTime)
|
|
153
|
+
{
|
|
154
|
+
// emit particles
|
|
155
|
+
if (this.emitRate)
|
|
156
|
+
{
|
|
157
|
+
const rate = 1/this.emitRate;
|
|
158
|
+
for (this.emitTimeBuffer += timeDelta; this.emitTimeBuffer > 0; this.emitTimeBuffer -= rate)
|
|
159
|
+
this.emitParticle();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else
|
|
163
|
+
this.destroy();
|
|
164
|
+
|
|
165
|
+
debugParticles && debugRect(this.pos, vec2(this.emitSize), '#0f0', 0, this.angle);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Spawn one particle
|
|
169
|
+
* @return {Particle} */
|
|
170
|
+
emitParticle()
|
|
171
|
+
{
|
|
172
|
+
// spawn a particle
|
|
173
|
+
const pos = this.emitSize.x != undefined ? // check if vec2 was used for size
|
|
174
|
+
(new Vector2(rand(-.5,.5), rand(-.5,.5))).multiply(this.emitSize).rotate(this.angle) // box emitter
|
|
175
|
+
: randInCircle(this.emitSize * .5); // circle emitter
|
|
176
|
+
const particle = new Particle(this.pos.add(pos), this.tileIndex, this.tileSize,
|
|
177
|
+
this.angle + rand(this.particleConeAngle, -this.particleConeAngle));
|
|
178
|
+
|
|
179
|
+
// randomness scales each paremeter by a percentage
|
|
180
|
+
const randomness = this.randomness;
|
|
181
|
+
const randomizeScale = (v)=> v + v*rand(randomness, -randomness);
|
|
182
|
+
|
|
183
|
+
// randomize particle settings
|
|
184
|
+
const particleTime = randomizeScale(this.particleTime);
|
|
185
|
+
const sizeStart = randomizeScale(this.sizeStart);
|
|
186
|
+
const sizeEnd = randomizeScale(this.sizeEnd);
|
|
187
|
+
const speed = randomizeScale(this.speed);
|
|
188
|
+
const angleSpeed = randomizeScale(this.angleSpeed) * randSign();
|
|
189
|
+
const coneAngle = rand(this.emitConeAngle, -this.emitConeAngle);
|
|
190
|
+
const colorStart = randColor(this.colorStartA, this.colorStartB, this.randomColorLinear);
|
|
191
|
+
const colorEnd = randColor(this.colorEndA, this.colorEndB, this.randomColorLinear);
|
|
192
|
+
|
|
193
|
+
// build particle settings
|
|
194
|
+
particle.colorStart = colorStart;
|
|
195
|
+
particle.colorEndDelta = colorEnd.subtract(colorStart);
|
|
196
|
+
particle.velocity = (new Vector2).setAngle(this.angle + coneAngle, speed);
|
|
197
|
+
particle.angleVelocity = angleSpeed;
|
|
198
|
+
particle.lifeTime = particleTime;
|
|
199
|
+
particle.sizeStart = sizeStart;
|
|
200
|
+
particle.sizeEndDelta = sizeEnd - sizeStart;
|
|
201
|
+
particle.fadeRate = this.fadeRate;
|
|
202
|
+
particle.damping = this.damping;
|
|
203
|
+
particle.angleDamping = this.angleDamping;
|
|
204
|
+
particle.elasticity = this.elasticity;
|
|
205
|
+
particle.friction = this.friction;
|
|
206
|
+
particle.gravityScale = this.gravityScale;
|
|
207
|
+
particle.collideTiles = this.collideTiles;
|
|
208
|
+
particle.additive = this.additive;
|
|
209
|
+
particle.renderOrder = this.renderOrder;
|
|
210
|
+
particle.trailScale = this.trailScale;
|
|
211
|
+
particle.mirror = rand()<.5;
|
|
212
|
+
|
|
213
|
+
// setup callbacks for particles
|
|
214
|
+
particle.destroyCallback = this.particleDestroyCallback;
|
|
215
|
+
this.particleCreateCallback && this.particleCreateCallback(particle);
|
|
216
|
+
|
|
217
|
+
// return the newly created particle
|
|
218
|
+
return particle;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Particle emitters are not rendered, only the particles are
|
|
222
|
+
render() {}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
226
|
+
/**
|
|
227
|
+
* Particle Object - Created automatically by Particle Emitters
|
|
228
|
+
* @extends EngineObject
|
|
229
|
+
*/
|
|
230
|
+
class Particle extends EngineObject
|
|
231
|
+
{
|
|
232
|
+
/**
|
|
233
|
+
* Create a particle with the given settings
|
|
234
|
+
* @param {Vector2} position - World space position of the particle
|
|
235
|
+
* @param {Number} [tileIndex=-1] - Tile to use to render, untextured if -1
|
|
236
|
+
* @param {Vector2} [tileSize=tileSizeDefault] - Size of tile in source pixels
|
|
237
|
+
* @param {Number} [angle=0] - Angle to rotate the particle
|
|
238
|
+
*/
|
|
239
|
+
constructor(pos, tileIndex, tileSize, angle) { super(pos, new Vector2, tileIndex, tileSize, angle); }
|
|
240
|
+
|
|
241
|
+
/** Render the particle, automatically called each frame, sorted by renderOrder */
|
|
242
|
+
render()
|
|
243
|
+
{
|
|
244
|
+
// modulate size and color
|
|
245
|
+
const p = min((time - this.spawnTime) / this.lifeTime, 1);
|
|
246
|
+
const radius = this.sizeStart + p * this.sizeEndDelta;
|
|
247
|
+
const size = new Vector2(radius, radius);
|
|
248
|
+
const fadeRate = this.fadeRate/2;
|
|
249
|
+
const color = new Color(
|
|
250
|
+
this.colorStart.r + p * this.colorEndDelta.r,
|
|
251
|
+
this.colorStart.g + p * this.colorEndDelta.g,
|
|
252
|
+
this.colorStart.b + p * this.colorEndDelta.b,
|
|
253
|
+
(this.colorStart.a + p * this.colorEndDelta.a) *
|
|
254
|
+
(p < fadeRate ? p/fadeRate : p > 1-fadeRate ? (1-p)/fadeRate : 1)); // fade alpha
|
|
255
|
+
|
|
256
|
+
// draw the particle
|
|
257
|
+
this.additive && setBlendMode(1);
|
|
258
|
+
if (this.trailScale)
|
|
259
|
+
{
|
|
260
|
+
// trail style particles
|
|
261
|
+
const speed = this.velocity.length();
|
|
262
|
+
const direction = this.velocity.scale(1/speed);
|
|
263
|
+
const trailLength = speed * this.trailScale;
|
|
264
|
+
size.y = max(size.x, trailLength);
|
|
265
|
+
this.angle = direction.angle();
|
|
266
|
+
drawTile(this.pos.add(direction.multiply(vec2(0,-trailLength/2))), size, this.tileIndex, this.tileSize, color, this.angle, this.mirror);
|
|
267
|
+
}
|
|
268
|
+
else
|
|
269
|
+
drawTile(this.pos, size, this.tileIndex, this.tileSize, color, this.angle, this.mirror);
|
|
270
|
+
this.additive && setBlendMode();
|
|
271
|
+
debugParticles && debugRect(this.pos, size, '#f005', 0, this.angle);
|
|
272
|
+
|
|
273
|
+
if (p == 1)
|
|
274
|
+
{
|
|
275
|
+
// destroy particle when it's time runs out
|
|
276
|
+
this.color = color;
|
|
277
|
+
this.size = size;
|
|
278
|
+
this.destroyCallback && this.destroyCallback(this);
|
|
279
|
+
this.destroyed = 1;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
package/engine/engineRelease.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
|
-
LittleJS -
|
|
3
|
-
|
|
2
|
+
LittleJS - Release build include file
|
|
3
|
+
- This file is used for release builds in place of engineDebug.js
|
|
4
|
+
- Debug functionality will be disabled to lower size and increase performance
|
|
4
5
|
*/
|
|
5
|
-
/*
|
|
6
|
-
LittleJS - Build include file
|
|
7
|
-
By Frank Force 2021
|
|
8
|
-
|
|
9
|
-
This file is used for release builds in place of engineDebug.js
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
6
|
|
|
13
7
|
'use strict';
|
|
14
8
|
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LittleJS Engine Settings
|
|
3
|
+
* @namespace Settings
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
9
|
+
// Display settings
|
|
10
|
+
|
|
11
|
+
/** The max size of the canvas, centered if window is larger
|
|
12
|
+
* @type {Vector2}
|
|
13
|
+
* @default
|
|
14
|
+
* @memberof Settings */
|
|
15
|
+
const maxSize = vec2(1920, 1200);
|
|
16
|
+
|
|
17
|
+
/** Fixed size of the canvas, if enabled cavnvas size never changes
|
|
18
|
+
* @type {Vector2}
|
|
19
|
+
* @default
|
|
20
|
+
* @memberof Settings */
|
|
21
|
+
let fixedSize = vec2();
|
|
22
|
+
|
|
23
|
+
/** Default font used for text rendering
|
|
24
|
+
* @default
|
|
25
|
+
* @memberof Settings */
|
|
26
|
+
let fontDefault = 'arial';
|
|
27
|
+
|
|
28
|
+
/** Use crisp pixels for pixel art if true
|
|
29
|
+
* @default
|
|
30
|
+
* @memberof Settings */
|
|
31
|
+
let pixelated = 1;
|
|
32
|
+
|
|
33
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
34
|
+
// Tile sheet settings
|
|
35
|
+
|
|
36
|
+
/** Default size of tiles in pixels
|
|
37
|
+
* @type {Vector2}
|
|
38
|
+
* @default
|
|
39
|
+
* @memberof Settings */
|
|
40
|
+
const tileSizeDefault = vec2(16);
|
|
41
|
+
|
|
42
|
+
/** Prevent tile bleeding from neighbors in pixels
|
|
43
|
+
* @default
|
|
44
|
+
* @memberof Settings */
|
|
45
|
+
const tileBleedShrinkFix = .3;
|
|
46
|
+
|
|
47
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
48
|
+
// Object settings
|
|
49
|
+
|
|
50
|
+
/** Default size of objects
|
|
51
|
+
* @type {Vector2}
|
|
52
|
+
* @default
|
|
53
|
+
* @memberof Settings */
|
|
54
|
+
const objectDefaultSize = vec2(1);
|
|
55
|
+
|
|
56
|
+
/** Default object mass for collison calcuations (how heavy objects are)
|
|
57
|
+
* @default
|
|
58
|
+
* @memberof Settings */
|
|
59
|
+
const objectDefaultMass = 1;
|
|
60
|
+
|
|
61
|
+
/** How much to slow velocity by each frame (0-1)
|
|
62
|
+
* @default
|
|
63
|
+
* @memberof Settings */
|
|
64
|
+
const objectDefaultDamping = .99;
|
|
65
|
+
|
|
66
|
+
/** How much to slow angular velocity each frame (0-1)
|
|
67
|
+
* @default
|
|
68
|
+
* @memberof Settings */
|
|
69
|
+
const objectDefaultAngleDamping = .99;
|
|
70
|
+
|
|
71
|
+
/** How much to bounce when a collision occurs (0-1)
|
|
72
|
+
* @default
|
|
73
|
+
* @memberof Settings */
|
|
74
|
+
const objectDefaultElasticity = 0;
|
|
75
|
+
|
|
76
|
+
/** How much to slow when touching (0-1)
|
|
77
|
+
* @default
|
|
78
|
+
* @memberof Settings */
|
|
79
|
+
const objectDefaultFriction = .8;
|
|
80
|
+
|
|
81
|
+
/** Clamp max speed to avoid fast objects missing collisions
|
|
82
|
+
* @default
|
|
83
|
+
* @memberof Settings */
|
|
84
|
+
const objectMaxSpeed = 1;
|
|
85
|
+
|
|
86
|
+
/** How much gravity to apply to objects along the Y axis, negative is down
|
|
87
|
+
* @default
|
|
88
|
+
* @memberof Settings */
|
|
89
|
+
let gravity = 0;
|
|
90
|
+
|
|
91
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
92
|
+
// Camera settings
|
|
93
|
+
|
|
94
|
+
/** Position of camera in world space
|
|
95
|
+
* @type {Vector2}
|
|
96
|
+
* @default
|
|
97
|
+
* @memberof Settings */
|
|
98
|
+
let cameraPos = vec2();
|
|
99
|
+
|
|
100
|
+
/** Scale of camera in world space
|
|
101
|
+
* @default
|
|
102
|
+
* @memberof Settings */
|
|
103
|
+
let cameraScale = max(tileSizeDefault.x, tileSizeDefault.y);
|
|
104
|
+
|
|
105
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
106
|
+
// WebGL settings
|
|
107
|
+
|
|
108
|
+
/** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
|
|
109
|
+
* @default
|
|
110
|
+
* @memberof Settings */
|
|
111
|
+
const glEnable = 1;
|
|
112
|
+
|
|
113
|
+
/** Fixes slow rendering in some browsers by not compositing the WebGL canvas
|
|
114
|
+
* @default
|
|
115
|
+
* @memberof Settings */
|
|
116
|
+
let glOverlay = 1;
|
|
117
|
+
|
|
118
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
119
|
+
// Input settings
|
|
120
|
+
|
|
121
|
+
/** Should gamepads be allowed
|
|
122
|
+
* @default
|
|
123
|
+
* @memberof Settings */
|
|
124
|
+
const gamepadsEnable = 1;
|
|
125
|
+
|
|
126
|
+
/** If true, the dpad input is also routed to the left analog stick (for better accessability)
|
|
127
|
+
* @default
|
|
128
|
+
* @memberof Settings */
|
|
129
|
+
const gamepadDirectionEmulateStick = 1;
|
|
130
|
+
|
|
131
|
+
/** If true touch input is routed to mouse functions
|
|
132
|
+
* @default
|
|
133
|
+
* @memberof Settings */
|
|
134
|
+
const inputTouchEnable = 1;
|
|
135
|
+
|
|
136
|
+
/** If true the WASD keys are also routed to the direction keys (for better accessability)
|
|
137
|
+
* @default
|
|
138
|
+
* @memberof Settings */
|
|
139
|
+
const inputWASDEmulateDirection = 1;
|
|
140
|
+
|
|
141
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
142
|
+
// Audio settings
|
|
143
|
+
|
|
144
|
+
/** Volume scale to apply to all sound, music and speech
|
|
145
|
+
* @default
|
|
146
|
+
* @memberof Settings */
|
|
147
|
+
let soundVolume = .5;
|
|
148
|
+
|
|
149
|
+
/** All audio code can be disabled and removed from build
|
|
150
|
+
* @default
|
|
151
|
+
* @memberof Settings */
|
|
152
|
+
const soundEnable = 1;
|
|
153
|
+
|
|
154
|
+
/** Default range where sound no longer plays
|
|
155
|
+
* @default
|
|
156
|
+
* @memberof Settings */
|
|
157
|
+
const soundDefaultRange = 30;
|
|
158
|
+
|
|
159
|
+
/** Default range percent to start tapering off sound (0-1)
|
|
160
|
+
* @default
|
|
161
|
+
* @memberof Settings */
|
|
162
|
+
const soundDefaultTaper = .7;
|
|
163
|
+
|
|
164
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
165
|
+
// Medals settings
|
|
166
|
+
|
|
167
|
+
/** How long to show medals for in seconds
|
|
168
|
+
* @default
|
|
169
|
+
* @memberof Settings */
|
|
170
|
+
const medalDisplayTime = 5;
|
|
171
|
+
|
|
172
|
+
/** How quickly to slide on/off medals in seconds
|
|
173
|
+
* @default
|
|
174
|
+
* @memberof Settings */
|
|
175
|
+
const medalDisplaySlideTime = .5;
|
|
176
|
+
|
|
177
|
+
/** Width of medal display
|
|
178
|
+
* @default
|
|
179
|
+
* @memberof Settings */
|
|
180
|
+
const medalDisplayWidth = 640;
|
|
181
|
+
|
|
182
|
+
/** Height of medal display
|
|
183
|
+
* @default
|
|
184
|
+
* @memberof Settings */
|
|
185
|
+
const medalDisplayHeight = 99;
|
|
186
|
+
|
|
187
|
+
/** Size of icon in medal display
|
|
188
|
+
* @default
|
|
189
|
+
* @memberof Settings */
|
|
190
|
+
const medalDisplayIconSize = 80;
|