fisrt commit

This commit is contained in:
2026-01-17 11:49:36 +03:00
commit b2dfe51b9f
5379 changed files with 4408602 additions and 0 deletions

595
node_modules/phaser/plugins/impact/Body.js generated vendored Normal file
View File

@ -0,0 +1,595 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var COLLIDES = require('./COLLIDES');
var GetVelocity = require('./GetVelocity');
var TYPE = require('./TYPE');
var UpdateMotion = require('./UpdateMotion');
/**
* @callback Phaser.Types.Physics.Impact.BodyUpdateCallback
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} body - [description]
*/
/**
* @classdesc
* An Impact.js compatible physics body.
* This re-creates the properties you'd get on an Entity and the math needed to update them.
*
* @class Body
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} [sx=16] - [description]
* @param {number} [sy=16] - [description]
*/
var Body = new Class({
initialize:
function Body (world, x, y, sx, sy)
{
if (sx === undefined) { sx = 16; }
if (sy === undefined) { sy = sx; }
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#world
* @type {Phaser.Physics.Impact.World}
* @since 3.0.0
*/
this.world = world;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#gameObject
* @type {Phaser.GameObjects.GameObject}
* @default null
* @since 3.0.0
*/
this.gameObject = null;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#enabled
* @type {boolean}
* @default true
* @since 3.0.0
*/
this.enabled = true;
/**
* The ImpactBody, ImpactSprite or ImpactImage object that owns this Body, if any.
*
* @name Phaser.Physics.Impact.Body#parent
* @type {?(Phaser.Physics.Impact.ImpactBody|Phaser.Physics.Impact.ImpactImage|Phaser.Physics.Impact.ImpactSprite)}
* @since 3.0.0
*/
this.parent;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#id
* @type {integer}
* @since 3.0.0
*/
this.id = world.getNextID();
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#name
* @type {string}
* @default ''
* @since 3.0.0
*/
this.name = '';
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#size
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.size = { x: sx, y: sy };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#offset
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.offset = { x: 0, y: 0 };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#pos
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.pos = { x: x, y: y };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#last
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.last = { x: x, y: y };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#vel
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.vel = { x: 0, y: 0 };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#accel
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.accel = { x: 0, y: 0 };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#friction
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.friction = { x: 0, y: 0 };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#maxVel
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.maxVel = { x: world.defaults.maxVelocityX, y: world.defaults.maxVelocityY };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#standing
* @type {boolean}
* @default false
* @since 3.0.0
*/
this.standing = false;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#gravityFactor
* @type {number}
* @since 3.0.0
*/
this.gravityFactor = world.defaults.gravityFactor;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#bounciness
* @type {number}
* @since 3.0.0
*/
this.bounciness = world.defaults.bounciness;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#minBounceVelocity
* @type {number}
* @since 3.0.0
*/
this.minBounceVelocity = world.defaults.minBounceVelocity;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#accelGround
* @type {number}
* @default 0
* @since 3.0.0
*/
this.accelGround = 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#accelAir
* @type {number}
* @default 0
* @since 3.0.0
*/
this.accelAir = 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#jumpSpeed
* @type {number}
* @default 0
* @since 3.0.0
*/
this.jumpSpeed = 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#type
* @type {Phaser.Physics.Impact.TYPE}
* @since 3.0.0
*/
this.type = TYPE.NONE;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#checkAgainst
* @type {Phaser.Physics.Impact.TYPE}
* @since 3.0.0
*/
this.checkAgainst = TYPE.NONE;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#collides
* @type {Phaser.Physics.Impact.COLLIDES}
* @since 3.0.0
*/
this.collides = COLLIDES.NEVER;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#debugShowBody
* @type {boolean}
* @since 3.0.0
*/
this.debugShowBody = world.defaults.debugShowBody;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#debugShowVelocity
* @type {boolean}
* @since 3.0.0
*/
this.debugShowVelocity = world.defaults.debugShowVelocity;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#debugBodyColor
* @type {integer}
* @since 3.0.0
*/
this.debugBodyColor = world.defaults.bodyDebugColor;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#updateCallback
* @type {?Phaser.Types.Physics.Impact.BodyUpdateCallback}
* @since 3.0.0
*/
this.updateCallback;
/**
* min 44 deg, max 136 deg
*
* @name Phaser.Physics.Impact.Body#slopeStanding
* @type {{ min: number, max: number }}
* @since 3.0.0
*/
this.slopeStanding = { min: 0.767944870877505, max: 2.3736477827122884 };
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#reset
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
*/
reset: function (x, y)
{
this.pos = { x: x, y: y };
this.last = { x: x, y: y };
this.vel = { x: 0, y: 0 };
this.accel = { x: 0, y: 0 };
this.friction = { x: 0, y: 0 };
this.maxVel = { x: 100, y: 100 };
this.standing = false;
this.gravityFactor = 1;
this.bounciness = 0;
this.minBounceVelocity = 40;
this.accelGround = 0;
this.accelAir = 0;
this.jumpSpeed = 0;
this.type = TYPE.NONE;
this.checkAgainst = TYPE.NONE;
this.collides = COLLIDES.NEVER;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#update
* @since 3.0.0
*
* @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.
*/
update: function (delta)
{
var pos = this.pos;
this.last.x = pos.x;
this.last.y = pos.y;
this.vel.y += this.world.gravity * delta * this.gravityFactor;
this.vel.x = GetVelocity(delta, this.vel.x, this.accel.x, this.friction.x, this.maxVel.x);
this.vel.y = GetVelocity(delta, this.vel.y, this.accel.y, this.friction.y, this.maxVel.y);
var mx = this.vel.x * delta;
var my = this.vel.y * delta;
var res = this.world.collisionMap.trace(pos.x, pos.y, mx, my, this.size.x, this.size.y);
if (this.handleMovementTrace(res))
{
UpdateMotion(this, res);
}
var go = this.gameObject;
if (go)
{
go.x = (pos.x - this.offset.x) + go.displayOriginX * go.scaleX;
go.y = (pos.y - this.offset.y) + go.displayOriginY * go.scaleY;
}
if (this.updateCallback)
{
this.updateCallback(this);
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#drawDebug
* @since 3.0.0
*
* @param {Phaser.GameObjects.Graphics} graphic - [description]
*/
drawDebug: function (graphic)
{
var pos = this.pos;
if (this.debugShowBody)
{
graphic.lineStyle(1, this.debugBodyColor, 1);
graphic.strokeRect(pos.x, pos.y, this.size.x, this.size.y);
}
if (this.debugShowVelocity)
{
var x = pos.x + this.size.x / 2;
var y = pos.y + this.size.y / 2;
graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1);
graphic.lineBetween(x, y, x + this.vel.x, y + this.vel.y);
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#willDrawDebug
* @since 3.0.0
*
* @return {boolean} [description]
*/
willDrawDebug: function ()
{
return (this.debugShowBody || this.debugShowVelocity);
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#skipHash
* @since 3.0.0
*
* @return {boolean} [description]
*/
skipHash: function ()
{
return (!this.enabled || (this.type === 0 && this.checkAgainst === 0 && this.collides === 0));
},
/**
* Determines whether the body collides with the `other` one or not.
*
* @method Phaser.Physics.Impact.Body#touches
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} other - [description]
*
* @return {boolean} [description]
*/
touches: function (other)
{
return !(
this.pos.x >= other.pos.x + other.size.x ||
this.pos.x + this.size.x <= other.pos.x ||
this.pos.y >= other.pos.y + other.size.y ||
this.pos.y + this.size.y <= other.pos.y
);
},
/**
* Reset the size and position of the physics body.
*
* @method Phaser.Physics.Impact.Body#resetSize
* @since 3.0.0
*
* @param {number} x - The x coordinate to position the body.
* @param {number} y - The y coordinate to position the body.
* @param {number} width - The width of the body.
* @param {number} height - The height of the body.
*
* @return {Phaser.Physics.Impact.Body} This Body object.
*/
resetSize: function (x, y, width, height)
{
this.pos.x = x;
this.pos.y = y;
this.size.x = width;
this.size.y = height;
return this;
},
/**
* Export this body object to JSON.
*
* @method Phaser.Physics.Impact.Body#toJSON
* @since 3.0.0
*
* @return {Phaser.Types.Physics.Impact.JSONImpactBody} JSON representation of this body object.
*/
toJSON: function ()
{
var output = {
name: this.name,
size: { x: this.size.x, y: this.size.y },
pos: { x: this.pos.x, y: this.pos.y },
vel: { x: this.vel.x, y: this.vel.y },
accel: { x: this.accel.x, y: this.accel.y },
friction: { x: this.friction.x, y: this.friction.y },
maxVel: { x: this.maxVel.x, y: this.maxVel.y },
gravityFactor: this.gravityFactor,
bounciness: this.bounciness,
minBounceVelocity: this.minBounceVelocity,
type: this.type,
checkAgainst: this.checkAgainst,
collides: this.collides
};
return output;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#fromJSON
* @todo Code it!
* @since 3.0.0
*
* @param {object} config - [description]
*/
fromJSON: function ()
{
},
/**
* Can be overridden by user code
*
* @method Phaser.Physics.Impact.Body#check
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} other - [description]
*/
check: function ()
{
},
/**
* Can be overridden by user code
*
* @method Phaser.Physics.Impact.Body#collideWith
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} other - [description]
* @param {string} axis - [description]
*/
collideWith: function (other, axis)
{
if (this.parent && this.parent._collideCallback)
{
this.parent._collideCallback.call(this.parent._callbackScope, this, other, axis);
}
},
/**
* Can be overridden by user code but must return a boolean.
*
* @method Phaser.Physics.Impact.Body#handleMovementTrace
* @since 3.0.0
*
* @param {number} res - [description]
*
* @return {boolean} [description]
*/
handleMovementTrace: function ()
{
return true;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#destroy
* @since 3.0.0
*/
destroy: function ()
{
this.world.remove(this);
this.enabled = false;
this.world = null;
this.gameObject = null;
this.parent = null;
}
});
module.exports = Body;

73
node_modules/phaser/plugins/impact/COLLIDES.js generated vendored Normal file
View File

@ -0,0 +1,73 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Collision Types - Determine if and how entities collide with each other.
*
* In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves,
* while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE
* collisions, both entities are moved. LITE or PASSIVE entities don't collide
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
* FIXED collisions is undefined.
*
* @namespace Phaser.Physics.Impact.COLLIDES
* @memberof Phaser.Physics.Impact
* @since 3.0.0
*/
module.exports = {
/**
* Never collides.
*
* @name Phaser.Physics.Impact.COLLIDES.NEVER
* @type {integer}
* @const
* @since 3.0.0
*/
NEVER: 0,
/**
* Lite collision.
*
* @name Phaser.Physics.Impact.COLLIDES.LITE
* @type {integer}
* @const
* @since 3.0.0
*/
LITE: 1,
/**
* Passive collision.
*
* @name Phaser.Physics.Impact.COLLIDES.PASSIVE
* @type {integer}
* @const
* @since 3.0.0
*/
PASSIVE: 2,
/**
* Active collision.
*
* @name Phaser.Physics.Impact.COLLIDES.ACTIVE
* @type {integer}
* @const
* @since 3.0.0
*/
ACTIVE: 4,
/**
* Fixed collision.
*
* @name Phaser.Physics.Impact.COLLIDES.FIXED
* @type {integer}
* @const
* @since 3.0.0
*/
FIXED: 8
};

358
node_modules/phaser/plugins/impact/CollisionMap.js generated vendored Normal file
View File

@ -0,0 +1,358 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var DefaultDefs = require('./DefaultDefs');
/**
* @classdesc
* [description]
*
* @class CollisionMap
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {integer} [tilesize=32] - [description]
* @param {array} [data] - [description]
*/
var CollisionMap = new Class({
initialize:
function CollisionMap (tilesize, data)
{
if (tilesize === undefined) { tilesize = 32; }
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#tilesize
* @type {integer}
* @default 32
* @since 3.0.0
*/
this.tilesize = tilesize;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#data
* @type {array}
* @since 3.0.0
*/
this.data = (Array.isArray(data)) ? data : [];
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#width
* @type {number}
* @since 3.0.0
*/
this.width = (Array.isArray(data)) ? data[0].length : 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#height
* @type {number}
* @since 3.0.0
*/
this.height = (Array.isArray(data)) ? data.length : 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#lastSlope
* @type {integer}
* @default 55
* @since 3.0.0
*/
this.lastSlope = 55;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#tiledef
* @type {object}
* @since 3.0.0
*/
this.tiledef = DefaultDefs;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.CollisionMap#trace
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} vx - [description]
* @param {number} vy - [description]
* @param {number} objectWidth - [description]
* @param {number} objectHeight - [description]
*
* @return {boolean} [description]
*/
trace: function (x, y, vx, vy, objectWidth, objectHeight)
{
// Set up the trace-result
var res = {
collision: { x: false, y: false, slope: false },
pos: { x: x + vx, y: y + vy },
tile: { x: 0, y: 0 }
};
if (!this.data)
{
return res;
}
var steps = Math.ceil(Math.max(Math.abs(vx), Math.abs(vy)) / this.tilesize);
if (steps > 1)
{
var sx = vx / steps;
var sy = vy / steps;
for (var i = 0; i < steps && (sx || sy); i++)
{
this.step(res, x, y, sx, sy, objectWidth, objectHeight, vx, vy, i);
x = res.pos.x;
y = res.pos.y;
if (res.collision.x)
{
sx = 0;
vx = 0;
}
if (res.collision.y)
{
sy = 0;
vy = 0;
}
if (res.collision.slope)
{
break;
}
}
}
else
{
this.step(res, x, y, vx, vy, objectWidth, objectHeight, vx, vy, 0);
}
return res;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.CollisionMap#step
* @since 3.0.0
*
* @param {object} res - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} vx - [description]
* @param {number} vy - [description]
* @param {number} width - [description]
* @param {number} height - [description]
* @param {number} rvx - [description]
* @param {number} rvy - [description]
* @param {number} step - [description]
*/
step: function (res, x, y, vx, vy, width, height, rvx, rvy, step)
{
var t = 0;
var tileX;
var tileY;
var tilesize = this.tilesize;
var mapWidth = this.width;
var mapHeight = this.height;
// Horizontal
if (vx)
{
var pxOffsetX = (vx > 0 ? width : 0);
var tileOffsetX = (vx < 0 ? tilesize : 0);
var firstTileY = Math.max(Math.floor(y / tilesize), 0);
var lastTileY = Math.min(Math.ceil((y + height) / tilesize), mapHeight);
tileX = Math.floor((res.pos.x + pxOffsetX) / tilesize);
var prevTileX = Math.floor((x + pxOffsetX) / tilesize);
if (step > 0 || tileX === prevTileX || prevTileX < 0 || prevTileX >= mapWidth)
{
prevTileX = -1;
}
if (tileX >= 0 && tileX < mapWidth)
{
for (tileY = firstTileY; tileY < lastTileY; tileY++)
{
if (prevTileX !== -1)
{
t = this.data[tileY][prevTileX];
if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY))
{
break;
}
}
t = this.data[tileY][tileX];
if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY)))
{
if (t > 1 && t <= this.lastSlope && res.collision.slope)
{
break;
}
res.collision.x = true;
res.tile.x = t;
res.pos.x = (tileX * tilesize) - pxOffsetX + tileOffsetX;
x = res.pos.x;
rvx = 0;
break;
}
}
}
}
// Vertical
if (vy)
{
var pxOffsetY = (vy > 0 ? height : 0);
var tileOffsetY = (vy < 0 ? tilesize : 0);
var firstTileX = Math.max(Math.floor(res.pos.x / tilesize), 0);
var lastTileX = Math.min(Math.ceil((res.pos.x + width) / tilesize), mapWidth);
tileY = Math.floor((res.pos.y + pxOffsetY) / tilesize);
var prevTileY = Math.floor((y + pxOffsetY) / tilesize);
if (step > 0 || tileY === prevTileY || prevTileY < 0 || prevTileY >= mapHeight)
{
prevTileY = -1;
}
if (tileY >= 0 && tileY < mapHeight)
{
for (tileX = firstTileX; tileX < lastTileX; tileX++)
{
if (prevTileY !== -1)
{
t = this.data[prevTileY][tileX];
if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, prevTileY))
{
break;
}
}
t = this.data[tileY][tileX];
if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY)))
{
if (t > 1 && t <= this.lastSlope && res.collision.slope)
{
break;
}
res.collision.y = true;
res.tile.y = t;
res.pos.y = tileY * tilesize - pxOffsetY + tileOffsetY;
break;
}
}
}
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.CollisionMap#checkDef
* @since 3.0.0
*
* @param {object} res - [description]
* @param {number} t - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} vx - [description]
* @param {number} vy - [description]
* @param {number} width - [description]
* @param {number} height - [description]
* @param {number} tileX - [description]
* @param {number} tileY - [description]
*
* @return {boolean} [description]
*/
checkDef: function (res, t, x, y, vx, vy, width, height, tileX, tileY)
{
var def = this.tiledef[t];
if (!def)
{
return false;
}
var tilesize = this.tilesize;
var lx = (tileX + def[0]) * tilesize;
var ly = (tileY + def[1]) * tilesize;
var lvx = (def[2] - def[0]) * tilesize;
var lvy = (def[3] - def[1]) * tilesize;
var solid = def[4];
var tx = x + vx + (lvy < 0 ? width : 0) - lx;
var ty = y + vy + (lvx > 0 ? height : 0) - ly;
if (lvx * ty - lvy * tx > 0)
{
if (vx * -lvy + vy * lvx < 0)
{
return solid;
}
var length = Math.sqrt(lvx * lvx + lvy * lvy);
var nx = lvy / length;
var ny = -lvx / length;
var proj = tx * nx + ty * ny;
var px = nx * proj;
var py = ny * proj;
if (px * px + py * py >= vx * vx + vy * vy)
{
return solid || (lvx * (ty - vy) - lvy * (tx - vx) < 0.5);
}
res.pos.x = x + vx - px;
res.pos.y = y + vy - py;
res.collision.slope = { x: lvx, y: lvy, nx: nx, ny: ny };
return true;
}
return false;
}
});
module.exports = CollisionMap;

