melonjs 10.9.0 → 10.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "melonjs",
3
- "version": "10.9.0",
3
+ "version": "10.10.0",
4
4
  "description": "melonJS Game Engine",
5
5
  "homepage": "http://www.melonjs.org/",
6
6
  "keywords": [
@@ -35,6 +35,7 @@
35
35
  "name": "Olivier Biot",
36
36
  "email": "contact@melonjs.org"
37
37
  },
38
+ "funding": "https://github.com/sponsors/melonjs",
38
39
  "engines": {
39
40
  "node": ">= 12"
40
41
  },
@@ -46,7 +47,6 @@
46
47
  "dist/melonjs.min.js",
47
48
  "dist/melonjs.module.js",
48
49
  "dist/melonjs.module.d.ts",
49
- "plugins/",
50
50
  "src/",
51
51
  "package.json",
52
52
  "README.md",
@@ -55,21 +55,23 @@
55
55
  ],
56
56
  "dependencies": {
57
57
  "@teppeis/multimaps": "^2.0.0",
58
- "core-js": "^3.22.5",
58
+ "core-js": "^3.22.8",
59
59
  "earcut": "2.2.3",
60
60
  "eventemitter3": "^4.0.7",
61
61
  "howler": "2.2.3"
62
62
  },
63
63
  "devDependencies": {
64
+ "@melonjs/jsdoc-template": "^2.0.2",
64
65
  "@rollup/plugin-buble": "^0.21.3",
65
66
  "@rollup/plugin-commonjs": "^22.0.0",
66
67
  "@rollup/plugin-node-resolve": "^13.3.0",
67
68
  "@rollup/plugin-replace": "^4.0.0",
68
- "@types/offscreencanvas": "^2019.6.4",
69
+ "@types/offscreencanvas": "^2019.7.0",
70
+ "@webdoc/cli": "^1.6.0",
69
71
  "cheerio": "^1.0.0-rc.11",
70
72
  "del-cli": "^4.0.1",
71
- "eslint": "^8.16.0",
72
- "eslint-plugin-jsdoc": "^39.3.0",
73
+ "eslint": "^8.17.0",
74
+ "eslint-plugin-jsdoc": "^39.3.2",
73
75
  "jasmine-core": "^4.1.1",
74
76
  "jsdoc": "^3.6.10",
75
77
  "karma": "^6.3.20",
@@ -78,12 +80,12 @@
78
80
  "karma-html-detailed-reporter": "^2.1.0",
79
81
  "karma-jasmine": "^5.0.1",
80
82
  "karma-nyan-reporter": "0.2.5",
81
- "qs": "^6.10.3",
82
- "rollup": "^2.74.1",
83
+ "qs": "^6.10.5",
84
+ "rollup": "^2.75.5",
83
85
  "rollup-plugin-bundle-size": "^1.0.3",
84
86
  "rollup-plugin-string": "^3.0.0",
85
- "terser": "^5.13.1",
86
- "typescript": "^4.6.4"
87
+ "terser": "^5.14.0",
88
+ "typescript": "^4.7.3"
87
89
  },
