melonjs 13.4.0 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -6
- package/dist/melonjs.module.d.ts +13108 -11652
- package/dist/melonjs.module.js +581 -128
- package/package.json +21 -21
- package/src/application/application.js +3 -3
- package/src/audio/audio.js +27 -27
- package/src/camera/camera2d.js +1 -2
- package/src/entity/entity.js +1 -2
- package/src/geometries/ellipse.js +1 -2
- package/src/geometries/line.js +2 -3
- package/src/geometries/poly.js +2 -2
- package/src/geometries/rectangle.js +1 -3
- package/src/geometries/roundrect.js +1 -2
- package/src/index.js +8 -4
- package/src/input/gamepad.js +12 -12
- package/src/input/keyboard.js +8 -8
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +9 -9
- package/src/lang/deprecated.js +21 -2
- package/src/level/level.js +2 -2
- package/src/level/tiled/TMXGroup.js +1 -1
- package/src/level/tiled/TMXLayer.js +1 -1
- package/src/level/tiled/TMXTile.js +2 -2
- package/src/level/tiled/TMXTileMap.js +4 -4
- package/src/level/tiled/TMXTileset.js +2 -2
- package/src/level/tiled/TMXTilesetGroup.js +1 -1
- package/src/level/tiled/TMXUtils.js +7 -7
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/src/loader/loader.js +9 -9
- package/src/loader/loadingscreen.js +2 -2
- package/src/math/color.js +3 -3
- package/src/math/math.js +10 -10
- package/src/math/matrix2.js +1 -1
- package/src/math/matrix3.js +1 -1
- package/src/math/observable_vector2.js +1 -1
- package/src/math/observable_vector3.js +1 -1
- package/src/math/vector2.js +1 -1
- package/src/math/vector3.js +1 -1
- package/src/particles/emitter.js +2 -2
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +2 -2
- package/src/physics/bounds.js +1 -1
- package/src/physics/detector.js +3 -3
- package/src/physics/quadtree.js +2 -2
- package/src/physics/world.js +2 -2
- package/src/polyfill/performance.js +1 -1
- package/src/polyfill/requestAnimationFrame.js +1 -1
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/colorlayer.js +1 -1
- package/src/renderable/container.js +10 -6
- package/src/renderable/dragndrop.js +2 -2
- package/src/renderable/imagelayer.js +1 -2
- package/src/renderable/light2d.js +1 -1
- package/src/renderable/nineslicesprite.js +1 -2
- package/src/renderable/renderable.js +1 -3
- package/src/renderable/sprite.js +3 -4
- package/src/renderable/trigger.js +3 -4
- package/src/renderable/ui/uibaseelement.js +204 -0
- package/src/renderable/{GUI.js → ui/uispriteelement.js} +8 -35
- package/src/renderable/ui/uitextbutton.js +121 -0
- package/src/state/stage.js +4 -5
- package/src/system/device.js +27 -27
- package/src/system/dom.js +1 -1
- package/src/system/event.js +4 -4
- package/src/system/pooling.js +2 -3
- package/src/system/save.js +2 -2
- package/src/system/timer.js +1 -1
- package/src/text/bitmaptext.js +2 -3
- package/src/text/bitmaptextdata.js +4 -7
- package/src/text/glyph.js +1 -2
- package/src/text/text.js +2 -3
- package/src/text/textstyle.js +1 -1
- package/src/tweens/tween.js +2 -3
- package/src/utils/agent.js +4 -4
- package/src/utils/array.js +3 -3
- package/src/utils/file.js +2 -2
- package/src/utils/function.js +3 -3
- package/src/utils/string.js +5 -5
- package/src/utils/utils.js +2 -2
- package/src/video/canvas/canvas_renderer.js +1 -2
- package/src/video/renderer.js +2 -3
- package/src/video/texture/atlas.js +2 -2
- package/src/video/texture/cache.js +1 -2
- package/src/video/video.js +12 -14
- package/src/video/webgl/buffer/vertex.js +1 -2
- package/src/video/webgl/glshader.js +1 -2
- package/src/video/webgl/utils/attributes.js +1 -1
- package/src/video/webgl/utils/precision.js +1 -1
- package/src/video/webgl/utils/program.js +2 -2
- package/src/video/webgl/utils/string.js +1 -1
- package/src/video/webgl/utils/uniforms.js +3 -3
- package/src/video/webgl/webgl_compositor.js +1 -2
- package/src/video/webgl/webgl_renderer.js +1 -2
- package/dist/melonjs.js +0 -37922
- package/dist/melonjs.min.js +0 -29
|
@@ -151,7 +151,7 @@ function enablePointerEvent() {
|
|
|
151
151
|
device.focus();
|
|
152
152
|
pointerEventTarget.addEventListener(
|
|
153
153
|
activeEventList[2], // MOUSE/POINTER DOWN
|
|
154
|
-
|
|
154
|
+
() => {
|
|
155
155
|
device.focus();
|
|
156
156
|
},
|
|
157
157
|
{ passive: (preventDefault === false) }
|
|
@@ -566,7 +566,7 @@ export function globalToLocal(x, y, v) {
|
|
|
566
566
|
y /= scale.y;
|
|
567
567
|
}
|
|
568
568
|
return v.set(x * pixelRatio, y * pixelRatio);
|
|
569
|
-
}
|
|
569
|
+
}
|
|
570
570
|
|
|
571
571
|
/**
|
|
572
572
|
* enable/disable all gestures on the given element.<br>
|
|
@@ -580,7 +580,7 @@ export function globalToLocal(x, y, v) {
|
|
|
580
580
|
*/
|
|
581
581
|
export function setTouchAction(element, value) {
|
|
582
582
|
element.style["touch-action"] = value || "none";
|
|
583
|
-
}
|
|
583
|
+
}
|
|
584
584
|
|
|
585
585
|
/**
|
|
586
586
|
* Associate a pointer event to a keycode<br>
|
|
@@ -613,7 +613,7 @@ export function bindPointer() {
|
|
|
613
613
|
}
|
|
614
614
|
// map the mouse button to the keycode
|
|
615
615
|
pointer.bind[button] = keyCode;
|
|
616
|
-
}
|
|
616
|
+
}
|
|
617
617
|
|
|
618
618
|
/**
|
|
619
619
|
* unbind the defined keycode
|
|
@@ -630,7 +630,7 @@ export function unbindPointer(button) {
|
|
|
630
630
|
typeof(button) === "undefined" ?
|
|
631
631
|
pointer.LEFT : button
|
|
632
632
|
] = null;
|
|
633
|
-
}
|
|
633
|
+
}
|
|
634
634
|
|
|
635
635
|
|
|
636
636
|
/**
|
|
@@ -704,7 +704,7 @@ export function registerPointerEvent(eventType, region, callback) {
|
|
|
704
704
|
handlers.callbacks[eventType] = [callback];
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
|
-
}
|
|
707
|
+
}
|
|
708
708
|
|
|
709
709
|
/**
|
|
710
710
|
* allows the removal of event listeners from the object target.
|
|
@@ -749,7 +749,7 @@ export function releasePointerEvent(eventType, region, callback) {
|
|
|
749
749
|
eventHandlers.delete(region);
|
|
750
750
|
}
|
|
751
751
|
}
|
|
752
|
-
}
|
|
752
|
+
}
|
|
753
753
|
|
|
754
754
|
/**
|
|
755
755
|
* allows the removal of all registered event listeners from the object target.
|
|
@@ -766,8 +766,8 @@ export function releaseAllPointerEvents(region) {
|
|
|
766
766
|
for (var i = 0; i < pointerEventList.length; i++) {
|
|
767
767
|
releasePointerEvent(pointerEventList[i], region);
|
|
768
768
|
}
|
|
769
|
-
}
|
|
770
|
-
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
771
|
|
|
772
772
|
/**
|
|
773
773
|
* request for the pointer to be locked on the parent DOM element.
|
package/src/lang/deprecated.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TextureAtlas } from "./../video/texture/atlas.js";
|
|
2
2
|
import Renderer from "./../video/renderer.js";
|
|
3
3
|
import { Draggable, DropTarget } from "./../renderable/dragndrop.js";
|
|
4
|
-
|
|
4
|
+
import UISpriteElement from "./../renderable/ui/uispriteelement.js";
|
|
5
5
|
/*
|
|
6
6
|
* placeholder for all deprecated classes and corresponding alias for backward compatibility
|
|
7
7
|
*/
|
|
@@ -41,7 +41,7 @@ export function warning(deprecated, replacement, version) {
|
|
|
41
41
|
if (console.groupCollapsed) {
|
|
42
42
|
console.groupEnd();
|
|
43
43
|
}
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Alias of {@link TextureAtlas}
|
|
@@ -126,3 +126,22 @@ Renderer.prototype.getScreenContext = function() {
|
|
|
126
126
|
warning("getScreenContext", "getContext", "13.1.0");
|
|
127
127
|
return this.getContext();
|
|
128
128
|
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @classdesc
|
|
132
|
+
* A very basic object to manage GUI elements
|
|
133
|
+
* @augments Sprite
|
|
134
|
+
* @deprecated since 14.0.0
|
|
135
|
+
* @see UISpriteElement
|
|
136
|
+
*/
|
|
137
|
+
export class GUI_Object extends UISpriteElement {
|
|
138
|
+
/**
|
|
139
|
+
* @param {number} x the x coordinate of the GUI Object
|
|
140
|
+
* @param {number} y the y coordinate of the GUI Object
|
|
141
|
+
* @param {object} settings See {@link Sprite}
|
|
142
|
+
*/
|
|
143
|
+
constructor(x, y, settings) {
|
|
144
|
+
warning("GUI_Object", "UISpriteElement", "14.0.0");
|
|
145
|
+
super(x, y, settings);
|
|
146
|
+
}
|
|
147
|
+
}
|
package/src/level/level.js
CHANGED
|
@@ -44,7 +44,7 @@ function safeLoadLevel(levelId, options, restart) {
|
|
|
44
44
|
// resume the game loop if it was previously running
|
|
45
45
|
state.restart();
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Load a TMX level
|
|
@@ -69,7 +69,7 @@ function loadTMXLevel(levelId, container, flatten, setViewportBounds) {
|
|
|
69
69
|
|
|
70
70
|
// add all level elements to the target container
|
|
71
71
|
level.addTo(container, flatten, setViewportBounds);
|
|
72
|
-
}
|
|
72
|
+
}
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
/**
|
|
@@ -142,7 +142,7 @@ class Tile extends Bounds {
|
|
|
142
142
|
if (tileset.animations.has(this.tileId)) {
|
|
143
143
|
var frames = [];
|
|
144
144
|
var frameId = [];
|
|
145
|
-
(tileset.animations.get(this.tileId).frames).forEach(
|
|
145
|
+
(tileset.animations.get(this.tileId).frames).forEach((frame) => {
|
|
146
146
|
frameId.push(frame.tileid);
|
|
147
147
|
frames.push({
|
|
148
148
|
name : "" + frame.tileid,
|
|
@@ -181,5 +181,5 @@ class Tile extends Bounds {
|
|
|
181
181
|
|
|
182
182
|
return renderable;
|
|
183
183
|
}
|
|
184
|
-
}
|
|
184
|
+
}
|
|
185
185
|
export default Tile;
|
|
@@ -271,7 +271,7 @@ class TMXTileMap {
|
|
|
271
271
|
getRenderer() {
|
|
272
272
|
if ((typeof(this.renderer) === "undefined") || (!this.renderer.canRender(this))) {
|
|
273
273
|
this.renderer = getNewDefaultRenderer(this);
|
|
274
|
-
}
|
|
274
|
+
}
|
|
275
275
|
return this.renderer;
|
|
276
276
|
}
|
|
277
277
|
|
|
@@ -385,12 +385,12 @@ class TMXTileMap {
|
|
|
385
385
|
}
|
|
386
386
|
|
|
387
387
|
// add all layers instances
|
|
388
|
-
this.getLayers().forEach(
|
|
388
|
+
this.getLayers().forEach((layer) => {
|
|
389
389
|
container.addChild(layer);
|
|
390
390
|
});
|
|
391
391
|
|
|
392
392
|
// add all Object instances
|
|
393
|
-
this.getObjects(flatten).forEach(
|
|
393
|
+
this.getObjects(flatten).forEach((object) => {
|
|
394
394
|
container.addChild(object);
|
|
395
395
|
});
|
|
396
396
|
|
|
@@ -628,6 +628,6 @@ class TMXTileMap {
|
|
|
628
628
|
this.objectGroups.length = 0;
|
|
629
629
|
this.initialized = false;
|
|
630
630
|
}
|
|
631
|
-
}
|
|
631
|
+
}
|
|
632
632
|
|
|
633
633
|
export default TMXTileMap;
|
|
@@ -240,7 +240,7 @@ class TMXTileset {
|
|
|
240
240
|
if (this._lastUpdate !== now) {
|
|
241
241
|
this._lastUpdate = now;
|
|
242
242
|
|
|
243
|
-
this.animations.forEach(
|
|
243
|
+
this.animations.forEach((anim) => {
|
|
244
244
|
anim.dt += dt;
|
|
245
245
|
duration = anim.cur.duration;
|
|
246
246
|
while (anim.dt >= duration) {
|
|
@@ -297,6 +297,6 @@ class TMXTileset {
|
|
|
297
297
|
renderer.restore();
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
}
|
|
300
|
+
}
|
|
301
301
|
|
|
302
302
|
export default TMXTileset;
|
|
@@ -104,7 +104,7 @@ function parseAttributes(obj, elt) {
|
|
|
104
104
|
*/
|
|
105
105
|
export function decompress() {
|
|
106
106
|
throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
|
|
107
|
-
}
|
|
107
|
+
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Decode a CSV encoded array into a binary array
|
|
@@ -121,7 +121,7 @@ export function decodeCSV(input) {
|
|
|
121
121
|
result.push(+entries[i]);
|
|
122
122
|
}
|
|
123
123
|
return result;
|
|
124
|
-
}
|
|
124
|
+
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
127
|
* Decode a base64 encoded string into a byte array
|
|
@@ -145,7 +145,7 @@ export function decodeBase64AsArray(input, bytes) {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
return ar;
|
|
148
|
-
}
|
|
148
|
+
}
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
151
|
* Decode the given data
|
|
@@ -176,7 +176,7 @@ export function decode(data, encoding, compression) {
|
|
|
176
176
|
default:
|
|
177
177
|
throw new Error("Unknown layer encoding: " + encoding);
|
|
178
178
|
}
|
|
179
|
-
}
|
|
179
|
+
}
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
182
|
* Normalize TMX format to Tiled JSON format
|
|
@@ -284,7 +284,7 @@ export function normalize(obj, item) {
|
|
|
284
284
|
obj[nodeName] = parse(item);
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
|
-
}
|
|
287
|
+
}
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
290
|
* Parse a XML TMX object and returns the corresponding javascript object
|
|
@@ -323,7 +323,7 @@ export function parse(xml) {
|
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
return obj;
|
|
326
|
-
}
|
|
326
|
+
}
|
|
327
327
|
|
|
328
328
|
/**
|
|
329
329
|
* Apply TMX Properties to the given object
|
|
@@ -355,4 +355,4 @@ export function applyTMXProperties(obj, data) {
|
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
}
|
|
358
|
+
}
|
package/src/loader/loader.js
CHANGED
|
@@ -37,7 +37,7 @@ function checkLoadStatus(onload) {
|
|
|
37
37
|
// trigger the onload callback
|
|
38
38
|
// we call either the supplied callback (which takes precedence) or the global one
|
|
39
39
|
var callback = onload || loader.onload;
|
|
40
|
-
setTimeout(
|
|
40
|
+
setTimeout(() => {
|
|
41
41
|
callback();
|
|
42
42
|
event.emit(event.LOADER_COMPLETE);
|
|
43
43
|
}, 300);
|
|
@@ -51,7 +51,7 @@ function checkLoadStatus(onload) {
|
|
|
51
51
|
checkLoadStatus(onload);
|
|
52
52
|
}, 100);
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* load Images
|
|
@@ -77,7 +77,7 @@ function preloadImage(img, onload, onerror) {
|
|
|
77
77
|
imgList[img.name].crossOrigin = loader.crossOrigin;
|
|
78
78
|
}
|
|
79
79
|
imgList[img.name].src = img.src + loader.nocache;
|
|
80
|
-
}
|
|
80
|
+
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* load a font face
|
|
@@ -107,13 +107,13 @@ function preloadFontFace(data, onload, onerror) {
|
|
|
107
107
|
// onloaded callback
|
|
108
108
|
onload();
|
|
109
109
|
}
|
|
110
|
-
},
|
|
110
|
+
}, () => {
|
|
111
111
|
if (typeof onerror === "function") {
|
|
112
112
|
// rejected
|
|
113
113
|
onerror(data.name);
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
|
-
}
|
|
116
|
+
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* preload TMX files
|
|
@@ -221,7 +221,7 @@ function preloadTMX(tmxData, onload, onerror) {
|
|
|
221
221
|
};
|
|
222
222
|
// send the request
|
|
223
223
|
xmlhttp.send();
|
|
224
|
-
}
|
|
224
|
+
}
|
|
225
225
|
|
|
226
226
|
/**
|
|
227
227
|
* preload JSON files
|
|
@@ -258,7 +258,7 @@ function preloadJSON(data, onload, onerror) {
|
|
|
258
258
|
};
|
|
259
259
|
// send the request
|
|
260
260
|
xmlhttp.send();
|
|
261
|
-
}
|
|
261
|
+
}
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* preload Binary files
|
|
@@ -289,7 +289,7 @@ function preloadBinary(data, onload, onerror) {
|
|
|
289
289
|
}
|
|
290
290
|
};
|
|
291
291
|
httpReq.send();
|
|
292
|
-
}
|
|
292
|
+
}
|
|
293
293
|
|
|
294
294
|
/**
|
|
295
295
|
* preload Binary files
|
|
@@ -320,7 +320,7 @@ function preloadJavascript(data, onload, onerror) {
|
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
document.getElementsByTagName("body")[0].appendChild(script);
|
|
323
|
-
}
|
|
323
|
+
}
|
|
324
324
|
|
|
325
325
|
/**
|
|
326
326
|
* a small class to manage loading of stuff and manage resources
|
|
@@ -60,7 +60,7 @@ class ProgressBar extends Renderable {
|
|
|
60
60
|
event.off(event.VIEWPORT_ONRESIZE, this.resize);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
}
|
|
63
|
+
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* a default loading screen
|
|
@@ -107,6 +107,6 @@ class DefaultLoadingScreen extends Stage {
|
|
|
107
107
|
// cancel the callback
|
|
108
108
|
loader.unload({name: "melonjs_logo", type:"image"});
|
|
109
109
|
}
|
|
110
|
-
}
|
|
110
|
+
}
|
|
111
111
|
|
|
112
112
|
export default DefaultLoadingScreen;
|
package/src/math/color.js
CHANGED
|
@@ -4,7 +4,7 @@ import pool from "./../system/pooling.js";
|
|
|
4
4
|
// convert a give color component to it hexadecimal value
|
|
5
5
|
function toHex(component) {
|
|
6
6
|
return "0123456789ABCDEF".charAt((component - (component % 16)) >> 4) + "0123456789ABCDEF".charAt(component % 16);
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
8
|
|
|
9
9
|
function hue2rgb(p, q, t) {
|
|
10
10
|
if (t < 0) t += 1;
|
|
@@ -174,7 +174,7 @@ var cssToRGB = new Map();
|
|
|
174
174
|
[ "wheat", [ 245, 222, 179 ] ],
|
|
175
175
|
[ "whitesmoke", [ 245, 245, 245 ] ],
|
|
176
176
|
[ "yellowgreen", [ 154, 205, 50 ] ]
|
|
177
|
-
].forEach(
|
|
177
|
+
].forEach((value) => {
|
|
178
178
|
cssToRGB.set(value[0], value[1]);
|
|
179
179
|
});
|
|
180
180
|
|
|
@@ -604,6 +604,6 @@ class Color {
|
|
|
604
604
|
alpha +
|
|
605
605
|
")";
|
|
606
606
|
}
|
|
607
|
-
}
|
|
607
|
+
}
|
|
608
608
|
|
|
609
609
|
export default Color;
|
package/src/math/math.js
CHANGED
|
@@ -58,7 +58,7 @@ export const EPSILON = 0.000001;
|
|
|
58
58
|
*/
|
|
59
59
|
export function isPowerOfTwo(val) {
|
|
60
60
|
return (val & (val - 1)) === 0;
|
|
61
|
-
}
|
|
61
|
+
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* returns the next power of two for the given value
|
|
@@ -77,7 +77,7 @@ export function nextPowerOfTwo(val) {
|
|
|
77
77
|
val |= val >> 16;
|
|
78
78
|
val ++;
|
|
79
79
|
return val;
|
|
80
|
-
}
|
|
80
|
+
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Converts an angle in degrees to an angle in radians
|
|
@@ -92,7 +92,7 @@ export function nextPowerOfTwo(val) {
|
|
|
92
92
|
*/
|
|
93
93
|
export function degToRad(angle) {
|
|
94
94
|
return angle * DEG_TO_RAD;
|
|
95
|
-
}
|
|
95
|
+
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* Converts an angle in radians to an angle in degrees.
|
|
@@ -107,7 +107,7 @@ export function degToRad(angle) {
|
|
|
107
107
|
*/
|
|
108
108
|
export function radToDeg(radians) {
|
|
109
109
|
return radians * RAD_TO_DEG;
|
|
110
|
-
}
|
|
110
|
+
}
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* clamp the given value
|
|
@@ -121,7 +121,7 @@ export function radToDeg(radians) {
|
|
|
121
121
|
*/
|
|
122
122
|
export function clamp(val, low, high) {
|
|
123
123
|
return val < low ? low : val > high ? high : +val;
|
|
124
|
-
}
|
|
124
|
+
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
127
|
* return a random integer between min (included) and max (excluded)
|
|
@@ -137,7 +137,7 @@ export function clamp(val, low, high) {
|
|
|
137
137
|
*/
|
|
138
138
|
export function random(min, max) {
|
|
139
139
|
return (~~(Math.random() * (max - min)) + min);
|
|
140
|
-
}
|
|
140
|
+
}
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* return a random float between min, max (exclusive)
|
|
@@ -153,7 +153,7 @@ export function random(min, max) {
|
|
|
153
153
|
*/
|
|
154
154
|
export function randomFloat(min, max) {
|
|
155
155
|
return (Math.random() * (max - min)) + min;
|
|
156
|
-
}
|
|
156
|
+
}
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* return a weighted random between min, max (exclusive)
|
|
@@ -169,7 +169,7 @@ export function randomFloat(min, max) {
|
|
|
169
169
|
*/
|
|
170
170
|
export function weightedRandom(min, max) {
|
|
171
171
|
return (~~(Math.pow(Math.random(), 2) * (max - min)) + min);
|
|
172
|
-
}
|
|
172
|
+
}
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* round a value to the specified number of digit
|
|
@@ -187,7 +187,7 @@ export function round(num, dec = 0) {
|
|
|
187
187
|
// if only one argument use the object value
|
|
188
188
|
var powres = Math.pow(10, dec);
|
|
189
189
|
return (~~(0.5 + num * powres) / powres);
|
|
190
|
-
}
|
|
190
|
+
}
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* check if the given value is close to the expected one
|
|
@@ -206,4 +206,4 @@ export function round(num, dec = 0) {
|
|
|
206
206
|
*/
|
|
207
207
|
export function toBeCloseTo(expected, actual, precision = 2) {
|
|
208
208
|
return Math.abs(expected - actual) < (Math.pow(10, -precision) / 2);
|
|
209
|
-
}
|
|
209
|
+
}
|
package/src/math/matrix2.js
CHANGED
package/src/math/matrix3.js
CHANGED
package/src/math/vector2.js
CHANGED
package/src/math/vector3.js
CHANGED
package/src/particles/emitter.js
CHANGED
|
@@ -14,7 +14,7 @@ function createDefaultParticleTexture(w = 8, h = 8) {
|
|
|
14
14
|
defaultParticleTexture.context.fillRect(0, 0, w, h);
|
|
15
15
|
|
|
16
16
|
return defaultParticleTexture;
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @classdesc
|
|
@@ -254,6 +254,6 @@ class ParticleEmitter extends Container {
|
|
|
254
254
|
this.settings.image = undefined;
|
|
255
255
|
this.settings = undefined;
|
|
256
256
|
}
|
|
257
|
-
}
|
|
257
|
+
}
|
|
258
258
|
|
|
259
259
|
export default ParticleEmitter;
|
package/src/physics/body.js
CHANGED
|
@@ -545,7 +545,7 @@ class Body {
|
|
|
545
545
|
if (shape.contains(_x, _y)) {
|
|
546
546
|
return true;
|
|
547
547
|
}
|
|
548
|
-
}
|
|
548
|
+
}
|
|
549
549
|
}
|
|
550
550
|
return false;
|
|
551
551
|
}
|
|
@@ -690,6 +690,6 @@ class Body {
|
|
|
690
690
|
// reset some variable to default
|
|
691
691
|
this.setStatic(false);
|
|
692
692
|
}
|
|
693
|
-
}
|
|
693
|
+
}
|
|
694
694
|
|
|
695
695
|
export default Body;
|
package/src/physics/bounds.js
CHANGED
package/src/physics/detector.js
CHANGED
|
@@ -35,7 +35,7 @@ function shouldCollide(a, b) {
|
|
|
35
35
|
(a.body.collisionMask & b.body.collisionType) !== 0 &&
|
|
36
36
|
(a.body.collisionType & b.body.collisionMask) !== 0
|
|
37
37
|
);
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
@@ -108,7 +108,7 @@ export function collisionCheck(objA, response = globalResponse) {
|
|
|
108
108
|
}
|
|
109
109
|
// we could return the amount of objects we collided with ?
|
|
110
110
|
return collisionCounter > 0;
|
|
111
|
-
}
|
|
111
|
+
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
114
|
* Checks for object colliding with the given line
|
|
@@ -182,4 +182,4 @@ export function rayCast(line, result = []) {
|
|
|
182
182
|
|
|
183
183
|
// return the list of colliding objects
|
|
184
184
|
return result;
|
|
185
|
-
}
|
|
185
|
+
}
|
package/src/physics/quadtree.js
CHANGED
|
@@ -32,7 +32,7 @@ function QT_ARRAY_POP(world, bounds, max_objects = 4, max_levels = 4, level = 0)
|
|
|
32
32
|
} else {
|
|
33
33
|
return new QuadTree(world, bounds, max_objects, max_levels, level);
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Push back a quadtree back into the array
|
|
@@ -40,7 +40,7 @@ function QT_ARRAY_POP(world, bounds, max_objects = 4, max_levels = 4, level = 0)
|
|
|
40
40
|
*/
|
|
41
41
|
function QT_ARRAY_PUSH(qt) {
|
|
42
42
|
QT_ARRAY.push(qt);
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* a temporary vector object to be reused
|