65
node_modules/phaser/plugins/impact/DefaultDefs.js generated vendored Normal file
View File

@ -0,0 +1,65 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var H = 0.5;
var N = 1 / 3;
var M = 2 / 3;
// Tile ID to Slope defs.
// First 4 elements = line data, final = solid or non-solid behind the line
module.exports = {
2: [ 0, 1, 1, 0, true ],
3: [ 0, 1, 1, H, true ],
4: [ 0, H, 1, 0, true ],
5: [ 0, 1, 1, M, true ],
6: [ 0, M, 1, N, true ],
7: [ 0, N, 1, 0, true ],
8: [ H, 1, 0, 0, true ],
9: [ 1, 0, H, 1, true ],
10: [ H, 1, 1, 0, true ],
11: [ 0, 0, H, 1, true ],
12: [ 0, 0, 1, 0, false ],
13: [ 1, 1, 0, 0, true ],
14: [ 1, H, 0, 0, true ],
15: [ 1, 1, 0, H, true ],
16: [ 1, N, 0, 0, true ],
17: [ 1, M, 0, N, true ],
18: [ 1, 1, 0, M, true ],
19: [ 1, 1, H, 0, true ],
20: [ H, 0, 0, 1, true ],
21: [ 0, 1, H, 0, true ],
22: [ H, 0, 1, 1, true ],
23: [ 1, 1, 0, 1, false ],
24: [ 0, 0, 1, 1, true ],
25: [ 0, 0, 1, H, true ],
26: [ 0, H, 1, 1, true ],
27: [ 0, 0, 1, N, true ],
28: [ 0, N, 1, M, true ],
29: [ 0, M, 1, 1, true ],
30: [ N, 1, 0, 0, true ],
31: [ 1, 0, M, 1, true ],
32: [ M, 1, 1, 0, true ],
33: [ 0, 0, N, 1, true ],
34: [ 1, 0, 1, 1, false ],
35: [ 1, 0, 0, 1, true ],
36: [ 1, H, 0, 1, true ],
37: [ 1, 0, 0, H, true ],
38: [ 1, M, 0, 1, true ],
39: [ 1, N, 0, M, true ],
40: [ 1, 0, 0, N, true ],
41: [ M, 1, N, 0, true ],
42: [ M, 0, N, 1, true ],
43: [ N, 1, M, 0, true ],
44: [ N, 0, M, 1, true ],
45: [ 0, 1, 0, 0, false ],
52: [ 1, 1, M, 0, true ],
53: [ N, 0, 0, 1, true ],
54: [ 0, 1, N, 0, true ],
55: [ M, 0, 1, 1, true ]
};