88
90
  "scripts": {
89
91
  "build": "npm run lint && rollup -c --silent",
@@ -92,6 +94,7 @@
92
94
  "lint": "eslint src rollup.config.js",
93
95
  "test": "npm run build && karma start tests/karma.conf.cjs",
94
96
  "doc": "mkdirp docs && jsdoc -c jsdoc_conf.json",
97
+ "webdoc": "mkdirp dist && webdoc --quiet -R README.md",
95
98
  "release": "npm run dist && npm publish --access public",
96
99
  "clean": "del-cli --force build/*.js dist/*.js dist/*.d.ts docs src/**/*.d.ts",
97
100
  "types": "tsc dist/melonjs.module.js --declaration --allowJs --emitDeclarationOnly"
package/src/game.js CHANGED
@@ -5,9 +5,9 @@ import state from "./state/state.js";
5
5
  import World from "./physics/world.js";
6
6
 
7
7
  /**
8
- * me.game represents your current game, it contains all the objects,
8
+ * game represents your current game, it contains all the objects,
9
9
  * tilemap layers, current viewport, collision map, etc...<br>
10
- * me.game is also responsible for updating (each frame) the object status and draw them.
10
+ * game is also responsible for updating (each frame) the object status and draw them.
11
11
  * @namespace game
12
12
  */
13
13
 
@@ -17,7 +17,7 @@ class Ellipse {
17
17
  * @public
18
18
  * @type {Vector2d}
19
19
  * @name pos
20
- * @memberof Ellipse.prototype
20
+ * @memberof Ellipse
21
21
  */
22
22
  this.pos = pool.pull("Vector2d");
23
23
 
@@ -32,7 +32,7 @@ class Ellipse {
32
32
  * @public
33
33
  * @type {number}
34
34
  * @name radius
35
- * @memberof Ellipse.prototype
35
+ * @memberof Ellipse
36
36
  */
37
37
  this.radius = NaN;
38
38
 
@@ -41,7 +41,7 @@ class Ellipse {
41
41
  * @public
42
42
  * @type {Vector2d}
43
43
  * @name radiusV
44
- * @memberof Ellipse.prototype
44
+ * @memberof Ellipse
45
45
  */
46
46
  this.radiusV = pool.pull("Vector2d");
47
47
 
@@ -50,7 +50,7 @@ class Ellipse {
50
50
  * @public
51
51
  * @type {Vector2d}
52
52
  * @name radiusSq
53
- * @memberof Ellipse.prototype
53
+ * @memberof Ellipse
54
54
  */
55
55
  this.radiusSq = pool.pull("Vector2d");
56
56
 
@@ -59,7 +59,7 @@ class Ellipse {
59
59
  * @public
60
60
  * @type {Vector2d}
61
61
  * @name ratio
62
- * @memberof Ellipse.prototype
62
+ * @memberof Ellipse
63
63
  */
64
64
  this.ratio = pool.pull("Vector2d");
65
65
 
@@ -76,7 +76,7 @@ class Ellipse {
76
76
  /**
77
77
  * set new value to the Ellipse shape
78
78
  * @name setShape
79
- * @memberof Ellipse.prototype
79
+ * @memberof Ellipse
80
80
  * @function
81
81
  * @param {number} x the center x coordinate of the ellipse
82
82
  * @param {number} y the center y coordinate of the ellipse
@@ -106,7 +106,7 @@ class Ellipse {
106
106
  /**
107
107
  * Rotate this Ellipse (counter-clockwise) by the specified angle (in radians).
108
108
  * @name rotate
109
- * @memberof Ellipse.prototype
109
+ * @memberof Ellipse
110
110
  * @function
111
111
  * @param {number} angle The angle to rotate (in radians)
112
112
  * @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
@@ -123,7 +123,7 @@ class Ellipse {
123
123
  /**
124
124
  * Scale this Ellipse by the specified scalar.
125
125
  * @name scale
126
- * @memberof Ellipse.prototype
126
+ * @memberof Ellipse
127
127
  * @function
128
128
  * @param {number} x
129
129
  * @param {number} [y=x]
@@ -142,7 +142,7 @@ class Ellipse {
142
142
  /**
143
143
  * Scale this Ellipse by the specified vector.
144
144
  * @name scale
145
- * @memberof Ellipse.prototype
145
+ * @memberof Ellipse
146
146
  * @function
147
147
  * @param {Vector2d} v
148
148
  * @returns {Ellipse} Reference to this object for method chaining
@@ -154,7 +154,7 @@ class Ellipse {
154
154
  /**
155
155
  * apply the given transformation matrix to this ellipse
156
156
  * @name transform
157
- * @memberof Ellipse.prototype
157
+ * @memberof Ellipse
158
158
  * @function
159
159
  * @param {Matrix2d} matrix the transformation matrix
160
160
  * @returns {Polygon} Reference to this object for method chaining
@@ -167,7 +167,7 @@ class Ellipse {
167
167
  /**
168
168
  * translate the circle/ellipse by the specified offset
169
169
  * @name translate
170
- * @memberof Ellipse.prototype
170
+ * @memberof Ellipse
171
171
  * @function
172
172
  * @param {number} x x offset
173
173
  * @param {number} y y offset
@@ -176,7 +176,7 @@ class Ellipse {
176
176
  /**
177
177
  * translate the circle/ellipse by the specified vector
178
178
  * @name translate
179
- * @memberof Ellipse.prototype
179
+ * @memberof Ellipse
180
180
  * @function
181
181
  * @param {Vector2d} v vector offset
182
182
  * @returns {Ellipse} this ellipse
@@ -204,7 +204,7 @@ class Ellipse {
204
204
  /**
205
205
  * check if this circle/ellipse contains the specified point
206
206
  * @name contains
207
- * @memberof Ellipse.prototype
207
+ * @memberof Ellipse
208
208
  * @function
209
209
  * @param {Vector2d} point
210
210
  * @returns {boolean} true if contains
@@ -213,7 +213,7 @@ class Ellipse {
213
213
  /**
214
214
  * check if this circle/ellipse contains the specified point
215
215
  * @name contains
216
- * @memberof Ellipse.prototype
216
+ * @memberof Ellipse
217
217
  * @function
218
218
  * @param {number} x x coordinate
219
219
  * @param {number} y y coordinate
@@ -245,7 +245,7 @@ class Ellipse {
245
245
  /**
246
246
  * returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
247
247
  * @name getBounds
248
- * @memberof Ellipse.prototype
248
+ * @memberof Ellipse
249
249
  * @function
250
250
  * @returns {Bounds} this shape bounding box Rectangle object
251
251
  */
@@ -259,7 +259,7 @@ class Ellipse {
259
259
  /**
260
260
  * clone this Ellipse
261
261
  * @name clone
262
- * @memberof Ellipse.prototype
262
+ * @memberof Ellipse
263
263
  * @function
264
264
  * @returns {Ellipse} new Ellipse
265
265
  */
@@ -15,7 +15,7 @@ class Line extends Polygon {
15
15
  /**
16
16
  * Returns true if the Line contains the given point
17
17
  * @name contains
18
- * @memberof Line.prototype
18
+ * @memberof Line
19
19
  * @function
20
20
  * @param {Vector2d} point
21
21
  * @returns {boolean} true if contains
@@ -24,7 +24,7 @@ class Line extends Polygon {
24
24
  /**
25
25
  * Returns true if the Line contains the given point
26
26
  * @name contains
27
- * @memberof Line.prototype
27
+ * @memberof Line
28
28
  * @function
29
29
  * @param {number} x x coordinate
30
30
  * @param {number} y y coordinate
@@ -58,7 +58,7 @@ class Line extends Polygon {
58
58
  * Computes the calculated collision edges and normals.
59
59
  * This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
60
60
  * @name recalc
61
- * @memberof Line.prototype
61
+ * @memberof Line
62
62
  * @function
63
63
  * @returns {Line} this instance for objecf chaining
64
64
  */
@@ -94,7 +94,7 @@ class Line extends Polygon {
94
94
  /**
95
95
  * clone this line segment
96
96
  * @name clone
97
- * @memberof Line.prototype
97
+ * @memberof Line
98
98
  * @function
99
99
  * @returns {Line} new Line
100
100
  */
@@ -34,7 +34,7 @@ class Path2D {
34
34
  /**
35
35
  * begin a new path
36
36
  * @name beginPath
37
- * @memberof Path2D.prototype
37
+ * @memberof Path2D
38
38
  * @function
39
39
  */
40
40
  beginPath() {
@@ -50,7 +50,7 @@ class Path2D {
50
50
  * It tries to draw a straight line from the current point to the start.
51
51
  * If the shape has already been closed or has only one point, this function does nothing.
52
52
  * @name closePath
53
- * @memberof Path2D.prototype
53
+ * @memberof Path2D
54
54
  * @function
55
55
  */
56
56
  closePath() {
@@ -63,7 +63,7 @@ class Path2D {
63
63
  /**
64
64
  * triangulate the shape defined by this path into an array of triangles
65
65
  * @name triangulatePath
66
- * @memberof Path2D.prototype
66
+ * @memberof Path2D
67
67
  * @function
68
68
  * @returns {Vector2d[]}
69
69
  */
@@ -94,7 +94,7 @@ class Path2D {
94
94
  /**
95
95
  * moves the starting point of the current path to the (x, y) coordinates.
96
96
  * @name moveTo
97
- * @memberof Path2D.prototype
97
+ * @memberof Path2D
98
98
  * @function
99
99
  * @param {number} x the x-axis (horizontal) coordinate of the point.
100
100
  * @param {number} y the y-axis (vertical) coordinate of the point.
@@ -106,7 +106,7 @@ class Path2D {
106
106
  /**
107
107
  * connects the last point in the current patch to the (x, y) coordinates with a straight line.
108
108
  * @name lineTo
109
- * @memberof Path2D.prototype
109
+ * @memberof Path2D
110
110
  * @function
111
111
  * @param {number} x the x-axis coordinate of the line's end point.
112
112
  * @param {number} y the y-axis coordinate of the line's end point.
@@ -119,7 +119,7 @@ class Path2D {
119
119
  * adds an arc to the current path which is centered at (x, y) position with the given radius,
120
120
  * starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to clockwise).
121
121
  * @name arc
122
- * @memberof Path2D.prototype
122
+ * @memberof Path2D
123
123
  * @function
124
124
  * @param {number} x the horizontal coordinate of the arc's center.
125
125
  * @param {number} y the vertical coordinate of the arc's center.
@@ -169,7 +169,7 @@ class Path2D {
169
169
  /**
170
170
  * adds a circular arc to the path with the given control points and radius, connected to the previous point by a straight line.
171
171
  * @name arcTo
172
- * @memberof Path2D.prototype
172
+ * @memberof Path2D
173
173
  * @function
174
174
  * @param {number} x the x-axis coordinate of the first control point.
175
175
  * @param {number} y the y-axis coordinate of the first control point.
@@ -218,7 +218,7 @@ class Path2D {
218
218
  * adds an elliptical arc to the path which is centered at (x, y) position with the radii radiusX and radiusY
219
219
  * starting at startAngle and ending at endAngle going in the given direction by counterclockwise.
220
220
  * @name ellipse
221
- * @memberof Path2D.prototype
221
+ * @memberof Path2D
222
222
  * @function
223
223
  * @param {number} x the x-axis (horizontal) coordinate of the ellipse's center.
224
224
  * @param {number} y the y-axis (vertical) coordinate of the ellipse's center.
@@ -278,7 +278,7 @@ class Path2D {
278
278
  /**
279
279
  * creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
280
280
  * @name rect
281
- * @memberof Path2D.prototype
281
+ * @memberof Path2D
282
282
  * @function
283
283
  * @param {number} x the x-axis coordinate of the rectangle's starting point.
284
284
  * @param {number} y the y-axis coordinate of the rectangle's starting point.
@@ -296,7 +296,7 @@ class Path2D {
296
296
  /**
297
297
  * adds an rounded rectangle to the current path.
298
298
  * @name roundRect
299
- * @memberof Path2D.prototype
299
+ * @memberof Path2D
300
300
  * @function
301
301
  * @param {number} x the x-axis coordinate of the rectangle's starting point.
302
302
  * @param {number} y the y-axis coordinate of the rectangle's starting point.
@@ -25,7 +25,7 @@ class Polygon {
25
25
  * @public
26
26
  * @type {Vector2d}
27
27
  * @name pos
28
- * @memberof Polygon.prototype
28
+ * @memberof Polygon
29
29
  */
30
30
  this.pos = pool.pull("Vector2d");
31
31
 
@@ -34,7 +34,7 @@ class Polygon {
34
34
  * @ignore
35
35
  * @type {Bounds}
36
36
  * @name _bounds
37
- * @memberof Polygon.prototype
37
+ * @memberof Polygon
38
38
  */
39
39
  this._bounds;
40
40
 
@@ -44,7 +44,7 @@ class Polygon {
44
44
  * @public
45
45
  * @type {Vector2d[]}
46
46
  * @name points
47
- * @memberof Polygon.prototype
47
+ * @memberof Polygon
48
48
  */
49
49
  this.points = [];
50
50
 
@@ -83,7 +83,7 @@ class Polygon {
83
83
  /**
84
84
  * set new value to the Polygon
85
85
  * @name setShape
86
- * @memberof Polygon.prototype
86
+ * @memberof Polygon
87
87
  * @function
88
88
  * @param {number} x position of the Polygon
89
89
  * @param {number} y position of the Polygon
@@ -99,7 +99,7 @@ class Polygon {
99
99
  /**
100
100
  * set the vertices defining this Polygon
101
101
  * @name setVertices
102
- * @memberof Polygon.prototype
102
+ * @memberof Polygon
103
103
  * @function
104
104
  * @param {Vector2d[]} vertices array of vector or vertice defining the Polygon
105
105
  * @returns {Polygon} this instance for objecf chaining
@@ -139,7 +139,7 @@ class Polygon {
139
139
  /**
140
140
  * apply the given transformation matrix to this Polygon
141
141
  * @name transform
142
- * @memberof Polygon.prototype
142
+ * @memberof Polygon
143
143
  * @function
144
144
  * @param {Matrix2d} m the transformation matrix
145
145
  * @returns {Polygon} Reference to this object for method chaining
@@ -158,7 +158,7 @@ class Polygon {
158
158
  /**
159
159
  * apply an isometric projection to this shape
160
160
  * @name toIso
161
- * @memberof Polygon.prototype
161
+ * @memberof Polygon
162
162
  * @function
163
163
  * @returns {Polygon} Reference to this object for method chaining
164
164
  */
@@ -169,7 +169,7 @@ class Polygon {
169
169
  /**
170
170
  * apply a 2d projection to this shape
171
171
  * @name to2d
172
- * @memberof Polygon.prototype
172
+ * @memberof Polygon
173
173
  * @function
174
174
  * @returns {Polygon} Reference to this object for method chaining
175
175
  */
@@ -180,7 +180,7 @@ class Polygon {
180
180
  /**
181
181
  * Rotate this Polygon (counter-clockwise) by the specified angle (in radians).
182
182
  * @name rotate
183
- * @memberof Polygon.prototype
183
+ * @memberof Polygon
184
184
  * @function
185
185
  * @param {number} angle The angle to rotate (in radians)
186
186
  * @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
@@ -202,7 +202,7 @@ class Polygon {
202
202
  /**
203
203
  * Scale this Polygon by the given scalar.
204
204
  * @name scale
205
- * @memberof Polygon.prototype
205
+ * @memberof Polygon
206
206
  * @function
207
207
  * @param {number} x
208
208
  * @param {number} [y=x]
@@ -224,7 +224,7 @@ class Polygon {
224
224
  /**
225
225
  * Scale this Polygon by the given vector
226
226
  * @name scaleV
227
- * @memberof Polygon.prototype
227
+ * @memberof Polygon
228
228
  * @function
229
229
  * @param {Vector2d} v
230
230
  * @returns {Polygon} Reference to this object for method chaining
@@ -237,7 +237,7 @@ class Polygon {
237
237
  * Computes the calculated collision polygon.
238
238
  * This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
239
239
  * @name recalc
240
- * @memberof Polygon.prototype
240
+ * @memberof Polygon
241
241
  * @function
242
242
  * @returns {Polygon} Reference to this object for method chaining
243
243
  */
@@ -281,7 +281,7 @@ class Polygon {
281
281
  /**
282
282
  * returns a list of indices for all triangles defined in this polygon
283
283
  * @name getIndices
284
- * @memberof Polygon.prototype
284
+ * @memberof Polygon
285
285
  * @function
286
286
  * @returns {Array} an array of vertex indices for all triangles forming this polygon.
287
287
  */
@@ -295,7 +295,7 @@ class Polygon {
295
295
  /**
296
296
  * Returns true if the vertices composing this polygon form a convex shape (vertices must be in clockwise order).
297
297
  * @name isConvex
298
- * @memberof Polygon.prototype
298
+ * @memberof Polygon
299
299
  * @function
300
300
  * @returns {boolean} true if the vertices are convex, false if not, null if not computable
301
301
  */
@@ -342,7 +342,7 @@ class Polygon {
342
342
  /**
343
343
  * translate the Polygon by the specified offset
344
344
  * @name translate
345
- * @memberof Polygon.prototype
345
+ * @memberof Polygon
346
346
  * @function
347
347
  * @param {number} x x offset
348
348
  * @param {number} y y offset
@@ -351,7 +351,7 @@ class Polygon {
351
351
  /**
352
352
  * translate the Polygon by the specified vector
353
353
  * @name translate
354
- * @memberof Polygon.prototype
354
+ * @memberof Polygon
355
355
  * @function
356
356
  * @param {Vector2d} v vector offset
357
357
  * @returns {Polygon} Reference to this object for method chaining
@@ -379,14 +379,14 @@ class Polygon {
379
379
  /**
380
380
  * Shifts the Polygon to the given position vector.
381
381
  * @name shift
382
- * @memberof Polygon.prototype
382
+ * @memberof Polygon
383
383
  * @function
384
384
  * @param {Vector2d} position
385
385
  */
386
386
  /**
387
387
  * Shifts the Polygon to the given x, y position.
388
388
  * @name shift
389
- * @memberof Polygon.prototype
389
+ * @memberof Polygon
390
390
  * @function
391
391
  * @param {number} x
392
392
  * @param {number} y
@@ -412,7 +412,7 @@ class Polygon {
412
412
  * (Note: it is highly recommended to first do a hit test on the corresponding <br>
413
413
  * bounding rect, as the function can be highly consuming with complex shapes)
414
414
  * @name contains
415
- * @memberof Polygon.prototype
415
+ * @memberof Polygon
416
416
  * @function
417
417
  * @param {Vector2d} point
418
418
  * @returns {boolean} true if contains
@@ -423,7 +423,7 @@ class Polygon {
423
423
  * (Note: it is highly recommended to first do a hit test on the corresponding <br>
424
424
  * bounding rect, as the function can be highly consuming with complex shapes)
425
425
  * @name contains
426
- * @memberof Polygon.prototype
426
+ * @memberof Polygon
427
427
  * @function
428
428
  * @param {number} x x coordinate
429
429
  * @param {number} y y coordinate
@@ -461,7 +461,7 @@ class Polygon {
461
461
  /**
462
462
  * returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
463
463
  * @name getBounds
464
- * @memberof Polygon.prototype
464
+ * @memberof Polygon
465
465
  * @function
466
466
  * @returns {Bounds} this shape bounding box Rectangle object
467
467
  */
@@ -476,7 +476,7 @@ class Polygon {
476
476
  * update the bounding box for this shape.
477
477
  * @ignore
478
478
  * @name updateBounds
479
- * @memberof Polygon.prototype
479
+ * @memberof Polygon
480
480
  * @function
481
481
  * @returns {Bounds} this shape bounding box Rectangle object
482
482
  */
@@ -492,7 +492,7 @@ class Polygon {
492
492
  /**
493
493
  * clone this Polygon
494
494
  * @name clone
495
- * @memberof Polygon.prototype
495
+ * @memberof Polygon
496
496
  * @function
497
497
  * @returns {Polygon} new Polygon
498
498
  */