melonjs 9.1.0 → 10.0.1

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.
Files changed (78) hide show
  1. package/{LICENSE → LICENSE.md} +0 -0
  2. package/README.md +93 -57
  3. package/dist/melonjs.js +10334 -11179
  4. package/dist/melonjs.min.js +4 -10
  5. package/dist/melonjs.module.d.ts +13206 -0
  6. package/dist/melonjs.module.js +9913 -10872
  7. package/package.json +19 -14
  8. package/src/audio/audio.js +477 -553
  9. package/src/camera/camera2d.js +67 -65
  10. package/src/entity/draggable.js +26 -35
  11. package/src/entity/droptarget.js +17 -14
  12. package/src/entity/entity.js +59 -79
  13. package/src/game.js +194 -204
  14. package/src/index.js +12 -30
  15. package/src/input/gamepad.js +8 -19
  16. package/src/input/keyboard.js +4 -4
  17. package/src/input/pointer.js +14 -12
  18. package/src/input/pointerevent.js +15 -13
  19. package/src/lang/deprecated.js +2 -887
  20. package/src/level/level.js +3 -3
  21. package/src/level/tiled/TMXGroup.js +7 -11
  22. package/src/level/tiled/TMXLayer.js +33 -32
  23. package/src/level/tiled/TMXTileMap.js +15 -19
  24. package/src/level/tiled/TMXTileset.js +5 -5
  25. package/src/level/tiled/TMXUtils.js +3 -3
  26. package/src/level/tiled/renderer/TMXRenderer.js +4 -0
  27. package/src/loader/loader.js +8 -23
  28. package/src/loader/loadingscreen.js +51 -60
  29. package/src/math/matrix3.js +1 -1
  30. package/src/particles/emitter.js +36 -39
  31. package/src/particles/particle.js +27 -12
  32. package/src/particles/particlecontainer.js +17 -16
  33. package/src/physics/body.js +80 -118
  34. package/src/physics/collision.js +5 -235
  35. package/src/physics/detector.js +235 -0
  36. package/src/physics/quadtree.js +14 -14
  37. package/src/physics/world.js +84 -18
  38. package/src/plugin/plugin.js +26 -24
  39. package/src/polyfill/console.js +9 -14
  40. package/src/renderable/GUI.js +48 -62
  41. package/src/renderable/collectable.js +11 -4
  42. package/src/renderable/colorlayer.js +28 -26
  43. package/src/renderable/container.js +120 -96
  44. package/src/renderable/imagelayer.js +94 -93
  45. package/src/renderable/renderable.js +164 -138
  46. package/src/renderable/sprite.js +42 -44
  47. package/src/renderable/trigger.js +24 -17
  48. package/src/shapes/ellipse.js +27 -27
  49. package/src/shapes/line.js +12 -8
  50. package/src/shapes/poly.js +77 -49
  51. package/src/shapes/rectangle.js +193 -268
  52. package/src/state/stage.js +23 -25
  53. package/src/state/state.js +35 -86
  54. package/src/system/device.js +233 -285
  55. package/src/system/event.js +485 -432
  56. package/src/system/pooling.js +61 -54
  57. package/src/system/save.js +17 -16
  58. package/src/system/timer.js +34 -38
  59. package/src/text/bitmaptext.js +44 -46
  60. package/src/text/text.js +39 -34
  61. package/src/tweens/easing.js +0 -2
  62. package/src/tweens/interpolation.js +3 -8
  63. package/src/tweens/tween.js +332 -351
  64. package/src/utils/function.js +6 -8
  65. package/src/utils/utils.js +34 -30
  66. package/src/video/canvas/canvas_renderer.js +13 -8
  67. package/src/video/renderer.js +8 -7
  68. package/src/video/texture.js +8 -8
  69. package/src/video/texture_cache.js +5 -5
  70. package/src/video/video.js +373 -403
  71. package/src/video/webgl/glshader.js +2 -2
  72. package/src/video/webgl/webgl_compositor.js +14 -8
  73. package/src/video/webgl/webgl_renderer.js +21 -19
  74. package/plugins/debug/debugPanel.js +0 -770
  75. package/plugins/debug/font/PressStart2P.fnt +0 -100
  76. package/plugins/debug/font/PressStart2P.ltr +0 -1
  77. package/plugins/debug/font/PressStart2P.png +0 -0
  78. package/plugins/debug/particleDebugPanel.js +0 -303