151
node_modules/phaser/plugins/impact/Factory.js generated vendored Normal file
View File

@ -0,0 +1,151 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var ImpactBody = require('./ImpactBody');
var ImpactImage = require('./ImpactImage');
var ImpactSprite = require('./ImpactSprite');
/**
* @classdesc
* The Impact Physics Factory allows you to easily create Impact Physics enabled Game Objects.
* Objects that are created by this Factory are automatically added to the physics world.
*
* @class Factory
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - A reference to the Impact Physics world.
*/
var Factory = new Class({
initialize:
function Factory (world)
{
/**
* A reference to the Impact Physics world.
*
* @name Phaser.Physics.Impact.Factory#world
* @type {Phaser.Physics.Impact.World}
* @since 3.0.0
*/
this.world = world;
/**
* A reference to the Scene.Systems this Impact Physics instance belongs to.
*
* @name Phaser.Physics.Impact.Factory#sys
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
this.sys = world.scene.sys;
},
/**
* Creates a new ImpactBody object and adds it to the physics simulation.
*
* @method Phaser.Physics.Impact.Factory#body
* @since 3.0.0
*
* @param {number} x - The horizontal position of the body in the physics world.
* @param {number} y - The vertical position of the body in the physics world.
* @param {number} width - The width of the body.
* @param {number} height - The height of the body.
*
* @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created.
*/
body: function (x, y, width, height)
{
return new ImpactBody(this.world, x, y, width, height);
},
/**
* Adds an Impact Physics Body to the given Game Object.
*
* @method Phaser.Physics.Impact.Factory#existing
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to receive the physics body.
*
* @return {Phaser.GameObjects.GameObject} The Game Object.
*/
existing: function (gameObject)
{
var x = gameObject.x - gameObject.frame.centerX;
var y = gameObject.y - gameObject.frame.centerY;
var w = gameObject.width;
var h = gameObject.height;
gameObject.body = this.world.create(x, y, w, h);
gameObject.body.parent = gameObject;
gameObject.body.gameObject = gameObject;
return gameObject;
},
/**
* Creates a new ImpactImage object and adds it to the physics world.
*
* @method Phaser.Physics.Impact.Factory#image
* @since 3.0.0
*
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*
* @return {Phaser.Physics.Impact.ImpactImage} The ImpactImage object that was created.
*/
image: function (x, y, key, frame)
{
var image = new ImpactImage(this.world, x, y, key, frame);
this.sys.displayList.add(image);
return image;
},
/**
* Creates a new ImpactSprite object and adds it to the physics world.
*
* @method Phaser.Physics.Impact.Factory#sprite
* @since 3.0.0
*
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*
* @return {Phaser.Physics.Impact.ImpactSprite} The ImpactSprite object that was created.
*/
sprite: function (x, y, key, frame)
{
var sprite = new ImpactSprite(this.world, x, y, key, frame);
this.sys.displayList.add(sprite);
this.sys.updateList.add(sprite);
return sprite;
},
/**
* Destroys this Factory.
*
* @method Phaser.Physics.Impact.Factory#destroy
* @since 3.5.0
*/
destroy: function ()
{
this.world = null;
this.sys = null;
}
});
module.exports = Factory;

50
node_modules/phaser/plugins/impact/GetVelocity.js generated vendored Normal file
View File

@ -0,0 +1,50 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Clamp = require('../../math/Clamp');
/**
* [description]
*
* @function Phaser.Physics.Impact.GetVelocity
* @since 3.0.0
*
* @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.
* @param {number} vel - [description]
* @param {number} accel - [description]
* @param {number} friction - [description]
* @param {number} max - [description]
*
* @return {number} [description]
*/
var GetVelocity = function (delta, vel, accel, friction, max)
{
if (accel)
{
return Clamp(vel + accel * delta, -max, max);
}
else if (friction)
{
var frictionDelta = friction * delta;
if (vel - frictionDelta > 0)
{
return vel - frictionDelta;
}
else if (vel + frictionDelta < 0)
{
return vel + frictionDelta;
}
else
{
return 0;
}
}
return Clamp(vel, -max, max);
};
module.exports = GetVelocity;

127
node_modules/phaser/plugins/impact/ImpactBody.js generated vendored Normal file
View File

@ -0,0 +1,127 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Components = require('./components');
/**
* @classdesc
* [description]
*
* @class ImpactBody
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {number} x - x - The horizontal position of this physics body in the world.
* @param {number} y - y - The vertical position of this physics body in the world.
* @param {number} width - The width of the physics body in the world.
* @param {number} height - [description]
*/
var ImpactBody = new Class({
Mixins: [
Components.Acceleration,
Components.BodyScale,
Components.BodyType,
Components.Bounce,
Components.CheckAgainst,
Components.Collides,
Components.Debug,
Components.Friction,
Components.Gravity,
Components.Offset,
Components.SetGameObject,
Components.Velocity
],
initialize:
function ImpactBody (world, x, y, width, height)
{
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x, y, width, height);
this.body.parent = this;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}
});
module.exports = ImpactBody;

152
node_modules/phaser/plugins/impact/ImpactImage.js generated vendored Normal file
View File

