melonjs 14.2.0 → 14.4.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/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +2 -2
- package/dist/melonjs.mjs/_virtual/arraymultimap.js +2 -2
- package/dist/melonjs.mjs/_virtual/earcut.js +2 -2
- package/dist/melonjs.mjs/_virtual/howler.js +2 -2
- package/dist/melonjs.mjs/_virtual/index.js +2 -2
- package/dist/melonjs.mjs/_virtual/index2.js +2 -2
- package/dist/melonjs.mjs/_virtual/multimap.js +2 -2
- package/dist/melonjs.mjs/_virtual/setmultimap.js +2 -2
- package/dist/melonjs.mjs/application/application.js +141 -10
- package/dist/melonjs.mjs/application/header.js +34 -0
- package/dist/melonjs.mjs/application/resize.js +4 -2
- package/dist/melonjs.mjs/application/settings.js +28 -0
- package/dist/melonjs.mjs/audio/audio.js +2 -2
- package/dist/melonjs.mjs/camera/camera2d.js +3 -3
- package/dist/melonjs.mjs/const.js +32 -0
- package/dist/melonjs.mjs/entity/entity.js +2 -2
- package/dist/melonjs.mjs/game.js +1 -1
- package/dist/melonjs.mjs/geometries/ellipse.js +2 -2
- package/dist/melonjs.mjs/geometries/line.js +2 -2
- package/dist/melonjs.mjs/geometries/path2d.js +2 -2
- package/dist/melonjs.mjs/geometries/point.js +2 -2
- package/dist/melonjs.mjs/geometries/poly.js +2 -2
- package/dist/melonjs.mjs/geometries/rectangle.js +2 -2
- package/dist/melonjs.mjs/geometries/roundrect.js +2 -2
- package/dist/melonjs.mjs/index.js +44 -33
- package/dist/melonjs.mjs/input/gamepad.js +2 -2
- package/dist/melonjs.mjs/input/input.js +2 -2
- package/dist/melonjs.mjs/input/keyboard.js +2 -2
- package/dist/melonjs.mjs/input/pointer.js +3 -3
- package/dist/melonjs.mjs/input/pointerevent.js +3 -3
- package/dist/melonjs.mjs/lang/console.js +44 -0
- package/dist/melonjs.mjs/lang/deprecated.js +4 -40
- package/dist/melonjs.mjs/level/level.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +2 -23
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +68 -58
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +2 -64
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +10 -26
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +18 -84
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +2 -16
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +3 -10
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +37 -14
- package/dist/melonjs.mjs/level/tiled/constants.js +17 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +3 -6
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -14
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +38 -0
- package/dist/melonjs.mjs/loader/loader.js +5 -3
- package/dist/melonjs.mjs/loader/loadingscreen.js +3 -3
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +2 -2
- package/dist/melonjs.mjs/math/color.js +2 -2
- package/dist/melonjs.mjs/math/math.js +2 -2
- package/dist/melonjs.mjs/math/matrix2.js +2 -2
- package/dist/melonjs.mjs/math/matrix3.js +2 -2
- package/dist/melonjs.mjs/math/observable_vector2.js +2 -2
- package/dist/melonjs.mjs/math/observable_vector3.js +2 -2
- package/dist/melonjs.mjs/math/vector2.js +2 -2
- package/dist/melonjs.mjs/math/vector3.js +2 -2
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +2 -2
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +2 -2
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +2 -2
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +2 -2
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +2 -2
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +2 -2
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +2 -2
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +2 -2
- package/dist/melonjs.mjs/particles/emitter.js +2 -2
- package/dist/melonjs.mjs/particles/particle.js +2 -2
- package/dist/melonjs.mjs/particles/settings.js +2 -2
- package/dist/melonjs.mjs/physics/body.js +2 -2
- package/dist/melonjs.mjs/physics/bounds.js +2 -2
- package/dist/melonjs.mjs/physics/collision.js +4 -4
- package/dist/melonjs.mjs/physics/detector.js +175 -147
- package/dist/melonjs.mjs/physics/quadtree.js +2 -2
- package/dist/melonjs.mjs/physics/response.js +2 -2
- package/dist/melonjs.mjs/physics/sat.js +2 -2
- package/dist/melonjs.mjs/physics/world.js +11 -31
- package/dist/melonjs.mjs/plugin/plugin.js +4 -4
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +2 -2
- package/dist/melonjs.mjs/renderable/container.js +4 -88
- package/dist/melonjs.mjs/renderable/dragndrop.js +2 -2
- package/dist/melonjs.mjs/renderable/imagelayer.js +3 -3
- package/dist/melonjs.mjs/renderable/light2d.js +2 -2
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
- package/dist/melonjs.mjs/renderable/renderable.js +2 -2
- package/dist/melonjs.mjs/renderable/sprite.js +2 -2
- package/dist/melonjs.mjs/renderable/trigger.js +3 -3
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +2 -2
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +2 -2
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +2 -2
- package/dist/melonjs.mjs/state/stage.js +3 -3
- package/dist/melonjs.mjs/state/state.js +3 -3
- package/dist/melonjs.mjs/system/device.js +3 -23
- package/dist/melonjs.mjs/system/dom.js +2 -2
- package/dist/melonjs.mjs/system/event.js +2 -2
- package/dist/melonjs.mjs/system/platform.js +2 -2
- package/dist/melonjs.mjs/system/pooling.js +2 -2
- package/dist/melonjs.mjs/system/save.js +2 -2
- package/dist/melonjs.mjs/system/timer.js +2 -2
- package/dist/melonjs.mjs/text/bitmaptext.js +2 -2
- package/dist/melonjs.mjs/text/bitmaptextdata.js +2 -2
- package/dist/melonjs.mjs/text/glyph.js +2 -2
- package/dist/melonjs.mjs/text/text.js +2 -2
- package/dist/melonjs.mjs/text/textmetrics.js +2 -2
- package/dist/melonjs.mjs/text/textstyle.js +2 -2
- package/dist/melonjs.mjs/tweens/easing.js +2 -2
- package/dist/melonjs.mjs/tweens/interpolation.js +2 -2
- package/dist/melonjs.mjs/tweens/tween.js +3 -3
- package/dist/melonjs.mjs/utils/agent.js +2 -2
- package/dist/melonjs.mjs/utils/array.js +2 -2
- package/dist/melonjs.mjs/utils/file.js +2 -2
- package/dist/melonjs.mjs/utils/function.js +2 -2
- package/dist/melonjs.mjs/utils/string.js +2 -2
- package/dist/melonjs.mjs/utils/utils.js +2 -2
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +5 -2
- package/dist/melonjs.mjs/video/renderer.js +9 -2
- package/dist/melonjs.mjs/video/texture/atlas.js +2 -2
- package/dist/melonjs.mjs/video/texture/cache.js +2 -2
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +4 -3
- package/dist/melonjs.mjs/video/utils/autodetect.js +27 -0
- package/dist/melonjs.mjs/video/utils/resize.js +1 -1
- package/dist/melonjs.mjs/video/video.js +29 -158
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +2 -2
- package/dist/melonjs.mjs/video/webgl/glshader.js +3 -4
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +21 -3
- package/dist/melonjs.mjs/video/webgl/utils/program.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/string.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +2 -2
- package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +2 -2
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +5 -2
- package/dist/melonjs.module.js +20845 -20968
- package/dist/types/application/application.d.ts +148 -0
- package/dist/types/application/header.d.ts +5 -0
- package/dist/types/application/resize.d.ts +6 -0
- package/dist/types/application/settings.d.ts +18 -0
- package/dist/types/audio/audio.d.ts +267 -0
- package/dist/types/camera/camera2d.d.ts +289 -0
- package/dist/types/const.d.ts +21 -0
- package/dist/types/entity/entity.d.ts +98 -0
- package/{src/game.js → dist/types/game.d.ts} +3 -14
- package/dist/types/geometries/ellipse.d.ts +154 -0
- package/dist/types/geometries/line.d.ts +11 -0
- package/dist/types/geometries/path2d.d.ts +121 -0
- package/dist/types/geometries/point.d.ts +53 -0
- package/dist/types/geometries/poly.d.ts +222 -0
- package/dist/types/geometries/rectangle.d.ts +176 -0
- package/dist/types/geometries/roundrect.d.ts +52 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/input/gamepad.d.ts +95 -0
- package/dist/types/input/input.d.ts +15 -0
- package/dist/types/input/keyboard.d.ts +205 -0
- package/dist/types/input/pointer.d.ts +270 -0
- package/dist/types/input/pointerevent.d.ts +181 -0
- package/dist/types/lang/console.d.ts +7 -0
- package/dist/types/lang/deprecated.d.ts +45 -0
- package/dist/types/level/level.d.ts +134 -0
- package/dist/types/level/tiled/TMXGroup.d.ts +61 -0
- package/dist/types/level/tiled/TMXLayer.d.ts +158 -0
- package/dist/types/level/tiled/TMXObject.d.ts +133 -0
- package/dist/types/level/tiled/TMXTile.d.ts +64 -0
- package/dist/types/level/tiled/TMXTileMap.d.ts +142 -0
- package/dist/types/level/tiled/TMXTileset.d.ts +80 -0
- package/dist/types/level/tiled/TMXTilesetGroup.d.ts +26 -0
- package/dist/types/level/tiled/TMXUtils.d.ts +47 -0
- package/dist/types/level/tiled/constants.d.ts +5 -0
- package/dist/types/level/tiled/renderer/TMXHexagonalRenderer.d.ts +83 -0
- package/dist/types/level/tiled/renderer/TMXIsometricRenderer.d.ts +51 -0
- package/dist/types/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +43 -0
- package/dist/types/level/tiled/renderer/TMXRenderer.d.ts +63 -0
- package/dist/types/level/tiled/renderer/TMXStaggeredRenderer.d.ts +8 -0
- package/dist/types/level/tiled/renderer/autodetect.d.ts +9 -0
- package/dist/types/loader/loader.d.ts +181 -0
- package/dist/types/loader/loadingscreen.d.ts +18 -0
- package/dist/types/math/color.d.ts +170 -0
- package/dist/types/math/math.d.ts +165 -0
- package/dist/types/math/matrix2.d.ts +209 -0
- package/dist/types/math/matrix3.d.ts +236 -0
- package/dist/types/math/observable_vector2.d.ts +278 -0
- package/dist/types/math/observable_vector3.d.ts +277 -0
- package/dist/types/math/vector2.d.ts +327 -0
- package/dist/types/math/vector3.d.ts +332 -0
- package/dist/types/particles/emitter.d.ts +188 -0
- package/dist/types/particles/particle.d.ts +32 -0
- package/dist/types/particles/settings.d.ts +32 -0
- package/dist/types/physics/body.d.ts +330 -0
- package/dist/types/physics/bounds.d.ts +250 -0
- package/dist/types/physics/collision.d.ts +44 -0
- package/dist/types/physics/detector.d.ts +64 -0
- package/dist/types/physics/quadtree.d.ts +79 -0
- package/dist/types/physics/response.d.ts +37 -0
- package/dist/types/physics/sat.d.ts +48 -0
- package/dist/types/physics/world.d.ts +83 -0
- package/dist/types/plugin/plugin.d.ts +10 -0
- package/dist/types/polyfill/console.d.ts +0 -0
- package/dist/types/polyfill/index.d.ts +1 -0
- package/dist/types/polyfill/performance.d.ts +0 -0
- package/dist/types/polyfill/requestAnimationFrame.d.ts +1 -0
- package/dist/types/polyfill/roundrect.d.ts +0 -0
- package/dist/types/renderable/collectable.d.ts +19 -0
- package/dist/types/renderable/colorlayer.d.ts +28 -0
- package/dist/types/renderable/container.d.ts +302 -0
- package/dist/types/renderable/dragndrop.d.ts +118 -0
- package/dist/types/renderable/imagelayer.d.ts +106 -0
- package/dist/types/renderable/light2d.d.ts +58 -0
- package/dist/types/renderable/nineslicesprite.d.ts +59 -0
- package/dist/types/renderable/renderable.d.ts +402 -0
- package/dist/types/renderable/sprite.d.ts +268 -0
- package/dist/types/renderable/trigger.d.ts +61 -0
- package/dist/types/renderable/ui/uibaseelement.d.ts +95 -0
- package/dist/types/renderable/ui/uispriteelement.d.ts +127 -0
- package/dist/types/renderable/ui/uitextbutton.d.ts +54 -0
- package/dist/types/state/stage.d.ts +116 -0
- package/dist/types/state/state.d.ts +170 -0
- package/dist/types/system/device.d.ts +579 -0
- package/dist/types/system/dom.d.ts +1 -0
- package/dist/types/system/event.d.ts +473 -0
- package/dist/types/system/platform.d.ts +31 -0
- package/dist/types/system/pooling.d.ts +101 -0
- package/dist/types/system/save.d.ts +25 -0
- package/dist/types/system/timer.d.ts +126 -0
- package/dist/types/text/bitmaptext.d.ts +151 -0
- package/dist/types/text/bitmaptextdata.d.ts +35 -0
- package/dist/types/text/glyph.d.ts +28 -0
- package/dist/types/text/text.d.ts +173 -0
- package/dist/types/text/textmetrics.d.ts +47 -0
- package/dist/types/text/textstyle.d.ts +5 -0
- package/dist/types/tweens/easing.d.ts +46 -0
- package/dist/types/tweens/interpolation.d.ts +18 -0
- package/dist/types/tweens/tween.d.ts +195 -0
- package/dist/types/utils/agent.d.ts +21 -0
- package/dist/types/utils/array.d.ts +39 -0
- package/dist/types/utils/file.d.ts +18 -0
- package/dist/types/utils/function.d.ts +32 -0
- package/dist/types/utils/string.d.ts +50 -0
- package/dist/types/utils/utils.d.ts +17 -0
- package/dist/types/video/canvas/canvas_renderer.d.ts +380 -0
- package/dist/types/video/renderer.d.ts +222 -0
- package/dist/types/video/texture/atlas.d.ts +201 -0
- package/dist/types/video/texture/cache.d.ts +45 -0
- package/dist/types/video/texture/canvas_texture.d.ts +78 -0
- package/dist/types/video/utils/autodetect.d.ts +7 -0
- package/dist/types/video/utils/resize.d.ts +4 -0
- package/dist/types/video/video.d.ts +93 -0
- package/dist/types/video/webgl/buffer/vertex.d.ts +56 -0
- package/dist/types/video/webgl/glshader.d.ts +93 -0
- package/dist/types/video/webgl/utils/attributes.d.ts +4 -0
- package/dist/types/video/webgl/utils/precision.d.ts +13 -0
- package/dist/types/video/webgl/utils/program.d.ts +5 -0
- package/dist/types/video/webgl/utils/string.d.ts +5 -0
- package/dist/types/video/webgl/utils/uniforms.d.ts +4 -0
- package/dist/types/video/webgl/webgl_compositor.d.ts +174 -0
- package/dist/types/video/webgl/webgl_renderer.d.ts +429 -0
- package/package.json +8 -8
- package/src/application/application.js +138 -7
- package/src/application/header.js +25 -0
- package/src/{video/utils → application}/resize.js +11 -6
- package/src/application/settings.js +19 -0
- package/src/camera/camera2d.js +1 -1
- package/src/const.js +23 -0
- package/src/index.js +36 -23
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +1 -1
- package/src/lang/console.js +36 -0
- package/src/lang/deprecated.js +2 -37
- package/src/level/level.js +1 -1
- package/src/level/tiled/TMXGroup.js +0 -21
- package/src/level/tiled/TMXLayer.js +66 -56
- package/src/level/tiled/TMXObject.js +0 -62
- package/src/level/tiled/TMXTile.js +8 -24
- package/src/level/tiled/TMXTileMap.js +17 -83
- package/src/level/tiled/TMXTileset.js +0 -14
- package/src/level/tiled/TMXTilesetGroup.js +1 -9
- package/src/level/tiled/TMXUtils.js +38 -15
- package/src/level/tiled/constants.js +8 -0
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +5 -6
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -4
- package/src/level/tiled/renderer/TMXRenderer.js +0 -12
- package/src/level/tiled/renderer/autodetect.js +29 -0
- package/src/loader/loader.js +3 -1
- package/src/loader/loadingscreen.js +1 -1
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +172 -145
- package/src/physics/world.js +10 -30
- package/src/renderable/container.js +7 -91
- package/src/renderable/imagelayer.js +1 -1
- package/src/renderable/trigger.js +1 -1
- package/src/renderable/ui/uibaseelement.js +1 -1
- package/src/state/stage.js +1 -1
- package/src/state/state.js +1 -1
- package/src/system/device.js +0 -20
- package/src/tweens/tween.js +1 -1
- package/src/video/canvas/canvas_renderer.js +3 -0
- package/src/video/renderer.js +7 -0
- package/src/video/texture/canvas_texture.js +2 -1
- package/src/video/utils/autodetect.js +18 -0
- package/src/video/video.js +26 -155
- package/src/video/webgl/glshader.js +3 -4
- package/src/video/webgl/utils/precision.js +18 -0
- package/src/video/webgl/webgl_renderer.js +3 -0
- package/dist/melonjs.mjs/node_modules/core-js/es/string/trim-end.js +0 -13
- package/dist/melonjs.mjs/node_modules/core-js/es/string/trim-start.js +0 -13
- package/dist/melonjs.mjs/node_modules/core-js/internals/a-callable.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/an-object.js +0 -21
- package/dist/melonjs.mjs/node_modules/core-js/internals/array-includes.js +0 -45
- package/dist/melonjs.mjs/node_modules/core-js/internals/classof-raw.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/classof.js +0 -43
- package/dist/melonjs.mjs/node_modules/core-js/internals/copy-constructor-properties.js +0 -32
- package/dist/melonjs.mjs/node_modules/core-js/internals/create-non-enumerable-property.js +0 -24
- package/dist/melonjs.mjs/node_modules/core-js/internals/create-property-descriptor.js +0 -17
- package/dist/melonjs.mjs/node_modules/core-js/internals/define-built-in.js +0 -43
- package/dist/melonjs.mjs/node_modules/core-js/internals/define-global-property.js +0 -23
- package/dist/melonjs.mjs/node_modules/core-js/internals/descriptors.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/document-all.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/document-create-element.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/engine-user-agent.js +0 -14
- package/dist/melonjs.mjs/node_modules/core-js/internals/engine-v8-version.js +0 -39
- package/dist/melonjs.mjs/node_modules/core-js/internals/entry-unbind.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/enum-bug-keys.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/export.js +0 -72
- package/dist/melonjs.mjs/node_modules/core-js/internals/fails.js +0 -16
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-bind-native.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-call.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-name.js +0 -29
- package/dist/melonjs.mjs/node_modules/core-js/internals/function-uncurry-this.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/get-built-in.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/get-method.js +0 -21
- package/dist/melonjs.mjs/node_modules/core-js/internals/global.js +0 -25
- package/dist/melonjs.mjs/node_modules/core-js/internals/has-own-property.js +0 -23
- package/dist/melonjs.mjs/node_modules/core-js/internals/hidden-keys.js +0 -10
- package/dist/melonjs.mjs/node_modules/core-js/internals/ie8-dom-define.js +0 -24
- package/dist/melonjs.mjs/node_modules/core-js/internals/indexed-object.js +0 -28
- package/dist/melonjs.mjs/node_modules/core-js/internals/inspect-source.js +0 -27
- package/dist/melonjs.mjs/node_modules/core-js/internals/internal-state.js +0 -88
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-callable.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-forced.js +0 -34
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-null-or-undefined.js +0 -14
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-object.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/is-symbol.js +0 -27
- package/dist/melonjs.mjs/node_modules/core-js/internals/length-of-array-like.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/make-built-in.js +0 -68
- package/dist/melonjs.mjs/node_modules/core-js/internals/math-trunc.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-define-property.js +0 -58
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-descriptor.js +0 -41
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-names.js +0 -23
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-symbols.js +0 -12
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-is-prototype-of.js +0 -14
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-keys-internal.js +0 -35
- package/dist/melonjs.mjs/node_modules/core-js/internals/object-property-is-enumerable.js +0 -23
- package/dist/melonjs.mjs/node_modules/core-js/internals/ordinary-to-primitive.js +0 -28
- package/dist/melonjs.mjs/node_modules/core-js/internals/own-keys.js +0 -31
- package/dist/melonjs.mjs/node_modules/core-js/internals/require-object-coercible.js +0 -21
- package/dist/melonjs.mjs/node_modules/core-js/internals/shared-key.js +0 -21
- package/dist/melonjs.mjs/node_modules/core-js/internals/shared-store.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/shared.js +0 -24
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-end.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-forced.js +0 -28
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-start.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim.js +0 -45
- package/dist/melonjs.mjs/node_modules/core-js/internals/symbol-constructor-detection.js +0 -26
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-absolute-index.js +0 -23
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-indexed-object.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-integer-or-infinity.js +0 -20
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-length.js +0 -20
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-object.js +0 -20
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-primitive.js +0 -41
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-property-key.js +0 -21
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-string-tag-support.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/to-string.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/internals/try-to-string.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/uid.js +0 -20
- package/dist/melonjs.mjs/node_modules/core-js/internals/use-symbol-as-uid.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/v8-prototype-define-bug.js +0 -24
- package/dist/melonjs.mjs/node_modules/core-js/internals/weak-map-basic-detection.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/internals/well-known-symbol.js +0 -41
- package/dist/melonjs.mjs/node_modules/core-js/internals/whitespaces.js +0 -12
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.global-this.js +0 -18
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-end.js +0 -22
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-left.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-right.js +0 -19
- package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-start.js +0 -22
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.mjs.js +0 -9
package/src/physics/detector.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as SAT from "./sat.js";
|
|
2
2
|
import ResponseObject from "./response.js";
|
|
3
3
|
import Vector2d from "./../math/vector2.js";
|
|
4
|
-
import game from "./../game.js";
|
|
5
4
|
import Bounds from "./bounds.js";
|
|
6
5
|
|
|
7
|
-
|
|
8
6
|
// a dummy object when using Line for raycasting
|
|
9
7
|
let dummyObj = {
|
|
10
8
|
pos : new Vector2d(0, 0),
|
|
@@ -16,167 +14,196 @@ let dummyObj = {
|
|
|
16
14
|
}
|
|
17
15
|
};
|
|
18
16
|
|
|
17
|
+
// some cache bounds object used for collision detection
|
|
19
18
|
let boundsA = new Bounds();
|
|
20
19
|
let boundsB = new Bounds();
|
|
21
20
|
|
|
22
|
-
// the global response object used for collisions
|
|
23
|
-
let globalResponse = new ResponseObject();
|
|
24
|
-
|
|
25
21
|
/**
|
|
26
|
-
*
|
|
27
|
-
* you can redefine this function if you need any specific rules over what should collide with what.
|
|
28
|
-
* @ignore
|
|
29
|
-
* @param {Renderable} a - a reference to the object A.
|
|
30
|
-
* @param {Renderable} b - a reference to the object B.
|
|
31
|
-
* @returns {boolean} true if they should collide, false otherwise
|
|
22
|
+
* the Detector class contains methods for detecting collisions between bodies using a broadphase algorithm.
|
|
32
23
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* find all the collisions for the specified object
|
|
51
|
-
* @ignore
|
|
52
|
-
* @param {Renderable} objA - object to be tested for collision
|
|
53
|
-
* @param {ResponseObject} [response] - a user defined response object that will be populated if they intersect.
|
|
54
|
-
* @returns {boolean} in case of collision, false otherwise
|
|
55
|
-
*/
|
|
56
|
-
export function collisionCheck(objA, response = globalResponse) {
|
|
57
|
-
var collisionCounter = 0;
|
|
58
|
-
// retreive a list of potential colliding objects from the game world
|
|
59
|
-
var candidates = game.world.broadphase.retrieve(objA);
|
|
24
|
+
export default class Detector {
|
|
25
|
+
/**
|
|
26
|
+
* @param {Container} world - the physic world this detector is bind to
|
|
27
|
+
*/
|
|
28
|
+
constructor(world) {
|
|
29
|
+
// @ignore
|
|
30
|
+
this.world = world;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* the default response object used for collisions
|
|
34
|
+
* (will be automatically populated by the collides functions)
|
|
35
|
+
* @type {ResponseObject}
|
|
36
|
+
*/
|
|
37
|
+
this.response = new ResponseObject();
|
|
38
|
+
}
|
|
60
39
|
|
|
61
|
-
|
|
62
|
-
|
|
40
|
+
/**
|
|
41
|
+
* determine if two objects should collide (based on both respective objects body collision mask and type).<br>
|
|
42
|
+
* you can redefine this function if you need any specific rules over what should collide with what.
|
|
43
|
+
* @param {Renderable} a - a reference to the object A.
|
|
44
|
+
* @param {Renderable} b - a reference to the object B.
|
|
45
|
+
* @returns {boolean} true if they should collide, false otherwise
|
|
46
|
+
*/
|
|
47
|
+
shouldCollide(a, b) {
|
|
48
|
+
var bodyA = a.body,
|
|
49
|
+
bodyB = b.body;
|
|
50
|
+
return (
|
|
51
|
+
(typeof bodyA === "object" && typeof bodyB === "object") &&
|
|
52
|
+
a !== b &&
|
|
53
|
+
a.isKinematic !== true && b.isKinematic !== true &&
|
|
54
|
+
bodyA.shapes.length > 0 && bodyB.shapes.length > 0 &&
|
|
55
|
+
!(bodyA.isStatic === true && bodyB.isStatic === true) &&
|
|
56
|
+
(bodyA.collisionMask & bodyB.collisionType) !== 0 &&
|
|
57
|
+
(bodyA.collisionType & bodyB.collisionMask) !== 0
|
|
58
|
+
);
|
|
59
|
+
}
|
|
63
60
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
/**
|
|
62
|
+
* detect collision between two bodies.
|
|
63
|
+
* @param {Body} bodyA - a reference to body A.
|
|
64
|
+
* @param {Body} bodyB - a reference to body B.
|
|
65
|
+
* @returns {Boolean} true if colliding
|
|
66
|
+
*/
|
|
67
|
+
collides(bodyA, bodyB, response = this.response) {
|
|
68
|
+
// for each shape in body A
|
|
69
|
+
for (var indexA = bodyA.shapes.length, shapeA; indexA--, (shapeA = bodyA.shapes[indexA]);) {
|
|
70
|
+
// for each shape in body B
|
|
71
|
+
for (var indexB = bodyB.shapes.length, shapeB; indexB--, (shapeB = bodyB.shapes[indexB]);) {
|
|
72
|
+
// full SAT collision check
|
|
73
|
+
if (SAT["test" + shapeA.shapeType + shapeB.shapeType].call(
|
|
74
|
+
this,
|
|
75
|
+
bodyA.ancestor, // a reference to the object A
|
|
76
|
+
shapeA,
|
|
77
|
+
bodyB.ancestor, // a reference to the object B
|
|
78
|
+
shapeB,
|
|
79
|
+
// clear response object before reusing
|
|
80
|
+
response.clear()) === true
|
|
81
|
+
) {
|
|
67
82
|
|
|
68
|
-
|
|
69
|
-
|
|
83
|
+
// set the shape index
|
|
84
|
+
response.indexShapeA = indexA;
|
|
85
|
+
response.indexShapeB = indexB;
|
|
70
86
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// for each shape in body A
|
|
74
|
-
objA.body.shapes.forEach((shapeA, indexA) => {
|
|
75
|
-
// for each shape in body B
|
|
76
|
-
objB.body.shapes.forEach((shapeB, indexB) => {
|
|
77
|
-
// full SAT collision check
|
|
78
|
-
if (SAT["test" + shapeA.shapeType + shapeB.shapeType].call(
|
|
79
|
-
this,
|
|
80
|
-
objA, // a reference to the object A
|
|
81
|
-
shapeA,
|
|
82
|
-
objB, // a reference to the object B
|
|
83
|
-
shapeB,
|
|
84
|
-
// clear response object before reusing
|
|
85
|
-
response.clear()) === true
|
|
86
|
-
) {
|
|
87
|
-
// we touched something !
|
|
88
|
-
collisionCounter++;
|
|
89
|
-
|
|
90
|
-
// set the shape index
|
|
91
|
-
response.indexShapeA = indexA;
|
|
92
|
-
response.indexShapeB = indexB;
|
|
93
|
-
|
|
94
|
-
// execute the onCollision callback
|
|
95
|
-
if (objA.onCollision && objA.onCollision(response, objB) !== false && objA.body.isStatic === false) {
|
|
96
|
-
objA.body.respondToCollision.call(objA.body, response);
|
|
97
|
-
}
|
|
98
|
-
if (objB.onCollision && objB.onCollision(response, objA) !== false && objB.body.isStatic === false) {
|
|
99
|
-
objB.body.respondToCollision.call(objB.body, response);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
104
89
|
}
|
|
105
90
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return collisionCounter > 0;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Checks for object colliding with the given line
|
|
113
|
-
* @ignore
|
|
114
|
-
* @param {Line} line - line to be tested for collision
|
|
115
|
-
* @param {Array.<Renderable>} [result] - a user defined array that will be populated with intersecting physic objects.
|
|
116
|
-
* @returns {Array.<Renderable>} an array of intersecting physic objects
|
|
117
|
-
* @example
|
|
118
|
-
* // define a line accross the viewport
|
|
119
|
-
* var ray = new me.Line(
|
|
120
|
-
* // absolute position of the line
|
|
121
|
-
* 0, 0, [
|
|
122
|
-
* // starting point relative to the initial position
|
|
123
|
-
* new me.Vector2d(0, 0),
|
|
124
|
-
* // ending point
|
|
125
|
-
* new me.Vector2d(me.game.viewport.width, me.game.viewport.height)
|
|
126
|
-
* ]);
|
|
127
|
-
*
|
|
128
|
-
* // check for collition
|
|
129
|
-
* result = me.collision.rayCast(ray);
|
|
130
|
-
*
|
|
131
|
-
* if (result.length > 0) {
|
|
132
|
-
* // ...
|
|
133
|
-
* }
|
|
134
|
-
*/
|
|
135
|
-
export function rayCast(line, result = []) {
|
|
136
|
-
var collisionCounter = 0;
|
|
137
|
-
|
|
138
|
-
// retrieve a list of potential colliding objects from the game world
|
|
139
|
-
var candidates = game.world.broadphase.retrieve(line);
|
|
140
|
-
|
|
141
|
-
for (var i = candidates.length, objB; i--, (objB = candidates[i]);) {
|
|
142
|
-
|
|
143
|
-
// fast AABB check if both bounding boxes are overlaping
|
|
144
|
-
if (objB.body && line.getBounds().overlaps(objB.getBounds())) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
145
93
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
94
|
+
/**
|
|
95
|
+
* find all the collisions for the specified object using a broadphase algorithm
|
|
96
|
+
* @ignore
|
|
97
|
+
* @param {Renderable} objA - object to be tested for collision
|
|
98
|
+
* @returns {boolean} in case of collision, false otherwise
|
|
99
|
+
*/
|
|
100
|
+
collisions(objA) {
|
|
101
|
+
var collisionCounter = 0;
|
|
102
|
+
// retreive a list of potential colliding objects from the game world
|
|
103
|
+
var candidates = this.world.broadphase.retrieve(objA);
|
|
104
|
+
|
|
105
|
+
boundsA.addBounds(objA.getBounds(), true);
|
|
106
|
+
boundsA.addBounds(objA.body.getBounds());
|
|
107
|
+
|
|
108
|
+
candidates.forEach((objB) => {
|
|
109
|
+
// check if both objects "should" collide
|
|
110
|
+
if (this.shouldCollide(objA, objB)) {
|
|
111
|
+
|
|
112
|
+
boundsB.addBounds(objB.getBounds(), true);
|
|
113
|
+
boundsB.addBounds(objB.body.getBounds());
|
|
114
|
+
|
|
115
|
+
// fast AABB check if both bounding boxes are overlaping
|
|
116
|
+
if (boundsA.overlaps(boundsB)) {
|
|
117
|
+
|
|
118
|
+
if (this.collides(objA.body, objB.body)) {
|
|
119
|
+
// we touched something !
|
|
120
|
+
collisionCounter++;
|
|
121
|
+
|
|
122
|
+
// execute the onCollision callback
|
|
123
|
+
if (objA.onCollision && objA.onCollision(this.response, objB) !== false && objA.body.isStatic === false) {
|
|
124
|
+
objA.body.respondToCollision.call(objA.body, this.response);
|
|
125
|
+
}
|
|
126
|
+
if (objB.onCollision && objB.onCollision(this.response, objA) !== false && objB.body.isStatic === false) {
|
|
127
|
+
objB.body.respondToCollision.call(objB.body, this.response);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
150
131
|
}
|
|
132
|
+
});
|
|
133
|
+
// we could return the amount of objects we collided with ?
|
|
134
|
+
return collisionCounter > 0;
|
|
135
|
+
}
|
|
151
136
|
|
|
152
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Checks for object colliding with the given line
|
|
139
|
+
* @ignore
|
|
140
|
+
* @param {Line} line - line to be tested for collision
|
|
141
|
+
* @param {Array.<Renderable>} [result] - a user defined array that will be populated with intersecting physic objects.
|
|
142
|
+
* @returns {Array.<Renderable>} an array of intersecting physic objects
|
|
143
|
+
* @example
|
|
144
|
+
* // define a line accross the viewport
|
|
145
|
+
* var ray = new me.Line(
|
|
146
|
+
* // absolute position of the line
|
|
147
|
+
* 0, 0, [
|
|
148
|
+
* // starting point relative to the initial position
|
|
149
|
+
* new me.Vector2d(0, 0),
|
|
150
|
+
* // ending point
|
|
151
|
+
* new me.Vector2d(me.game.viewport.width, me.game.viewport.height)
|
|
152
|
+
* ]);
|
|
153
|
+
*
|
|
154
|
+
* // check for collition
|
|
155
|
+
* result = me.collision.rayCast(ray);
|
|
156
|
+
*
|
|
157
|
+
* if (result.length > 0) {
|
|
158
|
+
* // ...
|
|
159
|
+
* }
|
|
160
|
+
*/
|
|
161
|
+
rayCast(line, result = []) {
|
|
162
|
+
var collisionCounter = 0;
|
|
163
|
+
|
|
164
|
+
// retrieve a list of potential colliding objects from the game world
|
|
165
|
+
var candidates = this.world.broadphase.retrieve(line);
|
|
166
|
+
|
|
167
|
+
for (var i = candidates.length, objB; i--, (objB = candidates[i]);) {
|
|
153
168
|
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
do {
|
|
157
|
-
var shapeB = objB.body.getShape(indexB);
|
|
169
|
+
// fast AABB check if both bounding boxes are overlaping
|
|
170
|
+
if (objB.body && line.getBounds().overlaps(objB.getBounds())) {
|
|
158
171
|
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
dummyObj, // a reference to the object A
|
|
164
|
-
shapeA,
|
|
165
|
-
objB, // a reference to the object B
|
|
166
|
-
shapeB
|
|
167
|
-
)) {
|
|
168
|
-
// we touched something !
|
|
169
|
-
result[collisionCounter] = objB;
|
|
170
|
-
collisionCounter++;
|
|
172
|
+
// go trough all defined shapes in B (if any)
|
|
173
|
+
var bLen = objB.body.shapes.length;
|
|
174
|
+
if ( objB.body.shapes.length === 0) {
|
|
175
|
+
continue;
|
|
171
176
|
}
|
|
172
|
-
|
|
173
|
-
|
|
177
|
+
|
|
178
|
+
var shapeA = line;
|
|
179
|
+
|
|
180
|
+
// go through all defined shapes in B
|
|
181
|
+
var indexB = 0;
|
|
182
|
+
do {
|
|
183
|
+
var shapeB = objB.body.getShape(indexB);
|
|
184
|
+
|
|
185
|
+
// full SAT collision check
|
|
186
|
+
if (SAT["test" + shapeA.shapeType + shapeB.shapeType]
|
|
187
|
+
.call(
|
|
188
|
+
this,
|
|
189
|
+
dummyObj, // a reference to the object A
|
|
190
|
+
shapeA,
|
|
191
|
+
objB, // a reference to the object B
|
|
192
|
+
shapeB
|
|
193
|
+
)) {
|
|
194
|
+
// we touched something !
|
|
195
|
+
result[collisionCounter] = objB;
|
|
196
|
+
collisionCounter++;
|
|
197
|
+
}
|
|
198
|
+
indexB++;
|
|
199
|
+
} while (indexB < bLen);
|
|
200
|
+
}
|
|
174
201
|
}
|
|
175
|
-
}
|
|
176
202
|
|
|
177
|
-
|
|
178
|
-
|
|
203
|
+
// cap result in case it was not empty
|
|
204
|
+
result.length = collisionCounter;
|
|
179
205
|
|
|
180
|
-
|
|
181
|
-
|
|
206
|
+
// return the list of colliding objects
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
182
209
|
}
|
package/src/physics/world.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Vector2d from "./../math/vector2.js";
|
|
2
2
|
import * as event from "./../system/event.js";
|
|
3
3
|
import QuadTree from "./quadtree.js";
|
|
4
|
-
import Container from "
|
|
4
|
+
import Container from "../renderable/container.js";
|
|
5
5
|
import collision from "./collision.js";
|
|
6
|
-
import
|
|
6
|
+
import Detector from "./detector.js";
|
|
7
7
|
import state from "./../state/state.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -30,30 +30,22 @@ import state from "./../state/state.js";
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* the application (game) this physic world belong to
|
|
33
|
-
* @public
|
|
34
33
|
* @type {Application}
|
|
35
34
|
*/
|
|
36
|
-
this.app =
|
|
35
|
+
this.app = undefined;
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
* the rate at which the game world is updated,
|
|
40
39
|
* may be greater than or lower than the display fps
|
|
41
|
-
* @public
|
|
42
|
-
* @type {Vector2d}
|
|
43
40
|
* @default 60
|
|
44
|
-
* @name fps
|
|
45
|
-
* @memberof World
|
|
46
41
|
* @see timer.maxfps
|
|
47
42
|
*/
|
|
48
43
|
this.fps = 60;
|
|
49
44
|
|
|
50
45
|
/**
|
|
51
46
|
* world gravity
|
|
52
|
-
* @public
|
|
53
47
|
* @type {Vector2d}
|
|
54
48
|
* @default <0,0.98>
|
|
55
|
-
* @name gravity
|
|
56
|
-
* @memberof World
|
|
57
49
|
*/
|
|
58
50
|
this.gravity = new Vector2d(0, 0.98);
|
|
59
51
|
|
|
@@ -67,28 +59,27 @@ import state from "./../state/state.js";
|
|
|
67
59
|
* property to your layer (in Tiled).
|
|
68
60
|
* @type {boolean}
|
|
69
61
|
* @default false
|
|
70
|
-
* @memberof World
|
|
71
62
|
*/
|
|
72
63
|
this.preRender = false;
|
|
73
64
|
|
|
74
65
|
/**
|
|
75
66
|
* the active physic bodies in this simulation
|
|
76
|
-
* @name bodies
|
|
77
|
-
* @memberof World
|
|
78
|
-
* @public
|
|
79
67
|
* @type {Set<Body>}
|
|
80
68
|
*/
|
|
81
69
|
this.bodies = new Set();
|
|
82
70
|
|
|
83
71
|
/**
|
|
84
72
|
* the instance of the game world quadtree used for broadphase
|
|
85
|
-
* @name broadphase
|
|
86
|
-
* @memberof World
|
|
87
|
-
* @public
|
|
88
73
|
* @type {QuadTree}
|
|
89
74
|
*/
|
|
90
75
|
this.broadphase = new QuadTree(this, this.getBounds().clone(), collision.maxChildren, collision.maxDepth);
|
|
91
76
|
|
|
77
|
+
/**
|
|
78
|
+
* the collision detector instance used by this world instance
|
|
79
|
+
* @type {Detector}
|
|
80
|
+
*/
|
|
81
|
+
this.detector = new Detector(this);
|
|
82
|
+
|
|
92
83
|
// reset the world container on the game reset signal
|
|
93
84
|
event.on(event.GAME_RESET, this.reset, this);
|
|
94
85
|
|
|
@@ -101,8 +92,6 @@ import state from "./../state/state.js";
|
|
|
101
92
|
|
|
102
93
|
/**
|
|
103
94
|
* reset the game world
|
|
104
|
-
* @name reset
|
|
105
|
-
* @memberof World
|
|
106
95
|
*/
|
|
107
96
|
reset() {
|
|
108
97
|
// clear the quadtree
|
|
@@ -121,8 +110,6 @@ import state from "./../state/state.js";
|
|
|
121
110
|
|
|
122
111
|
/**
|
|
123
112
|
* Add a physic body to the game world
|
|
124
|
-
* @name addBody
|
|
125
|
-
* @memberof World
|
|
126
113
|
* @see Container.addChild
|
|
127
114
|
* @param {Body} body
|
|
128
115
|
* @returns {World} this game world
|
|
@@ -135,8 +122,6 @@ import state from "./../state/state.js";
|
|
|
135
122
|
|
|
136
123
|
/**
|
|
137
124
|
* Remove a physic body from the game world
|
|
138
|
-
* @name removeBody
|
|
139
|
-
* @memberof World
|
|
140
125
|
* @see Container.removeChild
|
|
141
126
|
* @param {Body} body
|
|
142
127
|
* @returns {World} this game world
|
|
@@ -149,8 +134,6 @@ import state from "./../state/state.js";
|
|
|
149
134
|
|
|
150
135
|
/**
|
|
151
136
|
* Apply gravity to the given body
|
|
152
|
-
* @name bodyApplyVelocity
|
|
153
|
-
* @memberof World
|
|
154
137
|
* @private
|
|
155
138
|
* @param {Body} body
|
|
156
139
|
*/
|
|
@@ -167,8 +150,6 @@ import state from "./../state/state.js";
|
|
|
167
150
|
|
|
168
151
|
/**
|
|
169
152
|
* update the game world
|
|
170
|
-
* @name reset
|
|
171
|
-
* @memberof World
|
|
172
153
|
* @param {number} dt - the time passed since the last frame update
|
|
173
154
|
* @returns {boolean} true if the word is dirty
|
|
174
155
|
*/
|
|
@@ -196,7 +177,7 @@ import state from "./../state/state.js";
|
|
|
196
177
|
ancestor.isDirty = true;
|
|
197
178
|
}
|
|
198
179
|
// handle collisions against other objects
|
|
199
|
-
|
|
180
|
+
this.detector.collisions(ancestor);
|
|
200
181
|
// clear body force
|
|
201
182
|
body.force.set(0, 0);
|
|
202
183
|
}
|
|
@@ -206,6 +187,5 @@ import state from "./../state/state.js";
|
|
|
206
187
|
// call the super constructor
|
|
207
188
|
return super.update(dt);
|
|
208
189
|
}
|
|
209
|
-
|
|
210
190
|
}
|
|
211
191
|
|