File without changes
package/README.md CHANGED
@@ -1,46 +1,55 @@
1
- melonJS
2
- =======
1
+ melonJS 2
2
+ =========
3
3
  [![Build Status](https://travis-ci.org/melonjs/melonJS.svg)](https://travis-ci.org/melonjs/melonJS)
4
4
  [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/melonjs/melonJS.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/melonjs/melonJS/context:javascript)
5
5
  [![Build Size](https://badgen.net/bundlephobia/min/melonjs)](https://bundlephobia.com/result?p=melonjs)
6
6
  [![Dependencies](https://img.shields.io/david/melonjs/melonJS.svg)](https://david-dm.org/melonjs/melonJS)
7
- [![jsDeliver](https://data.jsdelivr.com/v1/package/npm/melonjs/badge)](https://www.jsdelivr.com/package/npm/melonjs)
7
+ [![NPM Package](https://img.shields.io/npm/v/melonjs)](https://www.npmjs.com/package/melonjs)
8
8
  [![Boss Bounty Badge](https://img.shields.io/endpoint.svg?url=https://api.boss.dev/badge/enabled/melonjs/melonJS)](https://www.boss.dev/issues/repo/melonjs/melonJS)
9
9
 
10
10
 
11
- A fresh & lightweight HTML5 game engine
11
+ A fresh, _modern_ & lightweight HTML5 game engine
12
12
  -------------------------------------------------------------------------------
13
13
  ![melonJS](http://melonjs.org/media/alex4-github.png)
14
14
 
15
- Copyright (C) 2011 - 2021 Olivier Biot
15
+ melonJS 2 is a modern version of the melonJS game engine. It has been rebuilt almost entirely using ES6 class, inheritance and semantic, and is bundled using Rollup to provide modern features such as transpiling and tree-shaking.
16
16
 
17
- [melonJS](http://melonjs.org/) is licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
17
+ >Note: migrating an existing project to melonJS 2 (version 10.0 and higher) will definitely break your game (ES6 semantic, no more Jay inheritance, nodeJS event emitter, and no backward compatibility with deprecated legacy APIs), and you might want to read first this small step by step guide on [upgrading to melonJS 2](https://github.com/melonjs/melonJS/wiki/Upgrading-to-melonJS-2). If you are looking at the legacy version (9.x and lower) of melonJS, you can find it [here](https://github.com/melonjs/melonJS/tree/legacy) under the _legacy_ branch.
18
+
19
+ [melonJS](http://melonjs.org/) is open-source, licensed under the [MIT License](LICENSE.md), and actively developed and maintained with the help of a small team of enthusiasts at AltByte in Singapore.
18
20
 
19
21
  About melonJS
20
22
  -------------------------------------------------------------------------------
21
23
 
22
- [melonJS](http://melonjs.org/) is the result of our enthusiasm & experiments with Javascript,
23
- and currently features :
24
+ [melonJS](http://melonjs.org/) is a fully featured game engine :
24
25
 
25
- - A fresh & lightweight 2D sprite-based engine
26
+ Compatibility
26
27
  - Standalone library (does not rely on anything else, except a HTML5 capable browser)
27
28
  - Compatible with all major browsers (Chrome, Safari, Firefox, Opera, Edge) and mobile devices
28
- - Fast WebGL renderer for desktop and mobile devices with fallback to Canvas rendering
29
+
30
+ Graphics
31
+ - 2D sprite-based graphic engine
32
+ - Fast WebGL 1 & 2 renderer for desktop and mobile devices with fallback to Canvas rendering
29
33
  - High DPI resolution & Canvas advanced auto scaling
30
- - Web Audio support with fallback to Multi-channel HTML5 audio
31
- - Lightweight physics implementation to ensure low cpu requirements
32
- - Polygon (SAT) based collision algorithm for accurate detection and response
33
- - Fast Broad-phase collision detection using spatial partitioning
34
- - 3rd party tools support for physic body definition such as [PhysicsEditor](https://www.codeandweb.com/physicseditor)
35
- - Advanced math API for Vector and Matrix
36
- - Tween Effects, Transition effects
37
- - Basic set of Object Entities and GUI elements included
38
- - Pooling support for object recycling
39
- - Basic Particle System
40
34
  - Sprite with Animation management
35
+ - built-in effects such as tinting and masking
41
36
  - Standard spritesheet, single and multiple Packed Textures support
42
- - 3rd party tools support for Texture Packing such as [TexturePacker](https://www.codeandweb.com/texturepacker), [Free Texture Packer](http://free-tex-packer.com), [ShoeBox](https://renderhjs.net/shoebox/)
43
- - A state manager (to easily manage loading, menu, options, in-game state)
37
+ - System & Bitmap Text
38
+
39
+ Sound
40
+ - Web Audio support with spatial audio or stereo panning based on [Howler](https://howlerjs.com)
41
+ - fallback to Multi-channel HTML5 audio for legacy browsers
42
+
43
+ Physic
44
+ - Polygon (SAT) based collision algorithm for accurate detection and response
45
+ - Fast Broad-phase collision detection using spatial partitioning
46
+ - Collision filtering for optimized automatic collision detection
47
+
48
+ Input
49
+ - Mouse and Touch device support (with mouse emulation)
50
+ - Device motion & accelerometer support
51
+
52
+ Level Editor
44
53
  - Tiled map format version +1.0 integration for easy level design
45
54
  - Uncompressed Plain, Base64, CSV and JSON encoded XML tilemap loading
46
55
  - Orthogonal, Isometric and Hexagonal maps (both normal and staggered)
@@ -54,13 +63,29 @@ and currently features :
54
63
  - Dynamic Layer and Object/Group ordering
55
64
  - Dynamic Entity loading
56
65
  - Shape based Tile collision support
57
- - System & Bitmap fonts
58
- - Mouse and Touch device support (with mouse emulation)
59
- - Device motion & accelerometer support
60
- - Built-in support for 3rd party Application Wrappers such as [Cordova](https://cordova.apache.org)
61
- - Asynchronous publish/subscribe pattern messaging support (minPubSub)
66
+
67
+ Assets
68
+ - Asynchronous asset loading
62
69
  - A fully customizable preloader
63
- - As light as [~70kb](https://bundlephobia.com/result?p=melonjs@latest) minified & gzipped
70
+
71
+ And Also
72
+ - A state manager (to easily manage loading, menu, options, in-game state)
73
+ - Tween Effects, Transition effects
74
+ - Pooling support for object recycling
75
+ - Basic Particle System
76
+ - nodeJS EventEmitter based event system
77
+
78
+ Tools integration
79
+ -------------------------------------------------------------------------------
80
+ [![Free Texture Packer](https://user-images.githubusercontent.com/4033090/136762061-1d3a0dfe-dbe0-4d3d-808d-47a49ecf5309.png "Free Texture Packer")](http://free-tex-packer.com)
81
+ [![TexturePacker](https://user-images.githubusercontent.com/4033090/136762472-bc55a638-c69b-4ff5-9d03-c684c8bea0ea.png "TexturePacker")](https://www.codeandweb.com/texturepacker)
82
+ [![PhysicsEditor](https://user-images.githubusercontent.com/4033090/136762890-b1010c7f-cb19-4d35-a3f1-f5048db07835.png "PhysicsEditor")](https://www.codeandweb.com/physicseditor)
83
+ [![ShoeBox](https://user-images.githubusercontent.com/4033090/136762705-92027d94-d87c-4a95-b051-26647410248d.png "ShoeBox")](https://renderhjs.net/shoebox/)
84
+ [![Tiled](https://user-images.githubusercontent.com/4033090/136762999-5a7f377b-4136-4205-9fe0-83728c90cb9b.png "Tiled")](https://www.mapeditor.org)
85
+ [![Cordova](https://user-images.githubusercontent.com/4033090/136763147-6d157ce6-6921-437e-bb8f-0287b86109da.png "Cordova")](https://cordova.apache.org)
86
+
87
+ Tools integration and usage with melonJS is documented in our [Wiki](https://github.com/melonjs/melonJS/wiki#third-party-tools-usage).
88
+
64
89
 
65
90
  Using melonJS
66
91
  -------------------------------------------------------------------------------
@@ -68,7 +93,7 @@ Using melonJS
68
93
  Basic Example
69
94
 
70
95
  ```JavaScript
71
- import * as me from "melonjs.module.js"
96
+ import * as me from "melonjs.module.js";
72
97
 
73
98
  me.device.onReady(function () {
74
99
  // initialize the display canvas once the device/browser is ready
@@ -96,65 +121,68 @@ me.device.onReady(function () {
96
121
  Documentation :
97
122
 
98
123
  * [Online API](http://melonjs.github.io/melonJS/docs/) ([offline](https://github.com/melonjs/melonJS/archive/gh-pages.zip) version under the `docs` directory)
99
- * [Examples](https://melonjs.github.io/examples/)
100
124
 
101
125
  For your first time using melonJS, follow these tutorials :
102
126
 
103
127
  - [Platformer](http://melonjs.github.io/tutorial-platformer/) Step by Step Tutorial.
104
128
  - [Space Invaders](http://melonjs.github.io/tutorial-space-invaders/) Step by Step Tutorial.
105
129
 
130
+ > Note: current version of both the tutorials are not compatible with the ES6 version.
131
+
106
132
  You may find it useful to skim the overview found at the wiki [Details & Usage](https://github.com/melonjs/melonJS/wiki#details--usage)
107
133
 
108
- When starting your own projects, checkout the [boilerplate](https://github.com/melonjs/boilerplate)
134
+ When starting your own projects, checkout our [es6 boilerplate](https://github.com/melonjs/es6-boilerplate)
135
+
136
+ Demos
137
+ -------------------------------------------------------------------------------
138
+
139
+ A few demos of melonJS capabilities :
140
+
141
+ * [Platformer Demo](https://melonjs.github.io/examples/examples/platformer/)
142
+ * [Isometric Demo](https://melonjs.github.io/examples/examples/isometric_rpg/)
143
+ * [Sprite Demo](https://melonjs.github.io/examples/examples/sprite/)
144
+ * [Masking Demo](https://melonjs.github.io/examples/examples/masking/)
145
+ * [Primitive Drawing Demo](https://melonjs.github.io/examples/examples/graphics/)
146
+ * [UI Demo](https://melonjs.github.io/examples/examples/UI/)
147
+
148
+ More examples are available [here](https://melonjs.github.io/examples/)
109
149
 
110
150
  Download melonJS
111
151
  -------------------------------------------------------------------------------
112
152
 
113
153
  The latest builds with corresponding release note are available for direct download [here](https://github.com/melonjs/melonJS/releases).
114
154
 
115
- Since version 9.0.0 melonJS provides different build options :
155
+ Since version 10.0.0 melonJS provides different build options :
116
156
 
117
157
  | build | description |
118
158
  | ------------------- | ----------- |
119
- | `melonjs.js` | a legacy ES5 UMD Bundle (directly transpiled from the ES6 version) including full API backward compatibility with previous versions |
120
- | `melonjs.min.js` | a minified version of the ES5 UMD bundle version |
121
- | `melonjs.module.js` | a ES6 Module Bundle, for those living on the edge, and with no backward compatibility (note: this will break your game when upgrading!) |
122
-
123
- > Note: current version of both the tutorials and the debugPanel are not compatible with the ES6 version.
159
+ | `melonjs.module.js` | the ES6 Module (ESM) Bundle |
160
+ | `melonjs.module.d.ts` | typescript declaration file for the ES6 Module (ESM) Bundle |
161
+ | `melonjs.js` | a ES5 UMD Bundle (directly transpiled from the ES6 version) |
162
+ | `melonjs.min.js` | a minified version of the ES5 UMD bundle |
124
163
 
125
164
  Alternatively, the latest version of melonJS can be installed through [NPM](https://www.npmjs.com/package/melonjs) :
126
165
 
127
166
  $ npm install melonjs
128
167
 
129
- If you need to import the ES6 module of melonjs :
130
-
131
- $ import * as me from "melonjs.module.js";
168
+ If you need to import the ES6 module of melonjs (e.g. for Webpack):
132
169
 
133
- > Note: when using the es6 module, deprecated methods need to be manually applied, see [here](http://melonjs.github.io/melonJS/docs/me.deprecated.html#.apply)
170
+ $ import * as me from 'melonjs/dist/melonjs.module.js';
134
171
 
135
172
  Or can simply be added to your html, through a content delivery network (CDN) URL, using for example :
136
173
 
137
174
  ```html
138
- <!-- load the ES5 UMD bundle of melonJS v9.0.0 -->
139
- <script src="https://cdn.jsdelivr.net/npm/melonjs@9.0.0/dist/melonjs.js"></script>
140
- <!-- load the ES6 module bundle of melonJS v9.0.0 -->
141
- <script src="https://cdn.jsdelivr.net/npm/melonjs@9.0.0/dist/melonjs.module.js"></script>
175
+ <!-- load the ES5 UMD bundle of melonJS v10.0.0 -->
176
+ <script src="https://cdn.jsdelivr.net/npm/melonjs@10.0.0/dist/melonjs.js"></script>
177
+ <!-- load the ES6 module bundle of melonJS v10.0.0 -->
178
+ <script src="https://cdn.jsdelivr.net/npm/melonjs@10.0.0/dist/melonjs.module.js"></script>
142
179
  <!-- omit the version completely to get the latest one -->
143
180
  <!-- you should NOT use this in production -->
144
181
  <script src="https://cdn.jsdelivr.net/npm/melonjs/dist/melonjs.js"></script>
145
182
  <!-- add ".min" to any JS/CSS file to get a minified version -->
146
- <script src="https://cdn.jsdelivr.net/npm/melonjs@8.0.1/dist/melonjs.min.js"></script>
147
- ```
148
- and of course the debug panel :
149
- ```html
150
- <!-- load the latest debug panel -->
151
- <script src="https://cdn.jsdelivr.net/npm/melonjs/plugins/debug/debugPanel.js"></script>
152
- <!-- or a specific corresponding release -->
153
- <script src="https://cdn.jsdelivr.net/npm/melonjs@8.0.1/plugins/debug/debugPanel.js"></script>
183
+ <script src="https://cdn.jsdelivr.net/npm/melonjs@10.0.0/dist/melonjs.min.js"></script>
154
184
  ```
155
-
156
- > Note: "official" CDN and NPM install are only available from version 7.0.0 and onwards.
157
- > Note: ES6 version of melonJS is available from version 9.0.0 and onwards.
185
+ > Note: starting from the 10.0.0 version, the debug plugin is no longer provided as part of the melonJS library release, and has been moved to the official [boilerplate](https://github.com/melonjs/es6-boilerplate)
158
186
 
159
187
  Building melonJS
160
188
  -------------------------------------------------------------------------------
@@ -209,4 +237,12 @@ If you need technical support, you can contact us through the following channels
209
237
  * [melonJS wikipage](https://github.com/melonjs/melonJS/wiki)
210
238
  * [Discord](https://discord.gg/aur7JMk)
211
239
 
212
- For any other non technical related questions, feel free to also send us an [email](mailto:contact@melonjs.org).
240
+ For any other non technical related questions, feel free to also send us an [email](mailto:contact@melonjs.org)
241
+
242
+ Sponsors
243
+ -------------------------------------------------------------------------------
244
+ Support the development of melonJS by [becoming a sponsor](https://github.com/sponsors/melonjs). Get your logo in our README with a link to your site or become a backer and get your name in the [BACKERS](BACKERS.md) list. Any level of support is really appreciated and goes a long way !
245
+
246
+ [![Melon Gaming](https://user-images.githubusercontent.com/4033090/136695857-d098c27d-f4b2-4c71-8574-b5f4291779cb.png "Melon Gaming")](https://www.melongaming.com)
247
+
248
+ [![Altbyte Pte Ltd](https://user-images.githubusercontent.com/4033090/136692693-35dca8aa-5012-4a37-9ea2-51640d2e6d73.png "AltByte")]()