@ -0,0 +1,152 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Components = require('./components');
var Image = require('../../gameobjects/image/Image');
/**
* @classdesc
* An Impact Physics Image Game Object.
*
* An Image is a light-weight Game Object useful for the display of static images in your game,
* such as logos, backgrounds, scenery or other non-animated elements. Images can have input
* events and physics bodies, or be tweened, tinted or scrolled. The main difference between an
* Image and a Sprite is that you cannot animate an Image as they do not have the Animation component.
*
* @class ImpactImage
* @extends Phaser.GameObjects.Image
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {Phaser.Physics.Impact.World} world - The physics world of the Impact physics system.
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*/
var ImpactImage = new Class({
Extends: Image,
Mixins: [
Components.Acceleration,
Components.BodyScale,
Components.BodyType,
Components.Bounce,
Components.CheckAgainst,
Components.Collides,
Components.Debug,
Components.Friction,
Components.Gravity,
Components.Offset,
Components.SetGameObject,
Components.Velocity
],
initialize:
function ImpactImage (world, x, y, texture, frame)
{
Image.call(this, world.scene, x, y, texture, frame);
/**
* The Physics Body linked to an ImpactImage.
*
* @name Phaser.Physics.Impact.ImpactImage#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this;
this.body.gameObject = this;
/**
* The size of the physics Body.
*
* @name Phaser.Physics.Impact.ImpactImage#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* The X and Y offset of the Body from the left and top of the Image.
*
* @name Phaser.Physics.Impact.ImpactImage#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* The velocity, or rate of change the Body's position. Measured in pixels per second.
*
* @name Phaser.Physics.Impact.ImpactImage#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* The acceleration is the rate of change of the velocity. Measured in pixels per second squared.
*
* @name Phaser.Physics.Impact.ImpactImage#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* Friction between colliding bodies.
*
* @name Phaser.Physics.Impact.ImpactImage#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* The maximum velocity of the body.
*
* @name Phaser.Physics.Impact.ImpactImage#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}
});
module.exports = ImpactImage;

211
node_modules/phaser/plugins/impact/ImpactPhysics.js generated vendored Normal file
View File

@ -0,0 +1,211 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Factory = require('./Factory');
var GetFastValue = require('../../utils/object/GetFastValue');
var Merge = require('../../utils/object/Merge');
var PluginCache = require('../../plugins/PluginCache');
var SceneEvents = require('../../scene/events');
var World = require('./World');
/**
* @classdesc
* [description]
*
* @class ImpactPhysics
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - [description]
*/
var ImpactPhysics = new Class({
initialize:
function ImpactPhysics (scene)
{
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#scene
* @type {Phaser.Scene}
* @since 3.0.0
*/
this.scene = scene;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#systems
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
this.systems = scene.sys;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#config
* @type {object}
* @since 3.0.0
*/
this.config = this.getConfig();
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#world
* @type {Phaser.Physics.Impact.World}
* @since 3.0.0
*/
this.world;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#add
* @type {Phaser.Physics.Impact.Factory}
* @since 3.0.0
*/
this.add;
scene.sys.events.once(SceneEvents.BOOT, this.boot, this);
scene.sys.events.on(SceneEvents.START, this.start, this);
},
/**
* This method is called automatically, only once, when the Scene is first created.
* Do not invoke it directly.
*
* @method Phaser.Physics.Impact.ImpactPhysics#boot
* @private
* @since 3.5.1
*/
boot: function ()
{
this.world = new World(this.scene, this.config);
this.add = new Factory(this.world);
this.systems.events.once(SceneEvents.DESTROY, this.destroy, this);
},
/**
* This method is called automatically by the Scene when it is starting up.
* It is responsible for creating local systems, properties and listening for Scene events.
* Do not invoke it directly.
*
* @method Phaser.Physics.Impact.ImpactPhysics#start
* @private
* @since 3.5.0
*/
start: function ()
{
if (!this.world)
{
this.world = new World(this.scene, this.config);
this.add = new Factory(this.world);
}
var eventEmitter = this.systems.events;
eventEmitter.on(SceneEvents.UPDATE, this.world.update, this.world);
eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this);
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#getConfig
* @since 3.0.0
*
* @return {object} [description]
*/
getConfig: function ()
{
var gameConfig = this.systems.game.config.physics;
var sceneConfig = this.systems.settings.physics;
var config = Merge(
GetFastValue(sceneConfig, 'impact', {}),
GetFastValue(gameConfig, 'impact', {})
);
return config;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#pause
* @since 3.0.0
*
* @return {Phaser.Physics.Impact.World} The Impact World object.
*/
pause: function ()
{
return this.world.pause();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#resume
* @since 3.0.0
*
* @return {Phaser.Physics.Impact.World} The Impact World object.
*/
resume: function ()
{
return this.world.resume();
},
/**
* The Scene that owns this plugin is shutting down.
* We need to kill and reset all internal properties as well as stop listening to Scene events.
*
* @method Phaser.Physics.Impact.ImpactPhysics#shutdown
* @private
* @since 3.0.0
*/
shutdown: function ()
{
var eventEmitter = this.systems.events;
eventEmitter.off(SceneEvents.UPDATE, this.world.update, this.world);
eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this);
this.add.destroy();
this.world.destroy();
this.add = null;
this.world = null;
},
/**
* The Scene that owns this plugin is being destroyed.
* We need to shutdown and then kill off all external references.
*
* @method Phaser.Physics.Impact.ImpactPhysics#destroy
* @private
* @since 3.0.0
*/
destroy: function ()
{
this.shutdown();
this.scene.sys.events.off(SceneEvents.START, this.start, this);
this.scene = null;
this.systems = null;
}
});
PluginCache.register('ImpactPhysics', ImpactPhysics, 'impactPhysics');
module.exports = ImpactPhysics;

155
node_modules/phaser/plugins/impact/ImpactSprite.js generated vendored Normal file
View File

@ -0,0 +1,155 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Components = require('./components');
var Sprite = require('../../gameobjects/sprite/Sprite');
/**
* @classdesc
* An Impact Physics Sprite Game Object.
*
* A Sprite Game Object is used for the display of both static and animated images in your game.
* Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled
* and animated.
*
* The main difference between a Sprite and an Image Game Object is that you cannot animate Images.
* As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation
* Component. If you do not require animation then you can safely use Images to replace Sprites in all cases.
*
* @class ImpactSprite
* @extends Phaser.GameObjects.Sprite
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*/
var ImpactSprite = new Class({
Extends: Sprite,
Mixins: [
Components.Acceleration,
Components.BodyScale,
Components.BodyType,
Components.Bounce,
Components.CheckAgainst,
Components.Collides,
Components.Debug,
Components.Friction,
Components.Gravity,
Components.Offset,
Components.SetGameObject,
Components.Velocity
],
initialize:
function ImpactSprite (world, x, y, texture, frame)
{
Sprite.call(this, world.scene, x, y, texture, frame);
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this;
this.body.gameObject = this;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}
});
module.exports = ImpactSprite;

50
node_modules/phaser/plugins/impact/SeparateX.js generated vendored Normal file
View File

@ -0,0 +1,50 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* [description]
*
* @function Phaser.Physics.Impact.SeparateX
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {Phaser.Physics.Impact.Body} left - [description]
* @param {Phaser.Physics.Impact.Body} right - [description]
* @param {Phaser.Physics.Impact.Body} [weak] - [description]
*/
var SeparateX = function (world, left, right, weak)
{
var nudge = left.pos.x + left.size.x - right.pos.x;
// We have a weak entity, so just move this one
if (weak)
{
var strong = (left === weak) ? right : left;
weak.vel.x = -weak.vel.x * weak.bounciness + strong.vel.x;
var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, weak === left ? -nudge : nudge, 0, weak.size.x, weak.size.y);
weak.pos.x = resWeak.pos.x;
}
else
{
var v2 = (left.vel.x - right.vel.x) / 2;
left.vel.x = -v2;
right.vel.x = v2;
var resLeft = world.collisionMap.trace(left.pos.x, left.pos.y, -nudge / 2, 0, left.size.x, left.size.y);
left.pos.x = Math.floor(resLeft.pos.x);
var resRight = world.collisionMap.trace(right.pos.x, right.pos.y, nudge / 2, 0, right.size.x, right.size.y);
right.pos.x = Math.ceil(resRight.pos.x);
}
};
module.exports = SeparateX;

79
node_modules/phaser/plugins/impact/SeparateY.js generated vendored Normal file
View File

@ -0,0 +1,79 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* [description]
*
* @function Phaser.Physics.Impact.SeparateY
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {Phaser.Physics.Impact.Body} top - [description]
* @param {Phaser.Physics.Impact.Body} bottom - [description]
* @param {Phaser.Physics.Impact.Body} [weak] - [description]
*/
var SeparateY = function (world, top, bottom, weak)
{
var nudge = (top.pos.y + top.size.y - bottom.pos.y);
var nudgeX;
var resTop;
if (weak)
{
var strong = (top === weak) ? bottom : top;
weak.vel.y = -weak.vel.y * weak.bounciness + strong.vel.y;
// Riding on a platform?
nudgeX = 0;
if (weak === top && Math.abs(weak.vel.y - strong.vel.y) < weak.minBounceVelocity)
{
weak.standing = true;
nudgeX = strong.vel.x * world.delta;
}
var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, nudgeX, weak === top ? -nudge : nudge, weak.size.x, weak.size.y);
weak.pos.y = resWeak.pos.y;
weak.pos.x = resWeak.pos.x;
}
else if (world.gravity && (bottom.standing || top.vel.y > 0))
{
resTop = world.collisionMap.trace(top.pos.x, top.pos.y, 0, -(top.pos.y + top.size.y - bottom.pos.y), top.size.x, top.size.y);
top.pos.y = resTop.pos.y;
if (top.bounciness > 0 && top.vel.y > top.minBounceVelocity)
{
top.vel.y *= -top.bounciness;
}
else
{
top.standing = true;
top.vel.y = 0;
}
}
else
{
var v2 = (top.vel.y - bottom.vel.y) / 2;
top.vel.y = -v2;
bottom.vel.y = v2;
nudgeX = bottom.vel.x * world.delta;
resTop = world.collisionMap.trace(top.pos.x, top.pos.y, nudgeX, -nudge / 2, top.size.x, top.size.y);
top.pos.y = resTop.pos.y;
var resBottom = world.collisionMap.trace(bottom.pos.x, bottom.pos.y, 0, nudge / 2, bottom.size.x, bottom.size.y);
bottom.pos.y = resBottom.pos.y;
}
};
module.exports = SeparateY;

70
node_modules/phaser/plugins/impact/Solver.js generated vendored Normal file
View File

@ -0,0 +1,70 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var COLLIDES = require('./COLLIDES');
var Events = require('./events');
var SeparateX = require('./SeparateX');
var SeparateY = require('./SeparateY');
/**
* Impact Physics Solver
*
* @function Phaser.Physics.Impact.Solver
* @fires Phaser.Physics.Impact.Events#COLLIDE
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - The Impact simulation to run the solver in.
* @param {Phaser.Physics.Impact.Body} bodyA - The first body in the collision.
* @param {Phaser.Physics.Impact.Body} bodyB - The second body in the collision.
*/
var Solver = function (world, bodyA, bodyB)
{
var weak = null;
if (bodyA.collides === COLLIDES.LITE || bodyB.collides === COLLIDES.FIXED)
{
weak = bodyA;
}
else if (bodyB.collides === COLLIDES.LITE || bodyA.collides === COLLIDES.FIXED)
{
weak = bodyB;
}
if (bodyA.last.x + bodyA.size.x > bodyB.last.x && bodyA.last.x < bodyB.last.x + bodyB.size.x)
{
if (bodyA.last.y < bodyB.last.y)
{
SeparateY(world, bodyA, bodyB, weak);
}
else
{
SeparateY(world, bodyB, bodyA, weak);
}
bodyA.collideWith(bodyB, 'y');
bodyB.collideWith(bodyA, 'y');
world.emit(Events.COLLIDE, bodyA, bodyB, 'y');
}
else if (bodyA.last.y + bodyA.size.y > bodyB.last.y && bodyA.last.y < bodyB.last.y + bodyB.size.y)
{
if (bodyA.last.x < bodyB.last.x)
{
SeparateX(world, bodyA, bodyB, weak);
}
else
{
SeparateX(world, bodyB, bodyA, weak);
}
bodyA.collideWith(bodyB, 'x');
bodyB.collideWith(bodyA, 'x');
world.emit(Events.COLLIDE, bodyA, bodyB, 'x');
}
};
module.exports = Solver;

62
node_modules/phaser/plugins/impact/TYPE.js generated vendored Normal file
View File

@ -0,0 +1,62 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Collision Types - Determine if and how entities collide with each other.
*
* In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves,
* while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE
* collisions, both entities are moved. LITE or PASSIVE entities don't collide
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
* FIXED collisions is undefined.
*
* @namespace Phaser.Physics.Impact.TYPE
* @memberof Phaser.Physics.Impact
* @since 3.0.0
*/
module.exports = {
/**
* Collides with nothing.
*
* @name Phaser.Physics.Impact.TYPE.NONE
* @type {integer}
* @const
* @since 3.0.0
*/
NONE: 0,
/**
* Type A. Collides with Type B.
*
* @name Phaser.Physics.Impact.TYPE.A
* @type {integer}
* @const
* @since 3.0.0
*/
A: 1,
/**
* Type B. Collides with Type A.
*
* @name Phaser.Physics.Impact.TYPE.B
* @type {integer}
* @const
* @since 3.0.0
*/
B: 2,
/**
* Collides with both types A and B.
*
* @name Phaser.Physics.Impact.TYPE.BOTH
* @type {integer}
* @const
* @since 3.0.0
*/
BOTH: 3
};

89
node_modules/phaser/plugins/impact/UpdateMotion.js generated vendored Normal file
View File

@ -0,0 +1,89 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Set up the trace-result
* var res = {
* collision: {x: false, y: false, slope: false},
* pos: {x: x, y: y},
* tile: {x: 0, y: 0}
* };
*
* @function Phaser.Physics.Impact.UpdateMotion
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {object} res - [description]
*/
var UpdateMotion = function (body, res)
{
body.standing = false;
// Y
if (res.collision.y)
{
if (body.bounciness > 0 && Math.abs(body.vel.y) > body.minBounceVelocity)
{
body.vel.y *= -body.bounciness;
}
else
{
if (body.vel.y > 0)
{
body.standing = true;
}
body.vel.y = 0;
}
}
// X
if (res.collision.x)
{
if (body.bounciness > 0 && Math.abs(body.vel.x) > body.minBounceVelocity)
{
body.vel.x *= -body.bounciness;
}
else
{
body.vel.x = 0;
}
}
// SLOPE
if (res.collision.slope)
{
var s = res.collision.slope;
if (body.bounciness > 0)
{
var proj = body.vel.x * s.nx + body.vel.y * s.ny;
body.vel.x = (body.vel.x - s.nx * proj * 2) * body.bounciness;
body.vel.y = (body.vel.y - s.ny * proj * 2) * body.bounciness;
}
else
{
var lengthSquared = s.x * s.x + s.y * s.y;
var dot = (body.vel.x * s.x + body.vel.y * s.y) / lengthSquared;
body.vel.x = s.x * dot;
body.vel.y = s.y * dot;
var angle = Math.atan2(s.x, s.y);
if (angle > body.slopeStanding.min && angle < body.slopeStanding.max)
{
body.standing = true;
}
}
}
body.pos.x = res.pos.x;
body.pos.y = res.pos.y;
};
module.exports = UpdateMotion;

979
node_modules/phaser/plugins/impact/World.js generated vendored Normal file
View File

@ -0,0 +1,979 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Body = require('./Body');
var Class = require('../../utils/Class');
var COLLIDES = require('./COLLIDES');
var CollisionMap = require('./CollisionMap');
var EventEmitter = require('eventemitter3');
var Events = require('./events');
var GetFastValue = require('../../utils/object/GetFastValue');
var HasValue = require('../../utils/object/HasValue');
var Set = require('../../structs/Set');
var Solver = require('./Solver');
var TILEMAP_FORMATS = require('../../tilemaps/Formats');
var TYPE = require('./TYPE');
/**
* @classdesc
* [description]
*
* @class World
* @extends Phaser.Events.EventEmitter
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - The Scene to which this Impact World instance belongs.
* @param {Phaser.Types.Physics.Impact.WorldConfig} config - [description]
*/
var World = new Class({
Extends: EventEmitter,
initialize:
function World (scene, config)
{
EventEmitter.call(this);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#scene
* @type {Phaser.Scene}
* @since 3.0.0
*/
this.scene = scene;
/**
* [description]
*
* @name Phaser.Physics.Impact.World#bodies
* @type {Phaser.Structs.Set.<Phaser.Physics.Impact.Body>}
* @since 3.0.0
*/
this.bodies = new Set();
/**
* [description]
*
* @name Phaser.Physics.Impact.World#gravity
* @type {number}
* @default 0
* @since 3.0.0
*/
this.gravity = GetFastValue(config, 'gravity', 0);
/**
* Spatial hash cell dimensions
*
* @name Phaser.Physics.Impact.World#cellSize
* @type {integer}
* @default 64
* @since 3.0.0
*/
this.cellSize = GetFastValue(config, 'cellSize', 64);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#collisionMap
* @type {Phaser.Physics.Impact.CollisionMap}
* @since 3.0.0
*/
this.collisionMap = new CollisionMap();
/**
* [description]
*
* @name Phaser.Physics.Impact.World#timeScale
* @type {number}
* @default 1
* @since 3.0.0
*/
this.timeScale = GetFastValue(config, 'timeScale', 1);
/**
* Impacts maximum time step is 20 fps.
*
* @name Phaser.Physics.Impact.World#maxStep
* @type {number}
* @default 0.05
* @since 3.0.0
*/
this.maxStep = GetFastValue(config, 'maxStep', 0.05);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#enabled
* @type {boolean}
* @default true
* @since 3.0.0
*/
this.enabled = true;
/**
* [description]
*
* @name Phaser.Physics.Impact.World#drawDebug
* @type {boolean}
* @since 3.0.0
*/
this.drawDebug = GetFastValue(config, 'debug', false);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#debugGraphic
* @type {Phaser.GameObjects.Graphics}
* @since 3.0.0
*/
this.debugGraphic;
var _maxVelocity = GetFastValue(config, 'maxVelocity', 100);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#defaults
* @type {Phaser.Types.Physics.Impact.WorldDefaults}
* @since 3.0.0
*/
this.defaults = {
debugShowBody: GetFastValue(config, 'debugShowBody', true),
debugShowVelocity: GetFastValue(config, 'debugShowVelocity', true),
bodyDebugColor: GetFastValue(config, 'debugBodyColor', 0xff00ff),
velocityDebugColor: GetFastValue(config, 'debugVelocityColor', 0x00ff00),
maxVelocityX: GetFastValue(config, 'maxVelocityX', _maxVelocity),
maxVelocityY: GetFastValue(config, 'maxVelocityY', _maxVelocity),
minBounceVelocity: GetFastValue(config, 'minBounceVelocity', 40),
gravityFactor: GetFastValue(config, 'gravityFactor', 1),
bounciness: GetFastValue(config, 'bounciness', 0)
};
/**
* An object containing the 4 wall bodies that bound the physics world.
*
* @name Phaser.Physics.Impact.World#walls
* @type {Phaser.Types.Physics.Impact.WorldWalls}
* @since 3.0.0
*/
this.walls = { left: null, right: null, top: null, bottom: null };
/**
* [description]
*
* @name Phaser.Physics.Impact.World#delta
* @type {number}
* @default 0
* @since 3.0.0
*/
this.delta = 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.World#_lastId
* @type {number}
* @private
* @default 0
* @since 3.0.0
*/
this._lastId = 0;
if (GetFastValue(config, 'setBounds', false))
{
var boundsConfig = config['setBounds'];
if (typeof boundsConfig === 'boolean')
{
this.setBounds();
}
else
{
var x = GetFastValue(boundsConfig, 'x', 0);
var y = GetFastValue(boundsConfig, 'y', 0);
var width = GetFastValue(boundsConfig, 'width', scene.sys.scale.width);
var height = GetFastValue(boundsConfig, 'height', scene.sys.scale.height);
var thickness = GetFastValue(boundsConfig, 'thickness', 64);
var left = GetFastValue(boundsConfig, 'left', true);
var right = GetFastValue(boundsConfig, 'right', true);
var top = GetFastValue(boundsConfig, 'top', true);
var bottom = GetFastValue(boundsConfig, 'bottom', true);
this.setBounds(x, y, width, height, thickness, left, right, top, bottom);
}
}
if (this.drawDebug)
{
this.createDebugGraphic();
}
},
/**
* Sets the collision map for the world either from a Weltmeister JSON level in the cache or from
* a 2D array. If loading from a Weltmeister level, the map must have a layer called "collision".
*
* @method Phaser.Physics.Impact.World#setCollisionMap
* @since 3.0.0
*
* @param {(string|integer[][])} key - Either a string key that corresponds to a Weltmeister level
* in the cache, or a 2D array of collision IDs.
* @param {integer} tileSize - The size of a tile. This is optional if loading from a Weltmeister
* level in the cache.
*
* @return {?Phaser.Physics.Impact.CollisionMap} The newly created CollisionMap, or null if the method failed to
* create the CollisionMap.
*/
setCollisionMap: function (key, tileSize)
{
if (typeof key === 'string')
{
var tilemapData = this.scene.cache.tilemap.get(key);
if (!tilemapData || tilemapData.format !== TILEMAP_FORMATS.WELTMEISTER)
{
console.warn('The specified key does not correspond to a Weltmeister tilemap: ' + key);
return null;
}
var layers = tilemapData.data.layer;
var collisionLayer;
for (var i = 0; i < layers.length; i++)
{
if (layers[i].name === 'collision')
{
collisionLayer = layers[i];
break;
}
}
if (tileSize === undefined) { tileSize = collisionLayer.tilesize; }
this.collisionMap = new CollisionMap(tileSize, collisionLayer.data);
}
else if (Array.isArray(key))
{
this.collisionMap = new CollisionMap(tileSize, key);
}
else
{
console.warn('Invalid Weltmeister collision map data: ' + key);
}
return this.collisionMap;
},
/**
* Sets the collision map for the world from a tilemap layer. Only tiles that are marked as
* colliding will be used. You can specify the mapping from tiles to slope IDs in a couple of
* ways. The easiest is to use Tiled and the slopeTileProperty option. Alternatively, you can
* manually create a slopeMap that stores the mapping between tile indices and slope IDs.
*
* @method Phaser.Physics.Impact.World#setCollisionMapFromTilemapLayer
* @since 3.0.0
*
* @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The tilemap layer to use.
* @param {Phaser.Types.Physics.Impact.CollisionOptions} [options] - Options for controlling the mapping from tiles to slope IDs.
*
* @return {Phaser.Physics.Impact.CollisionMap} The newly created CollisionMap.
*/
setCollisionMapFromTilemapLayer: function (tilemapLayer, options)
{
if (options === undefined) { options = {}; }
var slopeProperty = GetFastValue(options, 'slopeProperty', null);
var slopeMap = GetFastValue(options, 'slopeMap', null);
var collidingSlope = GetFastValue(options, 'defaultCollidingSlope', null);
var nonCollidingSlope = GetFastValue(options, 'defaultNonCollidingSlope', 0);
var layerData = tilemapLayer.layer;
var tileSize = layerData.baseTileWidth;
var collisionData = [];
for (var ty = 0; ty < layerData.height; ty++)
{
collisionData[ty] = [];
for (var tx = 0; tx < layerData.width; tx++)
{
var tile = layerData.data[ty][tx];
if (tile && tile.collides)
{
if (slopeProperty !== null && HasValue(tile.properties, slopeProperty))
{
collisionData[ty][tx] = parseInt(tile.properties[slopeProperty], 10);
}
else if (slopeMap !== null && HasValue(slopeMap, tile.index))
{
collisionData[ty][tx] = slopeMap[tile.index];
}
else if (collidingSlope !== null)
{
collisionData[ty][tx] = collidingSlope;
}
else
{
collisionData[ty][tx] = tile.index;
}
}
else
{
collisionData[ty][tx] = nonCollidingSlope;
}
}
}
this.collisionMap = new CollisionMap(tileSize, collisionData);
return this.collisionMap;
},
/**
* Sets the bounds of the Physics world to match the given world pixel dimensions.
* You can optionally set which 'walls' to create: left, right, top or bottom.
* If none of the walls are given it will default to use the walls settings it had previously.
* I.e. if you previously told it to not have the left or right walls, and you then adjust the world size
* the newly created bounds will also not have the left and right walls.
* Explicitly state them in the parameters to override this.
*
* @method Phaser.Physics.Impact.World#setBounds
* @since 3.0.0
*
* @param {number} [x] - The x coordinate of the top-left corner of the bounds.
* @param {number} [y] - The y coordinate of the top-left corner of the bounds.
* @param {number} [width] - The width of the bounds.
* @param {number} [height] - The height of the bounds.
* @param {number} [thickness=64] - [description]
* @param {boolean} [left=true] - If true will create the left bounds wall.
* @param {boolean} [right=true] - If true will create the right bounds wall.
* @param {boolean} [top=true] - If true will create the top bounds wall.
* @param {boolean} [bottom=true] - If true will create the bottom bounds wall.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setBounds: function (x, y, width, height, thickness, left, right, top, bottom)
{
if (x === undefined) { x = 0; }
if (y === undefined) { y = 0; }
if (width === undefined) { width = this.scene.sys.scale.width; }
if (height === undefined) { height = this.scene.sys.scale.height; }
if (thickness === undefined) { thickness = 64; }
if (left === undefined) { left = true; }
if (right === undefined) { right = true; }
if (top === undefined) { top = true; }
if (bottom === undefined) { bottom = true; }
this.updateWall(left, 'left', x - thickness, y, thickness, height);
this.updateWall(right, 'right', x + width, y, thickness, height);
this.updateWall(top, 'top', x, y - thickness, width, thickness);
this.updateWall(bottom, 'bottom', x, y + height, width, thickness);
return this;
},
/**
* position = 'left', 'right', 'top' or 'bottom'
*
* @method Phaser.Physics.Impact.World#updateWall
* @since 3.0.0
*
* @param {boolean} add - [description]
* @param {string} position - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} width - [description]
* @param {number} height - [description]
*/
updateWall: function (add, position, x, y, width, height)
{
var wall = this.walls[position];
if (add)
{
if (wall)
{
wall.resetSize(x, y, width, height);
}
else
{
this.walls[position] = this.create(x, y, width, height);
this.walls[position].name = position;
this.walls[position].gravityFactor = 0;
this.walls[position].collides = COLLIDES.FIXED;
}
}
else
{
if (wall)
{
this.bodies.remove(wall);
}
this.walls[position] = null;
}
},
/**
* Creates a Graphics Game Object used for debug display and enables the world for debug drawing.
*
* @method Phaser.Physics.Impact.World#createDebugGraphic
* @since 3.0.0
*
* @return {Phaser.GameObjects.Graphics} The Graphics object created that will have the debug visuals drawn to it.
*/
createDebugGraphic: function ()
{
var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 });
graphic.setDepth(Number.MAX_VALUE);
this.debugGraphic = graphic;
this.drawDebug = true;
return graphic;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#getNextID
* @since 3.0.0
*
* @return {integer} [description]
*/
getNextID: function ()
{
return this._lastId++;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#create
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} sizeX - [description]
* @param {number} sizeY - [description]
*
* @return {Phaser.Physics.Impact.Body} The Body that was added to this World.
*/
create: function (x, y, sizeX, sizeY)
{
var body = new Body(this, x, y, sizeX, sizeY);
this.bodies.set(body);
return body;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#remove
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} object - The Body to remove from this World.
*/
remove: function (object)
{
this.bodies.delete(object);
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#pause
* @fires Phaser.Physics.Impact.Events#PAUSE
* @since 3.0.0
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
pause: function ()
{
this.enabled = false;
this.emit(Events.PAUSE);
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#resume
* @fires Phaser.Physics.Impact.Events#RESUME
* @since 3.0.0
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
resume: function ()
{
this.enabled = true;
this.emit(Events.RESUME);
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#update
* @since 3.0.0
*
* @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.
* @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.
*/
update: function (time, delta)
{
if (!this.enabled || this.bodies.size === 0)
{
return;
}
// Impact uses a divided delta value that is clamped to the maxStep (20fps) maximum
var clampedDelta = Math.min(delta / 1000, this.maxStep) * this.timeScale;
this.delta = clampedDelta;
// Update all active bodies
var i;
var body;
var bodies = this.bodies.entries;
var len = bodies.length;
var hash = {};
var size = this.cellSize;
for (i = 0; i < len; i++)
{
body = bodies[i];
if (body.enabled)
{
body.update(clampedDelta);
}
}
// Run collision against them all now they're in the new positions from the update
for (i = 0; i < len; i++)
{
body = bodies[i];
if (body && !body.skipHash())
{
this.checkHash(body, hash, size);
}
}
if (this.drawDebug)
{
var graphics = this.debugGraphic;
graphics.clear();
for (i = 0; i < len; i++)
{
body = bodies[i];
if (body && body.willDrawDebug())
{
body.drawDebug(graphics);
}
}
}
},
/**
* Check the body against the spatial hash.
*
* @method Phaser.Physics.Impact.World#checkHash
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {object} hash - [description]
* @param {number} size - [description]
*/
checkHash: function (body, hash, size)
{
var checked = {};
var xmin = Math.floor(body.pos.x / size);
var ymin = Math.floor(body.pos.y / size);
var xmax = Math.floor((body.pos.x + body.size.x) / size) + 1;
var ymax = Math.floor((body.pos.y + body.size.y) / size) + 1;
for (var x = xmin; x < xmax; x++)
{
for (var y = ymin; y < ymax; y++)
{
if (!hash[x])
{
hash[x] = {};
hash[x][y] = [ body ];
}
else if (!hash[x][y])
{
hash[x][y] = [ body ];
}
else
{
var cell = hash[x][y];
for (var c = 0; c < cell.length; c++)
{
if (body.touches(cell[c]) && !checked[cell[c].id])
{
checked[cell[c].id] = true;
this.checkBodies(body, cell[c]);
}
}
cell.push(body);
}
}
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#checkBodies
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} bodyA - [description]
* @param {Phaser.Physics.Impact.Body} bodyB - [description]
*/
checkBodies: function (bodyA, bodyB)
{
// 2 fixed bodies won't do anything
if (bodyA.collides === COLLIDES.FIXED && bodyB.collides === COLLIDES.FIXED)
{
return;
}
// bitwise checks
if (bodyA.checkAgainst & bodyB.type)
{
bodyA.check(bodyB);
}
if (bodyB.checkAgainst & bodyA.type)
{
bodyB.check(bodyA);
}
if (bodyA.collides && bodyB.collides && bodyA.collides + bodyB.collides > COLLIDES.ACTIVE)
{
Solver(this, bodyA, bodyB);
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCollidesNever
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCollidesNever: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.NEVER;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setLite
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setLite: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.LITE;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setPassive
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setPassive: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.PASSIVE;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setActive
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setActive: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.ACTIVE;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setFixed
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setFixed: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.FIXED;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setTypeNone
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeNone: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.NONE;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setTypeA
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.A;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setTypeB
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.B;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setAvsB
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setAvsB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.A;
bodies[i].checkAgainst = TYPE.B;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setBvsA
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setBvsA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.B;
bodies[i].checkAgainst = TYPE.A;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCheckAgainstNone
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstNone: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].checkAgainst = TYPE.NONE;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCheckAgainstA
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].checkAgainst = TYPE.A;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCheckAgainstB
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].checkAgainst = TYPE.B;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#shutdown
* @since 3.0.0
*/
shutdown: function ()
{
this.removeAllListeners();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#destroy
* @since 3.0.0
*/
destroy: function ()
{
this.removeAllListeners();
this.scene = null;
this.bodies.clear();
this.bodies = null;
this.collisionMap = null;
}
});
module.exports = World;

View File

@ -0,0 +1,71 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Acceleration component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Acceleration
* @since 3.0.0
*/
var Acceleration = {
/**
* Sets the horizontal acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationX
* @since 3.0.0
*
* @param {number} x - The amount of acceleration to apply.
*
* @return {this} This Game Object.
*/
setAccelerationX: function (x)
{
this.accel.x = x;
return this;
},
/**
* Sets the vertical acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationY
* @since 3.0.0
*
* @param {number} y - The amount of acceleration to apply.
*
* @return {this} This Game Object.
*/
setAccelerationY: function (y)
{
this.accel.y = y;
return this;
},
/**
* Sets the horizontal and vertical acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAcceleration
* @since 3.0.0
*
* @param {number} x - The amount of horizontal acceleration to apply.
* @param {number} y - The amount of vertical acceleration to apply.
*
* @return {this} This Game Object.
*/
setAcceleration: function (x, y)
{
this.accel.x = x;
this.accel.y = y;
return this;
}
};
module.exports = Acceleration;

View File

@ -0,0 +1,68 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Body Scale component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.BodyScale
* @since 3.0.0
*/
var BodyScale = {
/**
* Sets the size of the physics body.
*
* @method Phaser.Physics.Impact.Components.BodyScale#setBodySize
* @since 3.0.0
*
* @param {number} width - The width of the body in pixels.
* @param {number} [height=width] - The height of the body in pixels.
*
* @return {this} This Game Object.
*/
setBodySize: function (width, height)
{
if (height === undefined) { height = width; }
this.body.size.x = Math.round(width);
this.body.size.y = Math.round(height);
return this;
},
/**
* Sets the scale of the physics body.
*
* @method Phaser.Physics.Impact.Components.BodyScale#setBodyScale
* @since 3.0.0
*
* @param {number} scaleX - The horizontal scale of the body.
* @param {number} [scaleY] - The vertical scale of the body. If not given, will use the horizontal scale value.
*
* @return {this} This Game Object.
*/
setBodyScale: function (scaleX, scaleY)
{
if (scaleY === undefined) { scaleY = scaleX; }
var gameObject = this.body.gameObject;
if (gameObject)
{
gameObject.setScale(scaleX, scaleY);
return this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY);
}
else
{
return this.setBodySize(this.body.size.x * scaleX, this.body.size.y * scaleY);
}
}
};
module.exports = BodyScale;

View File

@ -0,0 +1,78 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var TYPE = require('../TYPE');
/**
* The Impact Body Type component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.BodyType
* @since 3.0.0
*/
var BodyType = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.BodyType#getBodyType
* @since 3.0.0
*
* @return {number} [description]
*/
getBodyType: function ()
{
return this.body.type;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.BodyType#setTypeNone
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setTypeNone: function ()
{
this.body.type = TYPE.NONE;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.BodyType#setTypeA
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setTypeA: function ()
{
this.body.type = TYPE.A;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.BodyType#setTypeB
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setTypeB: function ()
{
this.body.type = TYPE.B;
return this;
}
};
module.exports = BodyType;

View File

@ -0,0 +1,74 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Bounce component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Bounce
* @since 3.0.0
*/
var Bounce = {
/**
* Sets the impact physics bounce, or restitution, value.
*
* @method Phaser.Physics.Impact.Components.Bounce#setBounce
* @since 3.0.0
*
* @param {number} value - A value between 0 (no rebound) and 1 (full rebound)
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setBounce: function (value)
{
this.body.bounciness = value;
return this;
},
/**
* Sets the minimum velocity the body is allowed to be moving to be considered for rebound.
*
* @method Phaser.Physics.Impact.Components.Bounce#setMinBounceVelocity
* @since 3.0.0
*
* @param {number} value - The minimum allowed velocity.
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setMinBounceVelocity: function (value)
{
this.body.minBounceVelocity = value;
return this;
},
/**
* The bounce, or restitution, value of this body.
* A value between 0 (no rebound) and 1 (full rebound)
*
* @name Phaser.Physics.Impact.Components.Bounce#bounce
* @type {number}
* @since 3.0.0
*/
bounce: {
get: function ()
{
return this.body.bounciness;
},
set: function (value)
{
this.body.bounciness = value;
}
}
};
module.exports = Bounce;

View File

@ -0,0 +1,116 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var TYPE = require('../TYPE');
/**
* The Impact Check Against component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.CheckAgainst
* @since 3.0.0
*/
var CheckAgainst = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.CheckAgainst#setAvsB
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setAvsB: function ()
{
this.setTypeA();
return this.setCheckAgainstB();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.CheckAgainst#setBvsA
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setBvsA: function ()
{
this.setTypeB();
return this.setCheckAgainstA();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstNone
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setCheckAgainstNone: function ()
{
this.body.checkAgainst = TYPE.NONE;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstA
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setCheckAgainstA: function ()
{
this.body.checkAgainst = TYPE.A;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstB
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setCheckAgainstB: function ()
{
this.body.checkAgainst = TYPE.B;
return this;
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.CheckAgainst#checkAgainst
* @type {number}
* @since 3.0.0
*/
checkAgainst: {
get: function ()
{
return this.body.checkAgainst;
},
set: function (value)
{
this.body.checkAgainst = value;
}
}
};
module.exports = CheckAgainst;

View File

@ -0,0 +1,150 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var COLLIDES = require('../COLLIDES');
/**
* @callback CollideCallback
*
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {Phaser.Physics.Impact.Body} other - [description]
* @param {string} axis - [description]
*/
/**
* The Impact Collides component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Collides
* @since 3.0.0
*/
var Collides = {
_collideCallback: null,
_callbackScope: null,
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setCollideCallback
* @since 3.0.0
*
* @param {CollideCallback} callback - [description]
* @param {*} scope - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setCollideCallback: function (callback, scope)
{
this._collideCallback = callback;
if (scope)
{
this._callbackScope = scope;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setCollidesNever
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setCollidesNever: function ()
{
this.body.collides = COLLIDES.NEVER;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setLiteCollision
* @since 3.6.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setLiteCollision: function ()
{
this.body.collides = COLLIDES.LITE;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setPassiveCollision
* @since 3.6.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setPassiveCollision: function ()
{
this.body.collides = COLLIDES.PASSIVE;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setActiveCollision
* @since 3.6.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setActiveCollision: function ()
{
this.body.collides = COLLIDES.ACTIVE;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setFixedCollision
* @since 3.6.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setFixedCollision: function ()
{
this.body.collides = COLLIDES.FIXED;
return this;
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.Collides#collides
* @type {number}
* @since 3.0.0
*/
collides: {
get: function ()
{
return this.body.collides;
},
set: function (value)
{
this.body.collides = value;
}
}
};
module.exports = Collides;

119
node_modules/phaser/plugins/impact/components/Debug.js generated vendored Normal file
View File

@ -0,0 +1,119 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Debug component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Debug
* @since 3.0.0
*/
var Debug = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Debug#setDebug
* @since 3.0.0
*
* @param {boolean} showBody - [description]
* @param {boolean} showVelocity - [description]
* @param {number} bodyColor - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setDebug: function (showBody, showVelocity, bodyColor)
{
this.debugShowBody = showBody;
this.debugShowVelocity = showVelocity;
this.debugBodyColor = bodyColor;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Debug#setDebugBodyColor
* @since 3.0.0
*
* @param {number} value - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setDebugBodyColor: function (value)
{
this.body.debugBodyColor = value;
return this;
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.Debug#debugShowBody
* @type {boolean}
* @since 3.0.0
*/
debugShowBody: {
get: function ()
{
return this.body.debugShowBody;
},
set: function (value)
{
this.body.debugShowBody = value;
}
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.Debug#debugShowVelocity
* @type {boolean}
* @since 3.0.0
*/
debugShowVelocity: {
get: function ()
{
return this.body.debugShowVelocity;
},
set: function (value)
{
this.body.debugShowVelocity = value;
}
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.Debug#debugBodyColor
* @type {number}
* @since 3.0.0
*/
debugBodyColor: {
get: function ()
{
return this.body.debugBodyColor;
},
set: function (value)
{
this.body.debugBodyColor = value;
}
}
};
module.exports = Debug;

View File

@ -0,0 +1,71 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Friction component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Friction
* @since 3.0.0
*/
var Friction = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Friction#setFrictionX
* @since 3.0.0
*
* @param {number} x - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setFrictionX: function (x)
{
this.friction.x = x;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Friction#setFrictionY
* @since 3.0.0
*
* @param {number} y - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setFrictionY: function (y)
{
this.friction.y = y;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Friction#setFriction
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setFriction: function (x, y)
{
this.friction.x = x;
this.friction.y = y;
return this;
}
};
module.exports = Friction;

View File

@ -0,0 +1,56 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Gravity component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Gravity
* @since 3.0.0
*/
var Gravity = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Gravity#setGravity
* @since 3.0.0
*
* @param {number} value - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setGravity: function (value)
{
this.body.gravityFactor = value;
return this;
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.Gravity#gravity
* @type {number}
* @since 3.0.0
*/
gravity: {
get: function ()
{
return this.body.gravityFactor;
},
set: function (value)
{
this.body.gravityFactor = value;
}
}
};
module.exports = Gravity;

View File

@ -0,0 +1,44 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Offset component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Offset
* @since 3.0.0
*/
var Offset = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Offset#setOffset
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} [width] - [description]
* @param {number} [height] - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setOffset: function (x, y, width, height)
{
this.body.offset.x = x;
this.body.offset.y = y;
if (width)
{
this.setBodySize(width, height);
}
return this;
}
};
module.exports = Offset;

View File

@ -0,0 +1,70 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Set Game Object component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.SetGameObject
* @since 3.0.0
*/
var SetGameObject = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.SetGameObject#setGameObject
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
* @param {boolean} [sync=true] - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setGameObject: function (gameObject, sync)
{
if (sync === undefined) { sync = true; }
if (gameObject)
{
this.body.gameObject = gameObject;
if (sync)
{
this.syncGameObject();
}
}
else
{
this.body.gameObject = null;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.SetGameObject#syncGameObject
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
syncGameObject: function ()
{
var gameObject = this.body.gameObject;
if (gameObject)
{
this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY);
}
return this;
}
};
module.exports = SetGameObject;

View File

@ -0,0 +1,94 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Velocity component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Velocity
* @since 3.0.0
*/
var Velocity = {
/**
* Sets the horizontal velocity of the physics body.
*
* @method Phaser.Physics.Impact.Components.Velocity#setVelocityX
* @since 3.0.0
*
* @param {number} x - The horizontal velocity value.
*
* @return {this} This Game Object.
*/
setVelocityX: function (x)
{
this.vel.x = x;
return this;
},
/**
* Sets the vertical velocity of the physics body.
*
* @method Phaser.Physics.Impact.Components.Velocity#setVelocityY
* @since 3.0.0
*
* @param {number} y - The vertical velocity value.
*
* @return {this} This Game Object.
*/
setVelocityY: function (y)
{
this.vel.y = y;
return this;
},
/**
* Sets the horizontal and vertical velocities of the physics body.
*
* @method Phaser.Physics.Impact.Components.Velocity#setVelocity
* @since 3.0.0
*
* @param {number} x - The horizontal velocity value.
* @param {number} [y=x] - The vertical velocity value. If not given, defaults to the horizontal value.
*
* @return {this} This Game Object.
*/
setVelocity: function (x, y)
{
if (y === undefined) { y = x; }
this.vel.x = x;
this.vel.y = y;
return this;
},
/**
* Sets the maximum velocity this body can travel at.
*
* @method Phaser.Physics.Impact.Components.Velocity#setMaxVelocity
* @since 3.0.0
*
* @param {number} x - The maximum allowed horizontal velocity.
* @param {number} [y=x] - The maximum allowed vertical velocity. If not given, defaults to the horizontal value.
*
* @return {this} This Game Object.
*/
setMaxVelocity: function (x, y)
{
if (y === undefined) { y = x; }
this.maxVel.x = x;
this.maxVel.y = y;
return this;
}
};
module.exports = Velocity;

26
node_modules/phaser/plugins/impact/components/index.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace Phaser.Physics.Impact.Components
*/
module.exports = {
Acceleration: require('./Acceleration'),
BodyScale: require('./BodyScale'),
BodyType: require('./BodyType'),
Bounce: require('./Bounce'),
CheckAgainst: require('./CheckAgainst'),
Collides: require('./Collides'),
Debug: require('./Debug'),
Friction: require('./Friction'),
Gravity: require('./Gravity'),
Offset: require('./Offset'),
SetGameObject: require('./SetGameObject'),
Velocity: require('./Velocity')
};

View File

@ -0,0 +1,21 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Collide Event.
*
* This event is dispatched by an Impact Physics World instance if two bodies collide.
*
* Listen to it from a Scene using: `this.impact.world.on('collide', listener)`.
*
* @event Phaser.Physics.Impact.Events#COLLIDE
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} bodyA - The first body involved in the collision.
* @param {Phaser.Physics.Impact.Body} bodyB - The second body involved in the collision.
* @param {string} axis - The collision axis. Either `x` or `y`.
*/
module.exports = 'collide';

View File

@ -0,0 +1,17 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Pause Event.
*
* This event is dispatched by an Impact Physics World instance when it is paused.
*
* Listen to it from a Scene using: `this.impact.world.on('pause', listener)`.
*
* @event Phaser.Physics.Impact.Events#PAUSE
* @since 3.0.0
*/
module.exports = 'pause';

View File

@ -0,0 +1,17 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Resume Event.
*
* This event is dispatched by an Impact Physics World instance when it resumes from a paused state.
*
* Listen to it from a Scene using: `this.impact.world.on('resume', listener)`.
*
* @event Phaser.Physics.Impact.Events#RESUME
* @since 3.0.0
*/
module.exports = 'resume';

17
node_modules/phaser/plugins/impact/events/index.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace Phaser.Physics.Impact.Events
*/
module.exports = {
COLLIDE: require('./COLLIDE_EVENT'),
PAUSE: require('./PAUSE_EVENT'),
RESUME: require('./RESUME_EVENT')
};

36
node_modules/phaser/plugins/impact/index.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* An Impact.js compatible physics world, body and solver, for those who are used
* to the Impact way of defining and controlling physics bodies. Also works with
* the new Loader support for Weltmeister map data.
*
* World updated to run off the Phaser main loop.
* Body extended to support additional setter functions.
*
* To create the map data you'll need Weltmeister, which comes with Impact
* and can be purchased from http://impactjs.com
*
* My thanks to Dominic Szablewski for his permission to support Impact in Phaser.
*
* @namespace Phaser.Physics.Impact
*/
module.exports = {
Body: require('./Body'),
Events: require('./events'),
COLLIDES: require('./COLLIDES'),
CollisionMap: require('./CollisionMap'),
Factory: require('./Factory'),
Image: require('./ImpactImage'),
ImpactBody: require('./ImpactBody'),
ImpactPhysics: require('./ImpactPhysics'),
Sprite: require('./ImpactSprite'),
TYPE: require('./TYPE'),
World: require('./World')
};

View File

@ -0,0 +1,14 @@
/**
* @typedef {object} Phaser.Types.Physics.Impact.CollisionOptions
* @since 3.0.0
*
* @property {string} [slopeTileProperty=null] - Slope IDs can be stored on tiles directly
* using Impacts tileset editor. If a tile has a property with the given slopeTileProperty string
* name, the value of that property for the tile will be used for its slope mapping. E.g. a 45
* degree slope upward could be given a "slope" property with a value of 2.
* @property {object} [slopeMap=null] - A tile index to slope definition map.
* @property {integer} [defaultCollidingSlope=null] - If specified, the default slope ID to
* assign to a colliding tile. If not specified, the tile's index is used.
* @property {integer} [defaultNonCollidingSlope=0] - The default slope ID to assign to a
* non-colliding tile.
*/

View File

@ -0,0 +1,18 @@
/**
* @typedef {object} Phaser.Types.Physics.Impact.JSONImpactBody
* @since 3.0.0
*
* @property {string} name - [description]
* @property {Phaser.Types.Math.Vector2Like} size - [description]
* @property {Phaser.Types.Math.Vector2Like} pos - The entity's position in the game world.
* @property {Phaser.Types.Math.Vector2Like} vel - Current velocity in pixels per second.
* @property {Phaser.Types.Math.Vector2Like} accel - Current acceleration to be added to the entity's velocity per second. E.g. an entity with a `vel.x` of 0 and `accel.x` of 10 will have a `vel.x` of 100 ten seconds later.
* @property {Phaser.Types.Math.Vector2Like} friction - Deceleration to be subtracted from the entity's velocity per second. Only applies if `accel` is 0.
* @property {Phaser.Types.Math.Vector2Like} maxVel - The maximum velocity a body can move.
* @property {number} gravityFactor - [description]
* @property {number} bounciness - [description]
* @property {number} minBounceVelocity - [description]
* @property {Phaser.Physics.Impact.TYPE} type - [description]
* @property {Phaser.Physics.Impact.TYPE} checkAgainst - [description]
* @property {Phaser.Physics.Impact.COLLIDES} collides - [description]
*/

View File

@ -0,0 +1,30 @@
/**
* @typedef {object} Phaser.Types.Physics.Impact.WorldConfig
* @since 3.0.0
*
* @property {number} [gravity=0] - Sets {@link Phaser.Physics.Impact.World#gravity}
* @property {number} [cellSize=64] - The size of the cells used for the broadphase pass. Increase this value if you have lots of large objects in the world.
* @property {number} [timeScale=1] - A number that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed.
* @property {number} [maxStep=0.05] - [description]
* @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Impact.World#debug}.
* @property {number} [maxVelocity=100] - The maximum velocity a body can move.
* @property {boolean} [debugShowBody=true] - Whether the Body's boundary is drawn to the debug display.
* @property {boolean} [debugShowVelocity=true] - Whether the Body's velocity is drawn to the debug display.
* @property {number} [debugBodyColor=0xff00ff] - The color of this Body on the debug display.
* @property {number} [debugVelocityColor=0x00ff00] - The color of the Body's velocity on the debug display.
* @property {number} [maxVelocityX=maxVelocity] - Maximum X velocity objects can move.
* @property {number} [maxVelocityY=maxVelocity] - Maximum Y velocity objects can move.
* @property {number} [minBounceVelocity=40] - The minimum velocity an object can be moving at to be considered for bounce.
* @property {number} [gravityFactor=1] - Gravity multiplier. Set to 0 for no gravity.
* @property {number} [bounciness=0] - The default bounce, or restitution, of bodies in the world.
* @property {(object|boolean)} [setBounds] - Should the world have bounds enabled by default?
* @property {number} [setBounds.x=0] - The x coordinate of the world bounds.
* @property {number} [setBounds.y=0] - The y coordinate of the world bounds.
* @property {number} [setBounds.width] - The width of the world bounds.
* @property {number} [setBounds.height] - The height of the world bounds.
* @property {number} [setBounds.thickness=64] - The thickness of the walls of the world bounds.
* @property {boolean} [setBounds.left=true] - Should the left-side world bounds wall be created?
* @property {boolean} [setBounds.right=true] - Should the right-side world bounds wall be created?
* @property {boolean} [setBounds.top=true] - Should the top world bounds wall be created?
* @property {boolean} [setBounds.bottom=true] - Should the bottom world bounds wall be created?
*/

View File

@ -0,0 +1,16 @@
/**
* An object containing the 4 wall bodies that bound the physics world.
*
* @typedef {object} Phaser.Types.Physics.Impact.WorldDefaults
* @since 3.0.0
*
* @property {boolean} debugShowBody - Whether the Body's boundary is drawn to the debug display.
* @property {boolean} debugShowVelocity - Whether the Body's velocity is drawn to the debug display.
* @property {number} bodyDebugColor - The color of this Body on the debug display.
* @property {number} velocityDebugColor - The color of the Body's velocity on the debug display.
* @property {number} maxVelocityX - Maximum X velocity objects can move.
* @property {number} maxVelocityY - Maximum Y velocity objects can move.
* @property {number} minBounceVelocity - The minimum velocity an object can be moving at to be considered for bounce.
* @property {number} gravityFactor - Gravity multiplier. Set to 0 for no gravity.
* @property {number} bounciness - The default bounce, or restitution, of bodies in the world.
*/

View File

@ -0,0 +1,9 @@
/**
* @typedef {object} Phaser.Types.Physics.Impact.WorldWalls
* @since 3.0.0
*
* @property {?Phaser.Physics.Impact.Body} left - The left-side wall of the world bounds.
* @property {?Phaser.Physics.Impact.Body} right - The right-side wall of the world bounds.
* @property {?Phaser.Physics.Impact.Body} top - The top wall of the world bounds.
* @property {?Phaser.Physics.Impact.Body} bottom - The bottom wall of the world bounds.
*/

9
node_modules/phaser/plugins/impact/typedefs/index.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace Phaser.Types.Physics.Impact
*/