littlejsengine 1.11.9 → 1.11.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/littlejs.d.ts +485 -492
- package/dist/littlejs.esm.js +548 -529
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +546 -525
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +502 -484
- package/examples/htmlMenu/game.js +11 -1
- package/examples/htmlMenu/index.html +1 -10
- package/examples/module/game.js +2 -2
- package/examples/shorts/base.html +1 -1
- package/examples/starter/build/index.html +2 -0
- package/examples/starter/build/index.js +1 -0
- package/examples/starter/build/tiles.png +0 -0
- package/examples/starter/build.js +13 -3
- package/examples/starter/game.js +8 -1
- package/examples/starter/game.zip +0 -0
- package/examples/typescript/build/dist/littlejs.esm.js +4834 -0
- package/examples/typescript/build/examples/typescript/build.js +24 -0
- package/examples/typescript/build/examples/typescript/game.js +102 -0
- package/examples/typescript/build.bat +5 -0
- package/examples/typescript/build.js +33 -0
- package/examples/typescript/game.js +102 -0
- package/examples/typescript/game.ts +134 -0
- package/examples/typescript/index.html +10 -0
- package/examples/typescript/tiles.png +0 -0
- package/examples/typescript/tsconfig.json +8 -0
- package/package.json +1 -1
- package/plugins/newgrounds.js +44 -35
- package/plugins/postProcess.js +18 -4
- package/plugins/uiSystem.js +196 -30
- package/src/engine.js +21 -20
- package/src/engineAudio.js +59 -59
- package/src/engineDebug.js +44 -41
- package/src/engineDraw.js +58 -58
- package/src/engineExport.js +2 -4
- package/src/engineInput.js +40 -35
- package/src/engineMedals.js +21 -11
- package/src/engineObject.js +42 -35
- package/src/engineParticles.js +10 -10
- package/src/engineSettings.js +77 -82
- package/src/engineTileLayer.js +21 -21
- package/src/engineUtilities.js +150 -150
- package/src/engineWebGL.js +3 -3
package/src/engineSettings.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
let cameraPos = vec2();
|
|
17
17
|
|
|
18
18
|
/** Scale of camera in world space
|
|
19
|
-
* @type {
|
|
19
|
+
* @type {number}
|
|
20
20
|
* @default
|
|
21
21
|
* @memberof Settings */
|
|
22
22
|
let cameraScale = 32;
|
|
@@ -38,31 +38,34 @@ let canvasMaxSize = vec2(1920, 1080);
|
|
|
38
38
|
let canvasFixedSize = vec2();
|
|
39
39
|
|
|
40
40
|
/** Use nearest neighbor scaling algorithm for canvas for more pixelated look
|
|
41
|
-
*
|
|
41
|
+
* - Must be set before startup to take effect
|
|
42
|
+
* - If enabled sets css image-rendering:pixelated
|
|
43
|
+
* @type {boolean}
|
|
42
44
|
* @default
|
|
43
45
|
* @memberof Settings */
|
|
44
46
|
let canvasPixelated = true;
|
|
45
47
|
|
|
46
48
|
/** Disables texture filtering for crisper pixel art
|
|
47
|
-
* @type {
|
|
49
|
+
* @type {boolean}
|
|
48
50
|
* @default
|
|
49
51
|
* @memberof Settings */
|
|
50
52
|
let tilesPixelated = true;
|
|
51
53
|
|
|
52
54
|
/** Default font used for text rendering
|
|
53
|
-
* @type {
|
|
55
|
+
* @type {string}
|
|
54
56
|
* @default
|
|
55
57
|
* @memberof Settings */
|
|
56
58
|
let fontDefault = 'arial';
|
|
57
59
|
|
|
58
60
|
/** Enable to show the LittleJS splash screen be shown on startup
|
|
59
|
-
* @type {
|
|
61
|
+
* @type {boolean}
|
|
60
62
|
* @default
|
|
61
63
|
* @memberof Settings */
|
|
62
64
|
let showSplashScreen = false;
|
|
63
65
|
|
|
64
66
|
/** Disables all rendering, audio, and input for servers
|
|
65
|
-
*
|
|
67
|
+
* - Must be set before startup to take effect
|
|
68
|
+
* @type {boolean}
|
|
66
69
|
* @default
|
|
67
70
|
* @memberof Settings */
|
|
68
71
|
let headlessMode = false;
|
|
@@ -71,13 +74,15 @@ let headlessMode = false;
|
|
|
71
74
|
// WebGL settings
|
|
72
75
|
|
|
73
76
|
/** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
|
|
74
|
-
*
|
|
77
|
+
* - Must be set before startup to take effect
|
|
78
|
+
* @type {boolean}
|
|
75
79
|
* @default
|
|
76
80
|
* @memberof Settings */
|
|
77
81
|
let glEnable = true;
|
|
78
82
|
|
|
79
83
|
/** Fixes slow rendering in some browsers by not compositing the WebGL canvas
|
|
80
|
-
*
|
|
84
|
+
* - Must be set before startup to take effect
|
|
85
|
+
* @type {boolean}
|
|
81
86
|
* @default
|
|
82
87
|
* @memberof Settings */
|
|
83
88
|
let glOverlay = true;
|
|
@@ -92,7 +97,7 @@ let glOverlay = true;
|
|
|
92
97
|
let tileSizeDefault = vec2(16);
|
|
93
98
|
|
|
94
99
|
/** How many pixels smaller to draw tiles to prevent bleeding from neighbors
|
|
95
|
-
* @type {
|
|
100
|
+
* @type {number}
|
|
96
101
|
* @default
|
|
97
102
|
* @memberof Settings */
|
|
98
103
|
let tileFixBleedScale = 0;
|
|
@@ -101,55 +106,55 @@ let tileFixBleedScale = 0;
|
|
|
101
106
|
// Object settings
|
|
102
107
|
|
|
103
108
|
/** Enable physics solver for collisions between objects
|
|
104
|
-
* @type {
|
|
109
|
+
* @type {boolean}
|
|
105
110
|
* @default
|
|
106
111
|
* @memberof Settings */
|
|
107
112
|
let enablePhysicsSolver = true;
|
|
108
113
|
|
|
109
114
|
/** Default object mass for collision calculations (how heavy objects are)
|
|
110
|
-
* @type {
|
|
115
|
+
* @type {number}
|
|
111
116
|
* @default
|
|
112
117
|
* @memberof Settings */
|
|
113
118
|
let objectDefaultMass = 1;
|
|
114
119
|
|
|
115
120
|
/** How much to slow velocity by each frame (0-1)
|
|
116
|
-
* @type {
|
|
121
|
+
* @type {number}
|
|
117
122
|
* @default
|
|
118
123
|
* @memberof Settings */
|
|
119
124
|
let objectDefaultDamping = 1;
|
|
120
125
|
|
|
121
126
|
/** How much to slow angular velocity each frame (0-1)
|
|
122
|
-
* @type {
|
|
127
|
+
* @type {number}
|
|
123
128
|
* @default
|
|
124
129
|
* @memberof Settings */
|
|
125
130
|
let objectDefaultAngleDamping = 1;
|
|
126
131
|
|
|
127
132
|
/** How much to bounce when a collision occurs (0-1)
|
|
128
|
-
* @type {
|
|
133
|
+
* @type {number}
|
|
129
134
|
* @default
|
|
130
135
|
* @memberof Settings */
|
|
131
136
|
let objectDefaultElasticity = 0;
|
|
132
137
|
|
|
133
138
|
/** How much to slow when touching (0-1)
|
|
134
|
-
* @type {
|
|
139
|
+
* @type {number}
|
|
135
140
|
* @default
|
|
136
141
|
* @memberof Settings */
|
|
137
142
|
let objectDefaultFriction = .8;
|
|
138
143
|
|
|
139
144
|
/** Clamp max speed to avoid fast objects missing collisions
|
|
140
|
-
* @type {
|
|
145
|
+
* @type {number}
|
|
141
146
|
* @default
|
|
142
147
|
* @memberof Settings */
|
|
143
148
|
let objectMaxSpeed = 1;
|
|
144
149
|
|
|
145
150
|
/** How much gravity to apply to objects along the Y axis, negative is down
|
|
146
|
-
* @type {
|
|
151
|
+
* @type {number}
|
|
147
152
|
* @default
|
|
148
153
|
* @memberof Settings */
|
|
149
154
|
let gravity = 0;
|
|
150
155
|
|
|
151
156
|
/** Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)
|
|
152
|
-
* @type {
|
|
157
|
+
* @type {number}
|
|
153
158
|
* @default
|
|
154
159
|
* @memberof Settings */
|
|
155
160
|
let particleEmitRateScale = 1;
|
|
@@ -158,58 +163,59 @@ let particleEmitRateScale = 1;
|
|
|
158
163
|
// Input settings
|
|
159
164
|
|
|
160
165
|
/** Should gamepads be allowed
|
|
161
|
-
* @type {
|
|
166
|
+
* @type {boolean}
|
|
162
167
|
* @default
|
|
163
168
|
* @memberof Settings */
|
|
164
169
|
let gamepadsEnable = true;
|
|
165
170
|
|
|
166
171
|
/** If true, the dpad input is also routed to the left analog stick (for better accessability)
|
|
167
|
-
* @type {
|
|
172
|
+
* @type {boolean}
|
|
168
173
|
* @default
|
|
169
174
|
* @memberof Settings */
|
|
170
175
|
let gamepadDirectionEmulateStick = true;
|
|
171
176
|
|
|
172
177
|
/** If true the WASD keys are also routed to the direction keys (for better accessability)
|
|
173
|
-
* @type {
|
|
178
|
+
* @type {boolean}
|
|
174
179
|
* @default
|
|
175
180
|
* @memberof Settings */
|
|
176
181
|
let inputWASDEmulateDirection = true;
|
|
177
182
|
|
|
178
183
|
/** True if touch input is enabled for mobile devices
|
|
179
184
|
* - Touch events will be routed to mouse events
|
|
180
|
-
*
|
|
185
|
+
* - Must be set before startup to take effect
|
|
186
|
+
* @type {boolean}
|
|
181
187
|
* @default
|
|
182
188
|
* @memberof Settings */
|
|
183
189
|
let touchInputEnable = true;
|
|
184
190
|
|
|
185
191
|
/** True if touch gamepad should appear on mobile devices
|
|
186
192
|
* - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
187
|
-
* - Must be set
|
|
188
|
-
* @type {
|
|
193
|
+
* - Must be set before startup to take effect
|
|
194
|
+
* @type {boolean}
|
|
189
195
|
* @default
|
|
190
196
|
* @memberof Settings */
|
|
191
197
|
let touchGamepadEnable = false;
|
|
192
198
|
|
|
193
199
|
/** True if touch gamepad should be analog stick or false to use if 8 way dpad
|
|
194
|
-
* @type {
|
|
200
|
+
* @type {boolean}
|
|
195
201
|
* @default
|
|
196
202
|
* @memberof Settings */
|
|
197
203
|
let touchGamepadAnalog = true;
|
|
198
204
|
|
|
199
205
|
/** Size of virtual gamepad for touch devices in pixels
|
|
200
|
-
* @type {
|
|
206
|
+
* @type {number}
|
|
201
207
|
* @default
|
|
202
208
|
* @memberof Settings */
|
|
203
209
|
let touchGamepadSize = 99;
|
|
204
210
|
|
|
205
211
|
/** Transparency of touch gamepad overlay
|
|
206
|
-
* @type {
|
|
212
|
+
* @type {number}
|
|
207
213
|
* @default
|
|
208
214
|
* @memberof Settings */
|
|
209
215
|
let touchGamepadAlpha = .3;
|
|
210
216
|
|
|
211
217
|
/** Allow vibration hardware if it exists
|
|
212
|
-
* @type {
|
|
218
|
+
* @type {boolean}
|
|
213
219
|
* @default
|
|
214
220
|
* @memberof Settings */
|
|
215
221
|
let vibrateEnable = true;
|
|
@@ -218,25 +224,25 @@ let vibrateEnable = true;
|
|
|
218
224
|
// Audio settings
|
|
219
225
|
|
|
220
226
|
/** All audio code can be disabled and removed from build
|
|
221
|
-
* @type {
|
|
227
|
+
* @type {boolean}
|
|
222
228
|
* @default
|
|
223
229
|
* @memberof Settings */
|
|
224
230
|
let soundEnable = true;
|
|
225
231
|
|
|
226
232
|
/** Volume scale to apply to all sound, music and speech
|
|
227
|
-
* @type {
|
|
233
|
+
* @type {number}
|
|
228
234
|
* @default
|
|
229
235
|
* @memberof Settings */
|
|
230
236
|
let soundVolume = .3;
|
|
231
237
|
|
|
232
238
|
/** Default range where sound no longer plays
|
|
233
|
-
* @type {
|
|
239
|
+
* @type {number}
|
|
234
240
|
* @default
|
|
235
241
|
* @memberof Settings */
|
|
236
242
|
let soundDefaultRange = 40;
|
|
237
243
|
|
|
238
244
|
/** Default range percent to start tapering off sound (0-1)
|
|
239
|
-
* @type {
|
|
245
|
+
* @type {number}
|
|
240
246
|
* @default
|
|
241
247
|
* @memberof Settings */
|
|
242
248
|
let soundDefaultTaper = .7;
|
|
@@ -245,13 +251,13 @@ let soundDefaultTaper = .7;
|
|
|
245
251
|
// Medals settings
|
|
246
252
|
|
|
247
253
|
/** How long to show medals for in seconds
|
|
248
|
-
* @type {
|
|
254
|
+
* @type {number}
|
|
249
255
|
* @default
|
|
250
256
|
* @memberof Settings */
|
|
251
257
|
let medalDisplayTime = 5;
|
|
252
258
|
|
|
253
259
|
/** How quickly to slide on/off medals in seconds
|
|
254
|
-
* @type {
|
|
260
|
+
* @type {number}
|
|
255
261
|
* @default
|
|
256
262
|
* @memberof Settings */
|
|
257
263
|
let medalDisplaySlideTime = .5;
|
|
@@ -262,14 +268,8 @@ let medalDisplaySlideTime = .5;
|
|
|
262
268
|
* @memberof Settings */
|
|
263
269
|
let medalDisplaySize = vec2(640, 80);
|
|
264
270
|
|
|
265
|
-
/** Size of icon in medal display
|
|
266
|
-
* @type {Number}
|
|
267
|
-
* @default
|
|
268
|
-
* @memberof Settings */
|
|
269
|
-
let medalDisplayIconSize = 50;
|
|
270
|
-
|
|
271
271
|
/** Set to stop medals from being unlockable (like if cheats are enabled)
|
|
272
|
-
* @type {
|
|
272
|
+
* @type {boolean}
|
|
273
273
|
* @default
|
|
274
274
|
* @memberof Settings */
|
|
275
275
|
let medalsPreventUnlock = false;
|
|
@@ -283,7 +283,7 @@ let medalsPreventUnlock = false;
|
|
|
283
283
|
function setCameraPos(pos) { cameraPos = pos; }
|
|
284
284
|
|
|
285
285
|
/** Set scale of camera in world space
|
|
286
|
-
* @param {
|
|
286
|
+
* @param {number} scale
|
|
287
287
|
* @memberof Settings */
|
|
288
288
|
function setCameraScale(scale) { cameraScale = scale; }
|
|
289
289
|
|
|
@@ -298,37 +298,37 @@ function setCanvasMaxSize(size) { canvasMaxSize = size; }
|
|
|
298
298
|
function setCanvasFixedSize(size) { canvasFixedSize = size; }
|
|
299
299
|
|
|
300
300
|
/** Use nearest neighbor scaling algorithm for canvas for more pixelated look
|
|
301
|
-
* @param {
|
|
301
|
+
* @param {boolean} pixelated
|
|
302
302
|
* @memberof Settings */
|
|
303
303
|
function setCanvasPixelated(pixelated) { canvasPixelated = pixelated; }
|
|
304
304
|
|
|
305
305
|
/** Disables texture filtering for crisper pixel art
|
|
306
|
-
* @param {
|
|
306
|
+
* @param {boolean} pixelated
|
|
307
307
|
* @memberof Settings */
|
|
308
308
|
function setTilesPixelated(pixelated) { tilesPixelated = pixelated; }
|
|
309
309
|
|
|
310
310
|
/** Set default font used for text rendering
|
|
311
|
-
* @param {
|
|
311
|
+
* @param {string} font
|
|
312
312
|
* @memberof Settings */
|
|
313
313
|
function setFontDefault(font) { fontDefault = font; }
|
|
314
314
|
|
|
315
315
|
/** Set if the LittleJS splash screen be shown on startup
|
|
316
|
-
* @param {
|
|
316
|
+
* @param {boolean} show
|
|
317
317
|
* @memberof Settings */
|
|
318
318
|
function setShowSplashScreen(show) { showSplashScreen = show; }
|
|
319
319
|
|
|
320
320
|
/** Set to disable rendering, audio, and input for servers
|
|
321
|
-
* @param {
|
|
321
|
+
* @param {boolean} headless
|
|
322
322
|
* @memberof Settings */
|
|
323
323
|
function setHeadlessMode(headless) { headlessMode = headless; }
|
|
324
324
|
|
|
325
325
|
/** Set if webgl rendering is enabled
|
|
326
|
-
* @param {
|
|
326
|
+
* @param {boolean} enable
|
|
327
327
|
* @memberof Settings */
|
|
328
328
|
function setGlEnable(enable) { glEnable = enable; }
|
|
329
329
|
|
|
330
330
|
/** Set to not composite the WebGL canvas
|
|
331
|
-
* @param {
|
|
331
|
+
* @param {boolean} overlay
|
|
332
332
|
* @memberof Settings */
|
|
333
333
|
function setGlOverlay(overlay) { glOverlay = overlay; }
|
|
334
334
|
|
|
@@ -338,107 +338,107 @@ function setGlOverlay(overlay) { glOverlay = overlay; }
|
|
|
338
338
|
function setTileSizeDefault(size) { tileSizeDefault = size; }
|
|
339
339
|
|
|
340
340
|
/** Set to prevent tile bleeding from neighbors in pixels
|
|
341
|
-
* @param {
|
|
341
|
+
* @param {number} scale
|
|
342
342
|
* @memberof Settings */
|
|
343
343
|
function setTileFixBleedScale(scale) { tileFixBleedScale = scale; }
|
|
344
344
|
|
|
345
345
|
/** Set if collisions between objects are enabled
|
|
346
|
-
* @param {
|
|
346
|
+
* @param {boolean} enable
|
|
347
347
|
* @memberof Settings */
|
|
348
348
|
function setEnablePhysicsSolver(enable) { enablePhysicsSolver = enable; }
|
|
349
349
|
|
|
350
350
|
/** Set default object mass for collision calculations
|
|
351
|
-
* @param {
|
|
351
|
+
* @param {number} mass
|
|
352
352
|
* @memberof Settings */
|
|
353
353
|
function setObjectDefaultMass(mass) { objectDefaultMass = mass; }
|
|
354
354
|
|
|
355
355
|
/** Set how much to slow velocity by each frame
|
|
356
|
-
* @param {
|
|
356
|
+
* @param {number} damp
|
|
357
357
|
* @memberof Settings */
|
|
358
358
|
function setObjectDefaultDamping(damp) { objectDefaultDamping = damp; }
|
|
359
359
|
|
|
360
360
|
/** Set how much to slow angular velocity each frame
|
|
361
|
-
* @param {
|
|
361
|
+
* @param {number} damp
|
|
362
362
|
* @memberof Settings */
|
|
363
363
|
function setObjectDefaultAngleDamping(damp) { objectDefaultAngleDamping = damp; }
|
|
364
364
|
|
|
365
365
|
/** Set how much to bounce when a collision occur
|
|
366
|
-
* @param {
|
|
366
|
+
* @param {number} elasticity
|
|
367
367
|
* @memberof Settings */
|
|
368
368
|
function setObjectDefaultElasticity(elasticity) { objectDefaultElasticity = elasticity; }
|
|
369
369
|
|
|
370
370
|
/** Set how much to slow when touching
|
|
371
|
-
* @param {
|
|
371
|
+
* @param {number} friction
|
|
372
372
|
* @memberof Settings */
|
|
373
373
|
function setObjectDefaultFriction(friction) { objectDefaultFriction = friction; }
|
|
374
374
|
|
|
375
375
|
/** Set max speed to avoid fast objects missing collisions
|
|
376
|
-
* @param {
|
|
376
|
+
* @param {number} speed
|
|
377
377
|
* @memberof Settings */
|
|
378
378
|
function setObjectMaxSpeed(speed) { objectMaxSpeed = speed; }
|
|
379
379
|
|
|
380
380
|
/** Set how much gravity to apply to objects along the Y axis
|
|
381
|
-
* @param {
|
|
381
|
+
* @param {number} newGravity
|
|
382
382
|
* @memberof Settings */
|
|
383
383
|
function setGravity(newGravity) { gravity = newGravity; }
|
|
384
384
|
|
|
385
385
|
/** Set to scales emit rate of particles
|
|
386
|
-
* @param {
|
|
386
|
+
* @param {number} scale
|
|
387
387
|
* @memberof Settings */
|
|
388
388
|
function setParticleEmitRateScale(scale) { particleEmitRateScale = scale; }
|
|
389
389
|
|
|
390
390
|
/** Set if gamepads are enabled
|
|
391
|
-
* @param {
|
|
391
|
+
* @param {boolean} enable
|
|
392
392
|
* @memberof Settings */
|
|
393
393
|
function setGamepadsEnable(enable) { gamepadsEnable = enable; }
|
|
394
394
|
|
|
395
395
|
/** Set if the dpad input is also routed to the left analog stick
|
|
396
|
-
* @param {
|
|
396
|
+
* @param {boolean} enable
|
|
397
397
|
* @memberof Settings */
|
|
398
398
|
function setGamepadDirectionEmulateStick(enable) { gamepadDirectionEmulateStick = enable; }
|
|
399
399
|
|
|
400
400
|
/** Set if true the WASD keys are also routed to the direction keys
|
|
401
|
-
* @param {
|
|
401
|
+
* @param {boolean} enable
|
|
402
402
|
* @memberof Settings */
|
|
403
403
|
function setInputWASDEmulateDirection(enable) { inputWASDEmulateDirection = enable; }
|
|
404
404
|
|
|
405
405
|
/** Set if touch input is allowed
|
|
406
|
-
* @param {
|
|
406
|
+
* @param {boolean} enable
|
|
407
407
|
* @memberof Settings */
|
|
408
408
|
function setTouchInputEnable(enable) { touchInputEnable = enable; }
|
|
409
409
|
|
|
410
410
|
/** Set if touch gamepad should appear on mobile devices
|
|
411
|
-
* @param {
|
|
411
|
+
* @param {boolean} enable
|
|
412
412
|
* @memberof Settings */
|
|
413
413
|
function setTouchGamepadEnable(enable) { touchGamepadEnable = enable; }
|
|
414
414
|
|
|
415
415
|
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
416
|
-
* @param {
|
|
416
|
+
* @param {boolean} analog
|
|
417
417
|
* @memberof Settings */
|
|
418
418
|
function setTouchGamepadAnalog(analog) { touchGamepadAnalog = analog; }
|
|
419
419
|
|
|
420
420
|
/** Set size of virtual gamepad for touch devices in pixels
|
|
421
|
-
* @param {
|
|
421
|
+
* @param {number} size
|
|
422
422
|
* @memberof Settings */
|
|
423
423
|
function setTouchGamepadSize(size) { touchGamepadSize = size; }
|
|
424
424
|
|
|
425
425
|
/** Set transparency of touch gamepad overlay
|
|
426
|
-
* @param {
|
|
426
|
+
* @param {number} alpha
|
|
427
427
|
* @memberof Settings */
|
|
428
428
|
function setTouchGamepadAlpha(alpha) { touchGamepadAlpha = alpha; }
|
|
429
429
|
|
|
430
430
|
/** Set to allow vibration hardware if it exists
|
|
431
|
-
* @param {
|
|
431
|
+
* @param {boolean} enable
|
|
432
432
|
* @memberof Settings */
|
|
433
433
|
function setVibrateEnable(enable) { vibrateEnable = enable; }
|
|
434
434
|
|
|
435
435
|
/** Set to disable all audio code
|
|
436
|
-
* @param {
|
|
436
|
+
* @param {boolean} enable
|
|
437
437
|
* @memberof Settings */
|
|
438
438
|
function setSoundEnable(enable) { soundEnable = enable; }
|
|
439
439
|
|
|
440
440
|
/** Set volume scale to apply to all sound, music and speech
|
|
441
|
-
* @param {
|
|
441
|
+
* @param {number} volume
|
|
442
442
|
* @memberof Settings */
|
|
443
443
|
function setSoundVolume(volume)
|
|
444
444
|
{
|
|
@@ -448,22 +448,22 @@ function setSoundVolume(volume)
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
/** Set default range where sound no longer plays
|
|
451
|
-
* @param {
|
|
451
|
+
* @param {number} range
|
|
452
452
|
* @memberof Settings */
|
|
453
453
|
function setSoundDefaultRange(range) { soundDefaultRange = range; }
|
|
454
454
|
|
|
455
455
|
/** Set default range percent to start tapering off sound
|
|
456
|
-
* @param {
|
|
456
|
+
* @param {number} taper
|
|
457
457
|
* @memberof Settings */
|
|
458
458
|
function setSoundDefaultTaper(taper) { soundDefaultTaper = taper; }
|
|
459
459
|
|
|
460
460
|
/** Set how long to show medals for in seconds
|
|
461
|
-
* @param {
|
|
461
|
+
* @param {number} time
|
|
462
462
|
* @memberof Settings */
|
|
463
463
|
function setMedalDisplayTime(time) { medalDisplayTime = time; }
|
|
464
464
|
|
|
465
465
|
/** Set how quickly to slide on/off medals in seconds
|
|
466
|
-
* @param {
|
|
466
|
+
* @param {number} time
|
|
467
467
|
* @memberof Settings */
|
|
468
468
|
function setMedalDisplaySlideTime(time) { medalDisplaySlideTime = time; }
|
|
469
469
|
|
|
@@ -472,22 +472,17 @@ function setMedalDisplaySlideTime(time) { medalDisplaySlideTime = time; }
|
|
|
472
472
|
* @memberof Settings */
|
|
473
473
|
function setMedalDisplaySize(size) { medalDisplaySize = size; }
|
|
474
474
|
|
|
475
|
-
/** Set size of icon in medal display
|
|
476
|
-
* @param {Number} size
|
|
477
|
-
* @memberof Settings */
|
|
478
|
-
function setMedalDisplayIconSize(size) { medalDisplayIconSize = size; }
|
|
479
|
-
|
|
480
475
|
/** Set to stop medals from being unlockable
|
|
481
|
-
* @param {
|
|
476
|
+
* @param {boolean} preventUnlock
|
|
482
477
|
* @memberof Settings */
|
|
483
478
|
function setMedalsPreventUnlock(preventUnlock) { medalsPreventUnlock = preventUnlock; }
|
|
484
479
|
|
|
485
480
|
/** Set if watermark with FPS should be shown
|
|
486
|
-
* @param {
|
|
481
|
+
* @param {boolean} show
|
|
487
482
|
* @memberof Debug */
|
|
488
483
|
function setShowWatermark(show) { showWatermark = show; }
|
|
489
484
|
|
|
490
485
|
/** Set key code used to toggle debug mode, Esc by default
|
|
491
|
-
* @param {
|
|
486
|
+
* @param {string} key
|
|
492
487
|
* @memberof Debug */
|
|
493
488
|
function setDebugKey(key) { debugKey = key; }
|
package/src/engineTileLayer.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
15
|
/** The tile collision layer grid, use setTileCollisionData and getTileCollisionData to access
|
|
16
|
-
* @type {Array}
|
|
16
|
+
* @type {Array<number>}
|
|
17
17
|
* @memberof TileCollision */
|
|
18
18
|
let tileCollision = [];
|
|
19
19
|
|
|
@@ -35,7 +35,7 @@ function initTileCollision(size)
|
|
|
35
35
|
|
|
36
36
|
/** Set tile collision data for a given cell in the grid
|
|
37
37
|
* @param {Vector2} pos
|
|
38
|
-
* @param {
|
|
38
|
+
* @param {number} [data]
|
|
39
39
|
* @memberof TileCollision */
|
|
40
40
|
function setTileCollisionData(pos, data=0)
|
|
41
41
|
{
|
|
@@ -44,7 +44,7 @@ function setTileCollisionData(pos, data=0)
|
|
|
44
44
|
|
|
45
45
|
/** Get tile collision data for a given cell in the grid
|
|
46
46
|
* @param {Vector2} pos
|
|
47
|
-
* @return {
|
|
47
|
+
* @return {number}
|
|
48
48
|
* @memberof TileCollision */
|
|
49
49
|
function getTileCollisionData(pos)
|
|
50
50
|
{
|
|
@@ -55,7 +55,7 @@ function getTileCollisionData(pos)
|
|
|
55
55
|
* @param {Vector2} pos
|
|
56
56
|
* @param {Vector2} [size=(0,0)]
|
|
57
57
|
* @param {EngineObject} [object]
|
|
58
|
-
* @return {
|
|
58
|
+
* @return {boolean}
|
|
59
59
|
* @memberof TileCollision */
|
|
60
60
|
function tileCollisionTest(pos, size=vec2(), object)
|
|
61
61
|
{
|
|
@@ -136,17 +136,17 @@ function tileCollisionRaycast(posStart, posEnd, object)
|
|
|
136
136
|
class TileLayerData
|
|
137
137
|
{
|
|
138
138
|
/** Create a tile layer data object, one for each tile in a TileLayer
|
|
139
|
-
* @param {
|
|
140
|
-
* @param {
|
|
141
|
-
* @param {
|
|
139
|
+
* @param {number} [tile] - The tile to use, untextured if undefined
|
|
140
|
+
* @param {number} [direction] - Integer direction of tile, in 90 degree increments
|
|
141
|
+
* @param {boolean} [mirror] - If the tile should be mirrored along the x axis
|
|
142
142
|
* @param {Color} [color] - Color of the tile */
|
|
143
143
|
constructor(tile, direction=0, mirror=false, color=new Color)
|
|
144
144
|
{
|
|
145
|
-
/** @property {
|
|
145
|
+
/** @property {number} - The tile to use, untextured if undefined */
|
|
146
146
|
this.tile = tile;
|
|
147
|
-
/** @property {
|
|
147
|
+
/** @property {number} - Integer direction of tile, in 90 degree increments */
|
|
148
148
|
this.direction = direction;
|
|
149
|
-
/** @property {
|
|
149
|
+
/** @property {boolean} - If the tile should be mirrored along the x axis */
|
|
150
150
|
this.mirror = mirror;
|
|
151
151
|
/** @property {Color} - Color of the tile */
|
|
152
152
|
this.color = color;
|
|
@@ -175,7 +175,7 @@ class TileLayer extends EngineObject
|
|
|
175
175
|
* @param {Vector2} [size=tileCollisionSize] - World space size
|
|
176
176
|
* @param {TileInfo} [tileInfo] - Tile info for layer
|
|
177
177
|
* @param {Vector2} [scale=(1,1)] - How much to scale this layer when rendered
|
|
178
|
-
* @param {
|
|
178
|
+
* @param {number} [renderOrder] - Objects are sorted by renderOrder
|
|
179
179
|
*/
|
|
180
180
|
constructor(position, size=tileCollisionSize, tileInfo=tile(), scale=vec2(1), renderOrder=0)
|
|
181
181
|
{
|
|
@@ -187,7 +187,7 @@ class TileLayer extends EngineObject
|
|
|
187
187
|
this.context = this.canvas.getContext('2d');
|
|
188
188
|
/** @property {Vector2} - How much to scale this layer when rendered */
|
|
189
189
|
this.scale = scale;
|
|
190
|
-
/** @property {
|
|
190
|
+
/** @property {boolean} - If true this layer will render to overlay canvas and appear above all objects */
|
|
191
191
|
this.isOverlay = false;
|
|
192
192
|
|
|
193
193
|
// init tile data
|
|
@@ -210,7 +210,7 @@ class TileLayer extends EngineObject
|
|
|
210
210
|
/** Set data at a given position in the array
|
|
211
211
|
* @param {Vector2} layerPos - Local position in array
|
|
212
212
|
* @param {TileLayerData} data - Data to set
|
|
213
|
-
* @param {
|
|
213
|
+
* @param {boolean} [redraw] - Force the tile to redraw if true */
|
|
214
214
|
setData(layerPos, data, redraw=false)
|
|
215
215
|
{
|
|
216
216
|
if (layerPos.arrayCheck(this.size))
|
|
@@ -263,7 +263,7 @@ class TileLayer extends EngineObject
|
|
|
263
263
|
|
|
264
264
|
/** Call to start the redraw process
|
|
265
265
|
* - This can be used to manually update small parts of the level
|
|
266
|
-
* @param {
|
|
266
|
+
* @param {boolean} [clear] - Should it clear the canvas before drawing */
|
|
267
267
|
redrawStart(clear=false)
|
|
268
268
|
{
|
|
269
269
|
// save current render settings
|
|
@@ -307,7 +307,7 @@ class TileLayer extends EngineObject
|
|
|
307
307
|
* This can be used to clear out tiles when they are destroyed
|
|
308
308
|
* Tiles can also be redrawn if inside a redrawStart/End block
|
|
309
309
|
* @param {Vector2} layerPos
|
|
310
|
-
* @param {
|
|
310
|
+
* @param {boolean} [clear] - should the old tile be cleared out
|
|
311
311
|
*/
|
|
312
312
|
drawTileData(layerPos, clear=true)
|
|
313
313
|
{
|
|
@@ -325,7 +325,7 @@ class TileLayer extends EngineObject
|
|
|
325
325
|
{
|
|
326
326
|
ASSERT(mainContext == this.context, 'must call redrawStart() before drawing tiles');
|
|
327
327
|
const pos = layerPos.add(vec2(.5));
|
|
328
|
-
const tileInfo = tile(d.tile, s, this.tileInfo.textureIndex);
|
|
328
|
+
const tileInfo = tile(d.tile, s, this.tileInfo.textureIndex, this.tileInfo.padding);
|
|
329
329
|
drawTile(pos, vec2(1), tileInfo, d.color, d.direction*PI/2, d.mirror);
|
|
330
330
|
}
|
|
331
331
|
}
|
|
@@ -333,8 +333,8 @@ class TileLayer extends EngineObject
|
|
|
333
333
|
/** Draw directly to the 2D canvas in world space (bypass webgl)
|
|
334
334
|
* @param {Vector2} pos
|
|
335
335
|
* @param {Vector2} size
|
|
336
|
-
* @param {
|
|
337
|
-
* @param {
|
|
336
|
+
* @param {number} angle
|
|
337
|
+
* @param {boolean} mirror
|
|
338
338
|
* @param {Function} drawFunction */
|
|
339
339
|
drawCanvas2D(pos, size, angle, mirror, drawFunction)
|
|
340
340
|
{
|
|
@@ -354,8 +354,8 @@ class TileLayer extends EngineObject
|
|
|
354
354
|
* @param {Vector2} [size=(1,1)]
|
|
355
355
|
* @param {TileInfo} [tileInfo]
|
|
356
356
|
* @param {Color} [color=(1,1,1,1)]
|
|
357
|
-
* @param {
|
|
358
|
-
* @param {
|
|
357
|
+
* @param {number} [angle=0]
|
|
358
|
+
* @param {boolean} [mirror=0] */
|
|
359
359
|
drawTile(pos, size=vec2(1), tileInfo, color=new Color, angle, mirror)
|
|
360
360
|
{
|
|
361
361
|
this.drawCanvas2D(pos, size, angle, mirror, (context)=>
|
|
@@ -382,7 +382,7 @@ class TileLayer extends EngineObject
|
|
|
382
382
|
* @param {Vector2} pos
|
|
383
383
|
* @param {Vector2} [size=(1,1)]
|
|
384
384
|
* @param {Color} [color=(1,1,1,1)]
|
|
385
|
-
* @param {
|
|
385
|
+
* @param {number} [angle=0] */
|
|
386
386
|
drawRect(pos, size, color, angle)
|
|
387
387
|
{ this.drawTile(pos, size, undefined, color, angle); }
|
|
388
388
|
}
|