Commit 26380604 authored by lujinlei's avatar lujinlei

-a

parent 4db3d343
/**
* Created by rockyl on 2018/8/16.
*/
import Block from "./Block";
import {Background} from "./Background";
import Player from "./Player";
import {props} from "../props";
import {createSvga, getTextureByName, playSound} from "./utils";
import {Base} from "./Base";
import {GuideLayer} from "./GuideLayer";
import {GoldBag} from "./GoldBag";
import ObjectPool = engine.ObjectPool;
import { JumpTips } from "./JumpTips";
const PoolName: string = 'gold-bag';
ObjectPool.registerPool(PoolName, function () {
return new GoldBag();
}, function (item: GoldBag, data) {
item.reset(data);
});
export default class GameView extends engine.Container {
background: Background;
base: Base;
frontContainer: engine.Container;
blockContainer: engine.Container;
guideLayer: GuideLayer;
player: Player;
hitEffect: svga.Svga;
currentBlock: Block;
needHitTest;
index = -1;
blockComplete;
baseOffset: number;
scoreAddTipsContainer;
jumpTips
timer;
_pos;
_score;
_remainToShowGoldBag;
_blockShadow
_playerShadow
lastLandType;
scoreAddTips
_touchEnabled;
private _hasSetup;
constructor() {
super();
this.baseOffset = -props.baseOffset + props.playerOffset;
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
setup() {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
const {width, height} = this.stage;
const background = this.background = new Background();
this.addChild(background);
background.setup();
const frontContainer = this.frontContainer = new engine.Container();
frontContainer.x = width / 2;
this.addChild(frontContainer);
const guideLayer = this.guideLayer = new GuideLayer();
this.addChild(guideLayer);
const base = this.base = new Base();
frontContainer.addChild(base);
base.setup();
let blockShadow = this._blockShadow = new engine.Image(getTextureByName('方块阴影'));
blockShadow.anchorX = blockShadow.width / 2;
blockShadow.anchorY = blockShadow.height / 2;
blockShadow.x = -(blockShadow.width - base.width) / 2;
blockShadow.y =props.blockShadowOffset;
base.addChild(blockShadow);
const blockContainer = this.blockContainer = new engine.Container();
frontContainer.addChild(blockContainer);
const player = this.player = new Player();
frontContainer.addChild(player);
player.setup();
player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);
let playerShadow = this._playerShadow = new engine.Image(getTextureByName('玩家阴影'));
playerShadow.anchorX = playerShadow.width / 2;
playerShadow.anchorY = playerShadow.height / 2;
//playerShadow.x = frontContainer.width / 2;
playerShadow.x =this.player.x-playerShadow.width / 2;
let scoreAddTipsContainer = this.scoreAddTipsContainer = new engine.Container();
scoreAddTipsContainer.width=750;
scoreAddTipsContainer.anchorX = scoreAddTipsContainer.width / 2;
scoreAddTipsContainer.anchorY = scoreAddTipsContainer.height / 2;
let scoreAddTips = this.scoreAddTips = new engine.Label();
scoreAddTips.width=750;
scoreAddTips.fillColor = props.scoreAddFontColor;
scoreAddTips.textAlign=engine.TEXT_ALIGN.CENTER;
scoreAddTips.size = props.scoreAddFontSize;
scoreAddTips.alpha=0;
scoreAddTips.text = "+0";
scoreAddTips.x = this.player.x-scoreAddTips.width / 2;
scoreAddTipsContainer.addChild(scoreAddTips);
let jumpTips = this.jumpTips =new JumpTips()
jumpTips.setup()
jumpTips.x=props.jumpTipsOffset.x
frontContainer.addChild(playerShadow);
frontContainer.addChild(player);
frontContainer.addChild(scoreAddTipsContainer);
frontContainer.addChild(jumpTips);
ObjectPool.recycleObject(PoolName, ObjectPool.getObject(PoolName, {
y: 0,
remain: 0,
}));
this.hitEffect = createSvga('被撞烟雾', 'hitEffectAnchor');
this.pos = 0;
this.background.setup();
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
this.reset();
}
async setScoreText(score){
return new Promise(resolve => {
this.scoreAddTips.text=score
this.scoreAddTips.y=0
this.scoreAddTips.alpha=1
engine.Tween.get(this.scoreAddTips, null, null, true)
.to({y: -100,alpha:0}, 500, engine.Ease.cubicInOut)
.call(resolve);
})
}
async reset(revive = false) {
this.base.reset();
this.index = -1;
this._score = 0;
if (revive) {
} else {
this.pos = 0;
const blockContainer = this.blockContainer;
for (let i = 0, li = blockContainer.children.length; i < li; i++) {
const block = <Block>blockContainer.getChildAt(i);
block.playLeave();
}
}
for (let i = 0; i < props.initBlockCount; i++) {
this.addBlock(false);
}
for (let i = 0, li = this.goldBags.length; i < li; i++) {
const goldBag = this.goldBags[i];
this.frontContainer.removeChild(goldBag);
ObjectPool.recycleObject(PoolName, goldBag);
}
this.goldBags.splice(0);
//this.addGoldBag();
this.playZoom('in');
await this.resetPlayer(revive);
}
async resetPlayer(revive = false) {
this.player.reset(revive);
this.player.y = this.baseOffset - (this.index + 1) * props.blockHitHeight+props.blockBaseOffset;
}
async start(revive = false) {
this._playerShadow.y =this.player.y+props.playerShadowOffset;
this.scoreAddTipsContainer.y =this.player.y+props.scoreAddTipsOffset;
this.jumpTips.y =this.player.y+props.jumpTipsOffset.y;
//this.setScoreText("+100")
if (!revive) {
await this.player.playReady();
}
console.log("开始")
let guideFlagKey = 'jump-high-guide_' + props.guideFlagKey;
let guideFlag = localStorage.getItem(guideFlagKey);
if (!guideFlag) {
localStorage.setItem(guideFlagKey, '1');
await this.guideLayer.show('', {y: this.stage.height + this.player.y - 280});
}
this.lastLandType = 0;
this._remainToShowGoldBag = props.goldBagScoreMultiple - props.goldBagScoreSubtraction;
this._touchEnabled = true;
setTimeout(() => {
this.addBlock();
}, 100);
engine.globalEvent.dispatchEvent('jump-high-game-start');
}
pause() {
if (this.currentBlock) {
engine.Tween.pauseTweens(this.currentBlock);
}
engine.Tween.pauseTweens(this.player);
}
resume() {
if (this.currentBlock) {
engine.Tween.resumeTweens(this.currentBlock);
}
engine.Tween.resumeTweens(this.player);
}
async revive() {
this.blockContainer.getChildAt(this.index).visible = false;
this.index--;
await this.resetPlayer(true);
await this.playZoom('in');
this.start(true);
}
addBlock(animation = true) {
this.index++;
const blockContainer = this.blockContainer;
let block: Block;
if (blockContainer.children.length > this.index) {
block = <Block>blockContainer.getChildAt(this.index);
block.visible = true;
} else {
block = new Block();
blockContainer.addChild(block);
}
block.reset({
type: Math.floor(Math.random() * props.blockAssets.length),
});
block.y = this.baseOffset - this.index * props.blockHitHeight+props.blockBaseOffset;
this.blockComplete = false;
block.playEnter(this.index, animation).then(
(data) => {
this.blockComplete = true;
}
);
if (animation) {
this.needHitTest = true;
}
this.currentBlock = block;
/*if (this.blockCount > 0 && this.blockCount % props.goldBagMultiple === 0) {
this.addGoldBag();
}*/
}
private goldBags: GoldBag[] = [];
addGoldBag() {
let goldBag = <GoldBag>ObjectPool.getObject(PoolName, {
y: this.baseOffset - (this.blockCount + props.goldBagDistance + props.goldBagJumpSubtraction) * props.blockHitHeight,
remain: props.goldBagDistance,
});
this.frontContainer.addChild(goldBag);
this.goldBags.push(goldBag);
}
private nextToUpdateScore;
async playOpenGoldBag() {
for (let i = 0, li = this.goldBags.length; i < li; i++) {
const goldBag = this.goldBags[i];
goldBag.remain--;
if (goldBag.remain <= 0) {
this.goldBags.splice(i, 1);
i--;
li--;
this.nextToUpdateScore = true;
await goldBag.playOpen();
this.frontContainer.removeChild(goldBag);
ObjectPool.recycleObject(PoolName, goldBag);
}
}
}
onPlayerJumpOnTop() {
if (this.nextToUpdateScore) {
this.nextToUpdateScore = false;
this.scoreChange(4);
playSound('撞击钱袋音效');
}
}
get blockCount() {
return this.index - props.initBlockCount + 1;
}
get pos() {
return this._pos;
}
set pos(v) {
this._pos = v;
this.updatePos();
}
updatePos() {
this.frontContainer.y = this.stage.height + this._pos;
}
private onEnterFrame(event) {
if (this.needHitTest) {
if (this.currentBlock) {
const {x: bx, y: by, dir} = this.currentBlock;
const {x: px, y: py} = this.player;
const {blockHitWidth, blockHitHeight, playerWidth} = props;
let hitOn = false;
if (Math.abs(px - bx) < (blockHitWidth + playerWidth) / 2) {
this.player.changeBaseY(by - blockHitHeight);
if (py > by - blockHitHeight) {
hitOn = true;
}
}
if (hitOn) {
this.onHitOn(dir);
}
}
}
}
async onHitOn(dir) {
this._touchEnabled = false;
this.needHitTest = false;
clearInterval(this.timer);
this.currentBlock.playHit();
this._playerShadow.visible=false;
// this.currentBlock.stop();
this.playHitEffect(dir);
await this.player.hitAway(dir);
this.playZoom('out');
await this.player.parachute(dir);
engine.globalEvent.dispatchEvent('jump-high-game-end');
}
async jump() {
if (!this._touchEnabled) {
return;
}
this._playerShadow.visible=false;
this._touchEnabled = false;
this.playOpenGoldBag();
const result: any = await this.player.jump();
if (result) {
if (result.aboveBlock) {
let pos = Math.abs(this.currentBlock.x);
let type = 0;
if (pos > 0) {
type = pos > 0 && pos < props.scoreThreshold ? 2 : 3;
}
let lastLandType = this.lastLandType;
this.lastLandType = type;
if (type === 0) {
if (lastLandType !== type) { //如果前一次不是完美落地说明block没到正中间,所以没有重叠
type = 1;
}
}
if (type < 3) {
this.currentBlock.playEffect();
}
if(type===0){
this.currentBlock.playProFect();
}
if(type!=3){
this._playerShadow.visible=true;
}
this._playerShadow.y=this.player.y+props.playerShadowOffset;
this.player.playLand(type, this.currentBlock.dir);
this.currentBlock.stop();
this.scoreChange(type);
await this.playShake();
await new Promise(resolve => {
engine.Tween.get(this, null, null, true)
.to({pos: props.blockHitHeight * this.index}, 300, engine.Ease.cubicOut)
.call(resolve)
});
this.addBlock();
// this.frontContainer.addChild(this._playerShadow);
//this._playerShadow.y=this.player.y+props.playerShadowOffset;
}
this._touchEnabled = true;
}
}
private scoreChange(type) {
let scoreAdd = props.scoreWeights[type];
this._score += scoreAdd;
this._remainToShowGoldBag -= scoreAdd;
let score = this._score;
engine.globalEvent.dispatchEvent('jump-high-score', {
type,
score,
scoreAdd,
});
this.scoreAddTipsContainer.y =this.player.y+props.scoreAddTipsOffset;
this.setScoreText(`+${scoreAdd}`)
this.jumpTips.y =this.player.y+props.jumpTipsOffset.y;
this.jumpTips.show()
console.log(score, this._remainToShowGoldBag);
if (this._remainToShowGoldBag <= 0) {
this._remainToShowGoldBag += props.goldBagScoreMultiple;
this.addGoldBag();
console.log('addGoldBag');
}
}
playHitEffect(dir) {
let hitEffect = this.hitEffect;
hitEffect.scaleX = dir;
hitEffect.y = this.player.y - props.hitEffectAnchor.y;
hitEffect.play(true, false);
hitEffect.once(engine.Event.END_FRAME, function () {
this.frontContainer.removeChild(hitEffect);
}, this);
this.frontContainer.addChild(hitEffect);
}
playZoom(type: 'in' | 'out', duration = 700) {
this.background.playZoom(type, duration);
let count = this.stage.height / props.blockHitHeight;
return new Promise(resolve => {
this.frontContainer.anchorY = -props.blockHitHeight * (this.index + count * 1.3) + props.baseOffset;
let scale = type === 'in' ? 1 : /*Math.max(*/Math.min((this.stage.height / props.blockHitHeight / (this.index + count)), props.maxScale)/*, props.minScale)*/;
console.log(scale);
engine.Tween.get(this.frontContainer, null, null, true)
.to({scaleX: scale, scaleY: scale}, duration, engine.Ease.cubicInOut)
.call(resolve);
})
}
playShake(){
const {x, y} = this.frontContainer;
return new Promise(resolve => {
const shakeOffset = 7;
const duration = 30;
engine.Tween.get(this.frontContainer, null, null, true)
.to({x: x, y: y - shakeOffset}, duration)
.to({x: x, y: y + shakeOffset}, duration)
.to({x: x + shakeOffset, y: y}, duration)
.to({x: x - shakeOffset, y: y}, duration)
.to({x: x, y: y}, duration)
.call(resolve)
})
}
}
......@@ -46,6 +46,11 @@
"alias": "奖品Y轴偏移量(底框背景有透明)",
"type": "number",
"default": -20
},
"layer": {
"alias": "中奖标志是否在最下层",
"type": "boolean",
"default": false
}
},
"assets": [
......@@ -93,5 +98,5 @@
}
},
"id": "jiugong-turntable",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['jiugong-turntable'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tvar Turntable = (function (_super) {\r\n\t tslib.__extends(Turntable, _super);\r\n\t function Turntable(res) {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._vertical_Y = props.vertical || 20;\r\n\t _this._horizontal_X = props.horizontal || 20;\r\n\t _this._prizeIndex = 0;\r\n\t _this._boxArray = [];\r\n\t _this._boxIndex = 0;\r\n\t _this.tweenTime = props.tweenTime || 200;\r\n\t _this.slowTweenTime = props.slowTweenTime || 200;\r\n\t _this.circleNumber = 0;\r\n\t _this.turntableOrder = [1, 2, 3, 5, 8, 7, 6, 4];\r\n\t _this.recordID = -1;\r\n\t _this.boxPrizeIndex = -1;\r\n\t _this.slowDown = false;\r\n\t _this.isStop = false;\r\n\t _this.initTurntable(res);\r\n\t _this.setNodeOrder();\r\n\t return _this;\r\n\t }\r\n\t Turntable.prototype.initTurntable = function (res) {\r\n\t var turnTableNode = this._turnTableNode = new engine.Container();\r\n\t this.addChild(turnTableNode);\r\n\t for (var index_Y = 0; index_Y < 3; index_Y++) {\r\n\t var _loop_1 = function (index_X) {\r\n\t if (index_X == 1 && index_Y == 1)\r\n\t return \"continue\";\r\n\t var tmpNode = new engine.Container();\r\n\t var unchecked = this_1.getImage('unchecked', 1);\r\n\t var checked = this_1.getImage('checked', 0);\r\n\t tmpNode.width = Math.max(unchecked.width, checked.width);\r\n\t this_1._singleNodeWidth = this_1._singleNodeWidth ? this_1._singleNodeWidth : tmpNode.width;\r\n\t tmpNode.height = Math.max(unchecked.height, checked.height);\r\n\t tmpNode.x = index_X * (tmpNode.width + this_1._horizontal_X);\r\n\t tmpNode.y = index_Y * (tmpNode.height + this_1._vertical_Y);\r\n\t tmpNode.addChild(unchecked);\r\n\t tmpNode.addChild(checked);\r\n\t turnTableNode.addChild(tmpNode);\r\n\t var tmpTexture = engine.Texture.fromImage(res[this_1._prizeIndex].img, undefined);\r\n\t var prizeID = res[this_1._prizeIndex].id;\r\n\t tmpTexture.addEventListener('loaded', function () {\r\n\t var prize = new engine.Sprite(tmpTexture);\r\n\t prize.width = props.icon_width;\r\n\t prize.height = props.icon_height;\r\n\t prize.x = (tmpNode.width - prize.width) / 2 + props.icon_X;\r\n\t prize.y = (tmpNode.height - prize.height) / 2 + props.icon_Y;\r\n\t tmpNode.prizeID = prizeID;\r\n\t tmpNode.addChild(prize);\r\n\t }, this_1);\r\n\t this_1._prizeIndex++;\r\n\t this_1._boxArray.push(tmpNode);\r\n\t };\r\n\t var this_1 = this;\r\n\t for (var index_X = 0; index_X < 3; index_X++) {\r\n\t _loop_1(index_X);\r\n\t }\r\n\t }\r\n\t turnTableNode.x = (750 - (this._singleNodeWidth * 3 + this._horizontal_X * 2)) / 2;\r\n\t };\r\n\t Turntable.prototype.setNodeOrder = function () {\r\n\t var tmpNodeArray = [];\r\n\t for (var index = 0; index < this.turntableOrder.length; index++) {\r\n\t var order = this.turntableOrder[index];\r\n\t tmpNodeArray.push(this._boxArray[order - 1]);\r\n\t }\r\n\t this._boxArray = tmpNodeArray;\r\n\t };\r\n\t Turntable.prototype.getImage = function (resName, alpha) {\r\n\t var tmpImage = new engine.Sprite(getTextureByName(resName));\r\n\t tmpImage.x = 0;\r\n\t tmpImage.y = 0;\r\n\t tmpImage.alpha = alpha;\r\n\t tmpImage.name = resName;\r\n\t return tmpImage;\r\n\t };\r\n\t Turntable.prototype.startDraw = function () {\r\n\t var _this = this;\r\n\t var tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');\r\n\t if (this.isStop) {\r\n\t engine.Tween.removeTweens(tmpCheckNode);\r\n\t return;\r\n\t }\r\n\t if (this.slowDown) {\r\n\t if (this._boxIndex != this.getNodeIndexOFprize()) {\r\n\t this.tweenTime += this.slowTweenTime;\r\n\t }\r\n\t else {\r\n\t this.isStop = true;\r\n\t this.twinkle(tmpCheckNode);\r\n\t }\r\n\t }\r\n\t engine.Tween.get(tmpCheckNode)\r\n\t .to({ alpha: 1 }, this.tweenTime / 2)\r\n\t .to({ alpha: 0 }, this.tweenTime / 2)\r\n\t .call(function () {\r\n\t if (_this.circleNumber >= props.circleNumber && _this.getSlowStart() == _this._boxIndex) {\r\n\t _this.slowDown = true;\r\n\t }\r\n\t _this._boxIndex++;\r\n\t if (_this._boxIndex >= _this._boxArray.length) {\r\n\t _this._boxIndex = 0;\r\n\t _this.circleNumber++;\r\n\t }\r\n\t _this.startDraw();\r\n\t });\r\n\t };\r\n\t Turntable.prototype.getSlowStart = function () {\r\n\t if (this.recordID < 0)\r\n\t return -1;\r\n\t var tmpIndex = this.getNodeIndexOFprize();\r\n\t if (tmpIndex < 4) {\r\n\t return tmpIndex + 4;\r\n\t }\r\n\t else {\r\n\t return tmpIndex - 4;\r\n\t }\r\n\t };\r\n\t Turntable.prototype.getNodeIndexOFprize = function () {\r\n\t if (this.recordID < 0)\r\n\t return -1;\r\n\t for (var index = 0; index < this._boxArray.length; index++) {\r\n\t var element = this._boxArray[index];\r\n\t if (element.prizeID === this.recordID) {\r\n\t return index;\r\n\t }\r\n\t }\r\n\t return -1;\r\n\t };\r\n\t Turntable.prototype.twinkle = function (tmpNode) {\r\n\t engine.Tween.removeTweens(tmpNode);\r\n\t var twinkleTime = 1;\r\n\t engine.Tween.get(tmpNode, { loop: true })\r\n\t .to({ alpha: 0 }, 30)\r\n\t .to({ alpha: 1 }, 30)\r\n\t .call(function () {\r\n\t if (twinkleTime > 5) {\r\n\t engine.Tween.removeTweens(tmpNode);\r\n\t engine.globalEvent.dispatchEvent('jiugong-turntable-over');\r\n\t return;\r\n\t }\r\n\t else {\r\n\t twinkleTime++;\r\n\t }\r\n\t });\r\n\t };\r\n\t Turntable.prototype.setRecordID = function (prizeID) {\r\n\t this.recordID = prizeID;\r\n\t };\r\n\t Turntable.prototype.reset = function () {\r\n\t engine.Tween.removeAllTweens();\r\n\t this._boxIndex = 0;\r\n\t this.tweenTime = props.tweenTime || 200;\r\n\t this.slowTweenTime = props.slowTweenTime || 200;\r\n\t this.circleNumber = 0;\r\n\t this.recordID = -1;\r\n\t this.boxPrizeIndex = -1;\r\n\t this.slowDown = false;\r\n\t this.isStop = false;\r\n\t for (var index = 0; index < this._boxArray.length; index++) {\r\n\t var element = this._boxArray[index];\r\n\t element.getChildByName('checked').alpha = 0;\r\n\t }\r\n\t };\r\n\t return Turntable;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=turntable.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t return _super.call(this) || this;\r\n\t }\r\n\t GameView.prototype.setup = function (res) {\r\n\t if (this._hasSetup) {\r\n\t return;\r\n\t }\r\n\t this._hasSetup = true;\r\n\t var turntable = this._turntable = new Turntable(res);\r\n\t this.addChild(turntable);\r\n\t };\r\n\t GameView.prototype.startDraw = function () {\r\n\t this._turntable.startDraw();\r\n\t };\r\n\t GameView.prototype.setRecordID = function (prizeID) {\r\n\t this._turntable.setRecordID(prizeID);\r\n\t };\r\n\t GameView.prototype.reset = function () {\r\n\t this._turntable.reset();\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-init', _this.init, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-winPrize', _this.winPrize, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-reset', _this.reset, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-abnormal', _this.reset, _this);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.init = function (event) {\r\n\t var gameView = this._gameView = new GameView();\r\n\t this.addChild(gameView);\r\n\t console.log('奖品图', event.data.resources);\r\n\t this._gameView.setup(event.data.resources);\r\n\t };\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t this._gameView.startDraw();\r\n\t };\r\n\t GameWrapper.prototype.winPrize = function (event) {\r\n\t this._gameView.setRecordID(event.data.prizeID);\r\n\t };\r\n\t GameWrapper.prototype.reset = function () {\r\n\t this._gameView.reset();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['jiugong-turntable'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tvar Turntable = (function (_super) {\r\n\t tslib.__extends(Turntable, _super);\r\n\t function Turntable(res) {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._vertical_Y = props.vertical || 20;\r\n\t _this._horizontal_X = props.horizontal || 20;\r\n\t _this._prizeIndex = 0;\r\n\t _this._boxArray = [];\r\n\t _this._boxIndex = 0;\r\n\t _this.tweenTime = props.tweenTime || 200;\r\n\t _this.slowTweenTime = props.slowTweenTime || 200;\r\n\t _this.circleNumber = 0;\r\n\t _this.turntableOrder = [1, 2, 3, 5, 8, 7, 6, 4];\r\n\t _this.recordID = -1;\r\n\t _this.boxPrizeIndex = -1;\r\n\t _this.slowDown = false;\r\n\t _this.isStop = false;\r\n\t _this.initTurntable(res);\r\n\t _this.setNodeOrder();\r\n\t return _this;\r\n\t }\r\n\t Turntable.prototype.initTurntable = function (res) {\r\n\t var turnTableNode = this._turnTableNode = new engine.Container();\r\n\t this.addChild(turnTableNode);\r\n\t for (var index_Y = 0; index_Y < 3; index_Y++) {\r\n\t for (var index_X = 0; index_X < 3; index_X++) {\r\n\t if (index_X == 1 && index_Y == 1)\r\n\t continue;\r\n\t var tmpNode = new engine.Container();\r\n\t var unchecked = this.getImage('unchecked', 1);\r\n\t var checked = this.getImage('checked', 0);\r\n\t tmpNode.width = Math.max(unchecked.width, checked.width);\r\n\t this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;\r\n\t tmpNode.height = Math.max(unchecked.height, checked.height);\r\n\t tmpNode.x = index_X * (tmpNode.width + this._horizontal_X);\r\n\t tmpNode.y = index_Y * (tmpNode.height + this._vertical_Y);\r\n\t checked.x = (tmpNode.width - checked.width) / 2;\r\n\t checked.y = (tmpNode.height - checked.height) / 2;\r\n\t unchecked.x = (tmpNode.width - unchecked.width) / 2;\r\n\t unchecked.y = (tmpNode.height - unchecked.height) / 2;\r\n\t if (props.layer) {\r\n\t tmpNode.addChild(checked);\r\n\t tmpNode.addChild(unchecked);\r\n\t }\r\n\t else {\r\n\t tmpNode.addChild(unchecked);\r\n\t tmpNode.addChild(checked);\r\n\t }\r\n\t turnTableNode.addChild(tmpNode);\r\n\t var prize = new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img));\r\n\t var prizeID = res[this._prizeIndex].id;\r\n\t prize.width = props.icon_width;\r\n\t prize.height = props.icon_height;\r\n\t prize.x = (tmpNode.width - prize.width) / 2 + props.icon_X;\r\n\t prize.y = (tmpNode.height - prize.height) / 2 + props.icon_Y;\r\n\t tmpNode.prizeID = prizeID;\r\n\t tmpNode.addChild(prize);\r\n\t this._prizeIndex++;\r\n\t this._boxArray.push(tmpNode);\r\n\t }\r\n\t }\r\n\t turnTableNode.x = (750 - (this._singleNodeWidth * 3 + this._horizontal_X * 2)) / 2;\r\n\t };\r\n\t Turntable.prototype.setNodeOrder = function () {\r\n\t var tmpNodeArray = [];\r\n\t for (var index = 0; index < this.turntableOrder.length; index++) {\r\n\t var order = this.turntableOrder[index];\r\n\t tmpNodeArray.push(this._boxArray[order - 1]);\r\n\t }\r\n\t this._boxArray = tmpNodeArray;\r\n\t };\r\n\t Turntable.prototype.getImage = function (resName, alpha) {\r\n\t var tmpImage = new engine.Sprite(getTextureByName(resName));\r\n\t tmpImage.x = 0;\r\n\t tmpImage.y = 0;\r\n\t tmpImage.alpha = alpha;\r\n\t tmpImage.name = resName;\r\n\t return tmpImage;\r\n\t };\r\n\t Turntable.prototype.startDraw = function () {\r\n\t var _this = this;\r\n\t var tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');\r\n\t if (this.isStop) {\r\n\t engine.Tween.removeTweens(tmpCheckNode);\r\n\t return;\r\n\t }\r\n\t if (this.slowDown) {\r\n\t if (this._boxIndex != this.getNodeIndexOFprize()) {\r\n\t this.tweenTime += this.slowTweenTime;\r\n\t }\r\n\t else {\r\n\t this.isStop = true;\r\n\t this.twinkle(tmpCheckNode);\r\n\t }\r\n\t }\r\n\t engine.Tween.get(tmpCheckNode)\r\n\t .to({ alpha: 1 }, this.tweenTime / 2)\r\n\t .to({ alpha: 0 }, this.tweenTime / 2)\r\n\t .call(function () {\r\n\t if (_this.circleNumber >= props.circleNumber && _this.getSlowStart() == _this._boxIndex) {\r\n\t _this.slowDown = true;\r\n\t }\r\n\t _this._boxIndex++;\r\n\t if (_this._boxIndex >= _this._boxArray.length) {\r\n\t _this._boxIndex = 0;\r\n\t _this.circleNumber++;\r\n\t }\r\n\t _this.startDraw();\r\n\t });\r\n\t };\r\n\t Turntable.prototype.getSlowStart = function () {\r\n\t if (this.recordID < 0)\r\n\t return -1;\r\n\t var tmpIndex = this.getNodeIndexOFprize();\r\n\t if (tmpIndex < 4) {\r\n\t return tmpIndex + 4;\r\n\t }\r\n\t else {\r\n\t return tmpIndex - 4;\r\n\t }\r\n\t };\r\n\t Turntable.prototype.getNodeIndexOFprize = function () {\r\n\t if (this.recordID < 0)\r\n\t return -1;\r\n\t for (var index = 0; index < this._boxArray.length; index++) {\r\n\t var element = this._boxArray[index];\r\n\t if (element.prizeID === this.recordID) {\r\n\t return index;\r\n\t }\r\n\t }\r\n\t return -1;\r\n\t };\r\n\t Turntable.prototype.twinkle = function (tmpNode) {\r\n\t engine.Tween.removeTweens(tmpNode);\r\n\t var twinkleTime = 1;\r\n\t engine.Tween.get(tmpNode, { loop: true })\r\n\t .to({ alpha: 0 }, 30)\r\n\t .to({ alpha: 1 }, 30)\r\n\t .call(function () {\r\n\t if (twinkleTime > 5) {\r\n\t engine.Tween.removeTweens(tmpNode);\r\n\t engine.globalEvent.dispatchEvent('jiugong-turntable-over');\r\n\t return;\r\n\t }\r\n\t else {\r\n\t twinkleTime++;\r\n\t }\r\n\t });\r\n\t };\r\n\t Turntable.prototype.setRecordID = function (prizeID) {\r\n\t this.recordID = prizeID;\r\n\t };\r\n\t Turntable.prototype.reset = function () {\r\n\t engine.Tween.removeAllTweens();\r\n\t this._boxIndex = 0;\r\n\t this.tweenTime = props.tweenTime || 200;\r\n\t this.slowTweenTime = props.slowTweenTime || 200;\r\n\t this.circleNumber = 0;\r\n\t this.recordID = -1;\r\n\t this.boxPrizeIndex = -1;\r\n\t this.slowDown = false;\r\n\t this.isStop = false;\r\n\t for (var index = 0; index < this._boxArray.length; index++) {\r\n\t var element = this._boxArray[index];\r\n\t element.getChildByName('checked').alpha = 0;\r\n\t }\r\n\t };\r\n\t return Turntable;\r\n\t}(engine.Container));\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t return _super.call(this) || this;\r\n\t }\r\n\t GameView.prototype.setup = function (res) {\r\n\t if (this._hasSetup) {\r\n\t return;\r\n\t }\r\n\t this._hasSetup = true;\r\n\t var turntable = this._turntable = new Turntable(res);\r\n\t this.addChild(turntable);\r\n\t };\r\n\t GameView.prototype.startDraw = function () {\r\n\t this._turntable.startDraw();\r\n\t };\r\n\t GameView.prototype.setRecordID = function (prizeID) {\r\n\t this._turntable.setRecordID(prizeID);\r\n\t };\r\n\t GameView.prototype.reset = function () {\r\n\t this._turntable.reset();\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-init', _this.init, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-winPrize', _this.winPrize, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-reset', _this.reset, _this);\r\n\t engine.globalEvent.addEventListener('jiugong-turntable-abnormal', _this.reset, _this);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.init = function (event) {\r\n\t var gameView = this._gameView = new GameView();\r\n\t this.addChild(gameView);\r\n\t console.log('奖品图', event.data.resources);\r\n\t this._gameView.setup(event.data.resources);\r\n\t };\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t this._gameView.startDraw();\r\n\t };\r\n\t GameWrapper.prototype.winPrize = function (event) {\r\n\t this._gameView.setRecordID(event.data.prizeID);\r\n\t };\r\n\t GameWrapper.prototype.reset = function () {\r\n\t this._gameView.reset();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
{
"name": "海底",
"desc": "海底模块",
"props": {
"level_1": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "5,1,9,60"
},
"level_2": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "10,2,14,80"
},
"level_3": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "15,3,19,110"
}
},
"assets": [
{
"name": "灯",
"url": "//yun.duiba.com.cn/aurora/assets/c0f7c4b4d650da31d9b23a9006bd0e58aaca95ad.png",
"uuid": "55a9e50c-c7bc-4bb1-8624-fdd7edb66f93",
"ext": ".png"
},
{
"name": "机子",
"url": "//yun.duiba.com.cn/aurora/assets/e07baecf71ed8ecd9429fbbebb064b3cd50658df.png",
"uuid": "dee8564f-e17a-4a78-87f7-bebeb83fd235",
"ext": ".png"
},
{
"name": "篮筐",
"url": "//yun.duiba.com.cn/aurora/assets/b6977968fa3cdefbe181adbe2a381df9e8402af5.png",
"uuid": "8b49fe91-f6b7-414c-81d1-a9689e473b29",
"ext": ".png"
},
{
"name": "右按钮",
"url": "//yun.duiba.com.cn/aurora/assets/e3b4d4c0e557529b8c383639acce3d2ac01bf9b3.png",
"uuid": "1b1acf4a-a1fb-427e-a8cd-48214f89ac46",
"ext": ".png"
},
{
"name": "左按钮",
"url": "//yun.duiba.com.cn/aurora/assets/4bc49a4477adbfcda25d348473504d4384ad3dd2.png",
"uuid": "d828d269-68e7-4801-a3b2-e4bb1c38592b",
"ext": ".png"
},
{
"name": "basket_bottom",
"url": "//yun.duiba.com.cn/aurora/assets/8003d15eda09a24c38fdf32d2b774fe9a16fcd81.png",
"uuid": "1bccf897-d37e-4dc7-814f-6b8caf27a03b",
"ext": ".png"
},
{
"name": "basket_top",
"url": "//yun.duiba.com.cn/aurora/assets/55596516d4d44685fe07be1fef2105c8186edcd7.png",
"uuid": "826c7811-2767-469f-bf6b-908f3d404a1d",
"ext": ".png"
},
{
"name": "coin_json",
"url": "//yun.duiba.com.cn/aurora/assets/4170985efa5fea693a27734d14250e3b5a49962b.json",
"uuid": "9a0265ec-d9e7-4d47-83c7-d775115df38e",
"ext": ".json"
},
{
"name": "coin",
"url": "//yun.duiba.com.cn/aurora/assets/d6a361f27ebb81dd444ac40e428dffd06a0aa4e3.png",
"uuid": "abe242de-cf82-46ec-8a40-fcd51b0ca13d",
"ext": ".png"
},
{
"name": "boom_json",
"url": "//yun.duiba.com.cn/aurora/assets/4da36db75239d5c4f7b89d5805429ad64f7a05d5.json",
"uuid": "b0f0ae6d-b7c7-4a35-8c5a-7c4249f011db",
"ext": ".json"
},
{
"name": "boom",
"url": "//yun.duiba.com.cn/aurora/assets/b4579f262046e16245df9982ef31c57e433b0ba7.png",
"uuid": "129aa5f7-e308-40ce-ba9b-3fdc733d4ecb",
"ext": ".png"
},
{
"name": "candy_json",
"url": "//yun.duiba.com.cn/aurora/assets/2512911b42641f570be929e686a17fa91582f411.json",
"uuid": "0f21fae8-08cb-4c41-bab5-993d98fd7070",
"ext": ".json"
},
{
"name": "candy",
"url": "//yun.duiba.com.cn/aurora/assets/a91c39b45b0aa042b112ac477bc5ab80f00e8816.png",
"uuid": "67c0717c-9b89-4b56-a61a-91c8c7a99e4c",
"ext": ".png"
},
{
"name": "egg_json",
"url": "//yun.duiba.com.cn/aurora/assets/d789e4167a136e889729dd97d4f8728517226c8a.json",
"uuid": "75ac3c28-f8a8-4609-b908-bb386a6ace2c",
"ext": ".json"
},
{
"name": "egg",
"url": "//yun.duiba.com.cn/aurora/assets/a9156427b733d959c473dc0e37c929f103f77174.png",
"uuid": "e2f61593-e082-405a-bf19-79c78e2c067a",
"ext": ".png"
},
{
"name": "fail_json",
"url": "//yun.duiba.com.cn/aurora/assets/be22c261821766b019138176658ea3857f7dc5c8.json",
"uuid": "96f6c48f-f01e-4d13-a058-0c082edc38fa",
"ext": ".json"
},
{
"name": "fail",
"url": "//yun.duiba.com.cn/aurora/assets/d5fff67caae5a86bc29969d1676b76b253eda701.png",
"uuid": "9473b143-bd58-4450-b7b9-cb18911f3ba3",
"ext": ".png"
},
{
"name": "gift_json",
"url": "//yun.duiba.com.cn/aurora/assets/9165343ca17a457133d227956c217e0a821a0cf3.json",
"uuid": "48347b92-7c99-4bf5-a67a-d535b4785b20",
"ext": ".json"
},
{
"name": "gift",
"url": "//yun.duiba.com.cn/aurora/assets/e47e2ebdbb9cc8fe1f9f0e941af3cbe92b08162b.png",
"uuid": "a3667116-4218-4b5f-a6ec-c1529ddb71cf",
"ext": ".png"
},
{
"name": "success_json",
"url": "//yun.duiba.com.cn/aurora/assets/a010032b62ec260b6ad0844b1eff530847954e10.json",
"uuid": "3a70f25d-03c0-483c-847b-88b6e4ed5dcf",
"ext": ".json"
},
{
"name": "success",
"url": "//yun.duiba.com.cn/aurora/assets/e6c6b8fff68fcbb2e30cbb50f5690d52be4d8c99.png",
"uuid": "0ec792be-6fcc-4c5b-bf8a-0e8406a5c34b",
"ext": ".png"
},
{
"name": "玻璃",
"url": "//yun.duiba.com.cn/aurora/assets/90edb55a1c5fb4b7baf689144b7c1f3508ecb7ff.png",
"uuid": "92d1a3d4-256b-467b-a9a2-4820c2c2c718",
"ext": ".png"
},
{
"name": "contPng",
"url": "//yun.duiba.com.cn/aurora/assets/a19ba2de0b7f11830700ed8122585a95ebef1757.png",
"uuid": "84e4f5dc-149d-4ace-a02c-8b2aaf6819b1",
"ext": ".png"
},
{
"name": "bubble",
"url": "//yun.duiba.com.cn/aurora/assets/f30c3b92eac79cdae679c48436eb4ef92b97ff6c.png",
"uuid": "28c4a8e4-9ff8-4962-842a-dd90d04a958c",
"ext": ".png"
},
{
"name": "倒计时",
"url": "//yun.duiba.com.cn/aurora/assets/a9b9490cd7ef4974c6ca5c34b3b4e4a2fdd1f8ca.png",
"uuid": "893a1116-1ddb-49e5-89bd-8f523ad56f81",
"ext": ".png"
},
{
"name": "awesome",
"url": "//yun.duiba.com.cn/aurora/assets/89de7d7785bb70a95b139fe444b90fbe5e802c80.png",
"uuid": "b7f19c22-22ea-419e-99d0-3b6959b59f88",
"ext": ".png"
},
{
"name": "cool",
"url": "//yun.duiba.com.cn/aurora/assets/5e1ce8651de0f67cf98220238db00ef6d46b1aeb.png",
"uuid": "585b11a0-8d5d-4265-8871-96d98c0a65cf",
"ext": ".png"
},
{
"name": "good",
"url": "//yun.duiba.com.cn/aurora/assets/49a5633dc8429fac1d59c7a55ba15f3386cdddc7.png",
"uuid": "bdbc7ff6-5b64-4878-bcb2-9b83a498206b",
"ext": ".png"
},
{
"name": "great",
"url": "//yun.duiba.com.cn/aurora/assets/ad47ea03239e36e09806a74cb4bd475a42edb00a.png",
"uuid": "bd1da4bb-1dbf-4b80-a6ea-eb4e50cf65aa",
"ext": ".png"
},
{
"name": "perfect",
"url": "//yun.duiba.com.cn/aurora/assets/b560b07e694a95ef6b40b6702cdfc8853eb73ec3.png",
"uuid": "63ce23dc-be8b-4222-a0a6-0fd5a27c0af6",
"ext": ".png"
},
{
"name": "unbelievable",
"url": "//yun.duiba.com.cn/aurora/assets/a436eb46836e45d8043721107e5f49a58367ac3f.png",
"uuid": "6f352da0-0522-4530-b064-9132b591b341",
"ext": ".png"
},
{
"name": "进度",
"url": "//yun.duiba.com.cn/aurora/assets/0a7f33bba28a882ea1ec436b73ecafbaed4542d5.png",
"uuid": "647dc81b-443d-446b-bcf6-8b95b8511470",
"ext": ".png"
},
{
"name": "点亮",
"url": "//yun.duiba.com.cn/aurora/assets/3e8ca3a3f044df467c76a7a0d5ebbd75520bda8e.png",
"uuid": "9808f74f-a474-4c10-a8c6-bb51663d1a8e",
"ext": ".png"
},
{
"name": "lv1",
"url": "//yun.duiba.com.cn/aurora/assets/76db0c80d7b8051d7de44e87cac763ce607d2c7a.png",
"uuid": "a9a91d6c-06b0-4fdf-bcb8-77abe9bc7d83",
"ext": ".png"
},
{
"name": "lv2",
"url": "//yun.duiba.com.cn/aurora/assets/c5f1c83c683c5703432cc615b2c206aee1c675e0.png",
"uuid": "de8b2a81-fb38-4128-b536-9ef03eb013df",
"ext": ".png"
},
{
"name": "lv3",
"url": "//yun.duiba.com.cn/aurora/assets/beed55701a29bfa9b49dca1d5a059b34d7702496.png",
"uuid": "710eed46-f371-4d85-9858-ad048c86fc74",
"ext": ".png"
},
{
"name": "lv_common",
"url": "//yun.duiba.com.cn/aurora/assets/0afe14fc04beb3c66ce9080502c7c381f4b658ea.png",
"uuid": "e53e80fd-80a6-4385-b296-a3f097eeb51a",
"ext": ".png"
},
{
"name": "dot",
"url": "//yun.duiba.com.cn/aurora/assets/b39a88200f27f65e9d8d3f2a98a671de979f3027.png",
"uuid": "b8acc117-7d3c-4bcb-aff9-b5f42b901edf",
"ext": ".png"
}
],
"events": {
"in": {
"seabed-game-start": {
"alias": "开始",
"data": {}
},
"seabed-game-startNextLevel": {
"alias": "开始下一关",
"data": {
"level": "关卡"
}
},
"seabed-game-revive": {
"alias": "复活",
"data": {}
},
"seabed-game-themeChange": {
"alias": "更换主题",
"data": {
"gameCountdownImage": "游戏页倒计时",
"leftButtonImage": "左按钮",
"rightButtonImage": "右按钮"
}
}
},
"out": {
"seabed-game-fail": {
"alias": "游戏结束",
"data": {
"score": "当前分数",
"level": "当前关卡"
}
},
"seabed-game-success": {
"alias": "游戏成功",
"data": {
"score": "当前分数",
"level": "当前关卡"
}
}
}
},
"id": "seabed-game",
"code": "(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n typeof define === 'function' && define.amd ? define(['tslib'], factory) :\n (global = global || self, global['seabed-game'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n var LabelType;\r\n (function (LabelType) {\r\n LabelType[\"boom\"] = \"boom\";\r\n LabelType[\"candy\"] = \"candy\";\r\n LabelType[\"coin\"] = \"coin\";\r\n LabelType[\"gift\"] = \"gift\";\r\n LabelType[\"egg\"] = \"egg\";\r\n })(LabelType || (LabelType = {}));\r\n var LabelType$1 = LabelType;\r\n //# sourceMappingURL=LabelType.js.map\n\n var props = {};\r\n function prepareProps() {\r\n var metaProps = getProps();\r\n engine.injectProp(props, metaProps);\r\n }\r\n function injectProps(p) {\r\n engine.injectProp(props, p);\r\n }\r\n //# sourceMappingURL=props.js.map\n\n var levels;\r\n var setlevelData = function () {\r\n levels = {\r\n '1': { max: props.level_1[0], items: [[LabelType$1.boom, props.level_1[1]], [LabelType$1.coin, props.level_1[2]]], time: props.level_1[3] },\r\n '2': { max: props.level_2[0], items: [[LabelType$1.boom, props.level_2[1]], [LabelType$1.coin, props.level_2[2]]], time: props.level_2[3] },\r\n '3': { max: props.level_3[0], items: [[LabelType$1.boom, props.level_3[1]], [LabelType$1.coin, props.level_3[2]]], time: props.level_3[3] },\r\n };\r\n };\r\n var touchEnabled = false;\r\n var getTouchEnabled = function () {\r\n return touchEnabled;\r\n };\r\n var setTouchEnabled = function (b) {\r\n touchEnabled = b;\r\n };\r\n //# sourceMappingURL=GoldData.js.map\n\n function getTexture(uuid) {\r\n return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n }\r\n function getTextureByName(name) {\r\n return getTexture(engine.getAssetByName(name).uuid);\r\n }\r\n //# sourceMappingURL=utils.js.map\n\n var Tool = (function () {\r\n function Tool() {\r\n }\r\n Tool.getLabel = function (txt, size, color, bold, align, x, y) {\r\n if (color === void 0) { color = \"#ffffff\"; }\r\n if (bold === void 0) { bold = false; }\r\n if (align === void 0) { align = engine.TEXT_ALIGN.LEFT; }\r\n if (x === void 0) { x = 0; }\r\n if (y === void 0) { y = 0; }\r\n var label = new engine.Label();\r\n label.fillColor = color;\r\n label.bold = bold;\r\n label.size = size;\r\n label.textAlign = align;\r\n label.x = x;\r\n label.y = y;\r\n label.text = txt;\r\n return label;\r\n };\r\n return Tool;\r\n }());\r\n //# sourceMappingURL=Tools.js.map\n\n var curScore;\r\n function getScore() {\r\n return curScore;\r\n }\r\n function addScore(addCount) {\r\n curScore += addCount;\r\n return curScore;\r\n }\r\n function setScore(scoreCount) {\r\n curScore = scoreCount;\r\n }\r\n var curLevel;\r\n function getCurLevel() {\r\n return curLevel;\r\n }\r\n function setCurLevel(level) {\r\n curLevel = level;\r\n return curLevel;\r\n }\r\n var levels$1;\r\n var setlevelData$1 = function () {\r\n levels$1 = {\r\n '1': { max: props.level_1[0], items: [[LabelType$1.boom, props.level_1[1]], [LabelType$1.coin, props.level_1[2]]], time: props.level_1[3] },\r\n '2': { max: props.level_2[0], items: [[LabelType$1.boom, props.level_2[1]], [LabelType$1.coin, props.level_2[2]]], time: props.level_2[3] },\r\n '3': { max: props.level_3[0], items: [[LabelType$1.boom, props.level_3[1]], [LabelType$1.coin, props.level_3[2]]], time: props.level_3[3] },\r\n };\r\n };\r\n var getLevelData = function () {\r\n if (!levels$1) {\r\n setlevelData$1();\r\n }\r\n return levels$1[getCurLevel()];\r\n };\r\n var getCurrentItems = function () {\r\n if (!levels$1) {\r\n setlevelData$1();\r\n }\r\n return getLevelData().items;\r\n };\r\n var getlevelTime = function () {\r\n if (!levels$1) {\r\n setlevelData$1();\r\n }\r\n return getLevelData().time;\r\n };\r\n var getlevelMax = function () {\r\n if (!levels$1) {\r\n setlevelData$1();\r\n }\r\n return getLevelData().max;\r\n };\r\n //# sourceMappingURL=goldData.js.map\n\n var GameData = (function (_super) {\r\n tslib.__extends(GameData, _super);\r\n function GameData(parentNode, color) {\r\n var _this = _super.call(this) || this;\r\n _this.starList = [];\r\n _this._parentNode = parentNode;\r\n _this._color = color;\r\n _this.init();\r\n return _this;\r\n }\r\n GameData.prototype.init = function () {\r\n var scoreCount = this._scoreCount = Tool.getLabel('', 36, \"#ffffff\", true);\r\n scoreCount.y = 48;\r\n this.addChild(scoreCount);\r\n var scorelabel = this._scorelabel = Tool.getLabel('分', 22, \"#ffffff\");\r\n scorelabel.y = 56;\r\n this.addChild(scorelabel);\r\n var progress = new engine.Sprite(getTextureByName('进度'));\r\n progress.x = 212;\r\n progress.y = 8;\r\n this.addChild(progress);\r\n var progressMask = this._progressMask = new engine.Rect();\r\n progressMask.fillColor = 0x000000;\r\n progressMask.width = 245;\r\n progressMask.height = 100;\r\n progressMask.x = 213;\r\n progressMask.y = 5;\r\n progressMask.scaleX = 0;\r\n this.addChild(progressMask);\r\n progress.mask = progressMask;\r\n var star1 = new engine.Sprite(getTextureByName('点亮'));\r\n star1.x = 270;\r\n star1.y = 6;\r\n star1.visible = false;\r\n this.addChild(star1);\r\n this.starList.push(star1);\r\n var star2 = new engine.Sprite(getTextureByName('点亮'));\r\n star2.x = 365;\r\n star2.y = 6;\r\n star2.visible = false;\r\n this.addChild(star2);\r\n this.starList.push(star2);\r\n var star3 = new engine.Sprite(getTextureByName('点亮'));\r\n star3.x = 435;\r\n star3.y = 50;\r\n star3.visible = false;\r\n this.addChild(star3);\r\n this.starList.push(star3);\r\n this.scorePosUpdate();\r\n var levelLabel = this._levelLabel = Tool.getLabel('', 28, this._color || \"#28c1ec\", false);\r\n levelLabel.y = 98;\r\n this.addChild(levelLabel);\r\n this.levelUpdate();\r\n this.updateProgressMask();\r\n };\r\n GameData.prototype.scorePosUpdate = function () {\r\n this._scoreCount.text = getScore();\r\n this._scoreCount.x = (this._parentNode.width - this._scoreCount.width - this._scorelabel.width - 5) / 2;\r\n this._scorelabel.x = this._scoreCount.x + this._scoreCount.width + 5;\r\n this.updateProgressMask();\r\n };\r\n GameData.prototype.levelUpdate = function (color) {\r\n this._levelLabel.text = \"\\u7B2C\" + getCurLevel() + \"/3\\u5173\";\r\n this._levelLabel.x = (this._parentNode.width - this._levelLabel.width) / 2;\r\n };\r\n GameData.prototype.updateProgressMask = function () {\r\n var ratio = getScore() / getlevelMax();\r\n this._progressMask.scaleX = ratio;\r\n if (ratio >= 0.35) {\r\n this.starList[0].visible = true;\r\n }\r\n if (ratio >= 0.75) {\r\n this.starList[1].visible = true;\r\n }\r\n if (ratio >= 1) {\r\n this.starList[2].visible = true;\r\n }\r\n };\r\n GameData.prototype.resetMask = function () {\r\n this.starList.forEach(function (element) {\r\n element.visible = false;\r\n });\r\n };\r\n return GameData;\r\n }(engine.Container));\r\n //# sourceMappingURL=gameData.js.map\n\n var BaseItem = (function (_super) {\r\n tslib.__extends(BaseItem, _super);\r\n function BaseItem(mc, type) {\r\n var _this = _super.call(this) || this;\r\n _this.type = type;\r\n _this._mc = mc;\r\n var bubble = getTextureByName('bubble');\r\n var bubblePic = new engine.Sprite(bubble);\r\n bubblePic.anchorTexture.set(0.5, 0.5);\r\n _this._mc.anchorTexture.set(0.5, 0.5);\r\n _this._mc.x = bubblePic.x / 4;\r\n _this._mc.y = bubblePic.y / 4;\r\n _this.addChild(bubblePic);\r\n _this.addChild(_this._mc);\r\n return _this;\r\n }\r\n Object.defineProperty(BaseItem.prototype, \"mc\", {\r\n get: function () { return this._mc; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return BaseItem;\r\n }(engine.Sprite));\r\n //# sourceMappingURL=BaseItem.js.map\n\n var EgretRender = (function () {\r\n function EgretRender(root, engine) {\r\n this._root = root;\r\n this._engine = engine;\r\n }\r\n EgretRender.prototype.addBody = function (body, display, x, y) {\r\n if (display) {\r\n body['display'] = display;\r\n this._root.addChildAt(display, 0);\r\n display.x = x;\r\n display.y = y;\r\n }\r\n return body;\r\n };\r\n EgretRender.prototype.remove = function (body) {\r\n this.removeBody(body);\r\n this.removeDisplay(body);\r\n };\r\n EgretRender.prototype.removeBody = function (body) {\r\n Matter.World.remove(this._engine.world, body);\r\n };\r\n EgretRender.prototype.removeDisplay = function (body) {\r\n var display = body['display'];\r\n if (display && display.parent)\r\n display.parent.removeChild(display);\r\n };\r\n EgretRender.prototype.run = function () {\r\n var bodies = Matter.Composite.allBodies(this._engine.world);\r\n for (var i = 0; i < bodies.length; i++) {\r\n var body = bodies[i];\r\n var display = body['display'];\r\n if (!display)\r\n continue;\r\n var x1 = Math.round(display.x);\r\n var x2 = Math.round(body.position.x);\r\n var y1 = Math.round(display.y);\r\n var y2 = Math.round(body.position.y);\r\n var distanceX = Math.abs(x1 - x2);\r\n var distanceY = Math.abs(y1 - y2);\r\n var precision = 1;\r\n if (distanceX > precision || distanceY > precision) {\r\n if (display instanceof BaseItem)\r\n display.mc.resume();\r\n }\r\n else {\r\n if (display instanceof BaseItem)\r\n display.mc.pause();\r\n }\r\n display.x = body.position.x;\r\n display.y = body.position.y;\r\n display.rotation = this.getRotation(body.angle);\r\n }\r\n };\r\n EgretRender.prototype.rectangle = function (x, y, width, height, display, options) {\r\n var body = this.rectangleToRender(x, y, width, height, display, options);\r\n this.addBodyToWorld(body);\r\n return body;\r\n };\r\n EgretRender.prototype.circle = function (x, y, radius, display, options) {\r\n var body = this.circleToRender(x, y, radius, display, options);\r\n this.addBodyToWorld(body);\r\n return body;\r\n };\r\n EgretRender.prototype.addBodyToWorld = function (body) {\r\n Matter.World.add(this._engine.world, body);\r\n return body;\r\n };\r\n EgretRender.prototype.rectangleToRender = function (x, y, width, height, display, options) {\r\n var body = Matter.Bodies.rectangle(x, y, width, height, options);\r\n this.addBody(body, display, x, y);\r\n return body;\r\n };\r\n EgretRender.prototype.circleToRender = function (x, y, radius, display, options) {\r\n var body = Matter.Bodies.circle(x, y, radius, options);\r\n this.addBody(body, display, x, y);\r\n return body;\r\n };\r\n EgretRender.prototype.getRotation = function (angle) {\r\n return angle / Math.PI / 2 * 360;\r\n };\r\n return EgretRender;\r\n }());\r\n //# sourceMappingURL=EgretRender.js.map\n\n var wall = 1;\r\n var basket = 2;\r\n var award = 4;\r\n var bubble = 8;\r\n var bubbleStandby = 16;\r\n var bubbleGroup = -1;\r\n var bubbleStandbyGroup = -2;\r\n var wallMask = award + bubble + bubbleStandby;\r\n var basketMask = award + bubble + bubbleStandby;\r\n var awardMask = wall + basket + bubble;\r\n var bubbleMask = wall + basket + award;\r\n var bubbleStandbyMask = wall + basket;\r\n //# sourceMappingURL=collisionConfig.js.map\n\n var vibrate = (function (view, count, strength) {\r\n if (count === void 0) { count = 2; }\r\n if (strength === void 0) { strength = 10; }\r\n return new Promise(function (r) {\r\n var pos = [\r\n { x: strength, y: 0 },\r\n { x: 0, y: -strength },\r\n { x: -strength, y: 0 },\r\n { x: 0, y: strength },\r\n { x: 0, y: 0 },\r\n ];\r\n var list = [];\r\n for (var i = 0; i < count; i++) {\r\n list = list.concat(pos);\r\n }\r\n var x0 = view.x;\r\n var y0 = view.y;\r\n var counter = list.length;\r\n var _loop_1 = function (i) {\r\n var element = list[i];\r\n setTimeout(function () {\r\n view.x = element.x + x0;\r\n view.y = element.y + y0;\r\n counter--;\r\n if (counter == 0) {\r\n view.x = x0;\r\n view.y = y0;\r\n r();\r\n }\r\n }, 1000 / 60 * i);\r\n };\r\n for (var i = 0; i < list.length; i++) {\r\n _loop_1(i);\r\n }\r\n });\r\n });\r\n //# sourceMappingURL=vibrate.js.map\n\n var MovieClip = (function (_super) {\r\n tslib.__extends(MovieClip, _super);\r\n function MovieClip(_a) {\r\n var spritesheet = _a.spritesheet, frames = _a.frames, scale = _a.scale, position = _a.position, _b = _a.keys, keys = _b === void 0 ? null : _b, _c = _a.autoplay, autoplay = _c === void 0 ? true : _c, _d = _a.loop, loop = _d === void 0 ? true : _d, anchor = _a.anchor, _e = _a.frameInterval, frameInterval = _e === void 0 ? 1 : _e, _f = _a.callBack, callBack = _f === void 0 ? null : _f;\r\n var _this = _super.call(this) || this;\r\n _this.frames = frames;\r\n _this.frameInterval = frameInterval;\r\n _this.keys = keys;\r\n _this.autoplay = autoplay;\r\n _this.loop = loop;\r\n _this.anchorXtmp = anchor;\r\n _this.anchorYtmp = anchor;\r\n _this._callBack = callBack;\r\n if (Array.isArray(anchor)) {\r\n _this.anchorXtmp = anchor[0];\r\n _this.anchorYtmp = anchor[1];\r\n }\r\n _this.x = position[0];\r\n _this.y = position[1];\r\n _this.spritesheet = spritesheet;\r\n if (_this.autoplay) {\r\n _this.play();\r\n }\r\n _this.scaleX = _this.scaleY = scale;\r\n return _this;\r\n }\r\n MovieClip.prototype.pause = function () {\r\n this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this);\r\n };\r\n MovieClip.prototype.resume = function () {\r\n this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this);\r\n };\r\n MovieClip.prototype.play = function (start) {\r\n if (start === void 0) { start = 0; }\r\n this.goto(start);\r\n this.currentFrame = 0;\r\n this.counter = 0;\r\n this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this);\r\n };\r\n MovieClip.prototype.goto = function (frame) {\r\n this.texture = this.textures[frame];\r\n };\r\n MovieClip.prototype.onTick = function () {\r\n this.counter++;\r\n if (this.counter == this.frameInterval) {\r\n this.counter = 0;\r\n this.currentFrame++;\r\n this.goto(this.currentFrame);\r\n if (this.currentFrame == this.frames.length - 1) {\r\n if (this.loop) {\r\n this.currentFrame = 0;\r\n }\r\n else {\r\n this.stop();\r\n if (this._callBack) {\r\n this._callBack();\r\n this._callBack = null;\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n };\r\n MovieClip.prototype.stop = function () {\r\n this.currentFrame = 0;\r\n this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this);\r\n };\r\n Object.defineProperty(MovieClip.prototype, \"spritesheet\", {\r\n set: function (value) {\r\n this.textures = this.frames.map(function (frame) { return value[frame]; });\r\n this.anchorTexture.set(this.anchorXtmp, this.anchorYtmp);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MovieClip.prototype, \"textureItemWidth\", {\r\n get: function () { return this.textures[0].width; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MovieClip.prototype, \"textureItemHeight\", {\r\n get: function () { return this.textures[0].height; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return MovieClip;\r\n }(engine.Image));\r\n //# sourceMappingURL=MovieClip.js.map\n\n var wait = function (duration) { return tslib.__awaiter(void 0, void 0, void 0, function () {\r\n return tslib.__generator(this, function (_a) {\r\n return [2, new Promise(function (resolve) { return setTimeout(resolve, duration); })];\r\n });\r\n }); };\r\n //# sourceMappingURL=wait.js.map\n\n var josnData = {};\r\n function getJsonAsset(name) {\r\n var config = engine.getAssetByName(name + '_json');\r\n var tmpJosnData = engine.globalLoader.get(config.uuid);\r\n if (tmpJosnData) {\r\n josnData[name] = convert(tmpJosnData);\r\n }\r\n }\r\n function convert(data) {\r\n var frames = data.frames;\r\n var jsonName = data.file.split('.')[0];\r\n var obj = {};\r\n for (var key in frames) {\r\n var f = frames[key];\r\n obj[jsonName + key + \".png\"] = {\r\n \"x\": f.x,\r\n \"y\": f.y,\r\n \"w\": f.w,\r\n \"h\": f.h,\r\n \"ox\": f.offX,\r\n \"oy\": f.offY,\r\n \"sw\": f.sourceW,\r\n \"sh\": f.sourceH,\r\n \"ro\": false,\r\n };\r\n }\r\n return obj || null;\r\n }\r\n function getJosnData(jsonName) {\r\n return josnData[jsonName] || null;\r\n }\r\n //# sourceMappingURL=JsonTools.js.map\n\n function createTextureSheet(baseTexture, altaData) {\r\n var frames = altaData;\r\n var frameKeys = Object.keys(frames);\r\n var frameIndex = 0;\r\n var textures = {};\r\n while (frameIndex < frameKeys.length) {\r\n var i = frameKeys[frameIndex];\r\n var data = frames[i];\r\n var frame = null;\r\n var trim = null;\r\n var orig = new engine.Rectangle(0, 0, Math.floor(data.sw), Math.floor(data.sh));\r\n if (data.ro) {\r\n frame = new engine.Rectangle(Math.floor(data.x), Math.floor(data.y), Math.floor(data.h), Math.floor(data.w));\r\n }\r\n else {\r\n frame = new engine.Rectangle(Math.floor(data.x), Math.floor(data.y), Math.floor(data.w), Math.floor(data.h));\r\n }\r\n if (data.ox || data.oy) {\r\n trim = new engine.Rectangle(Math.floor(data.ox), Math.floor(data.oy), Math.floor(data.w), Math.floor(data.h));\r\n }\r\n var texture = new engine.Texture(baseTexture, frame, orig, trim, data.ro ? 2 : 0);\r\n engine.Texture.addToCache(texture, i);\r\n textures[i] = texture;\r\n frameIndex++;\r\n }\r\n return textures;\r\n }\r\n //# sourceMappingURL=createTextureSheet.js.map\n\n function playMovieClip(parent, key, frames, frameInterval) {\r\n if (frameInterval === void 0) { frameInterval = 5; }\r\n return tslib.__awaiter(this, void 0, void 0, function () {\r\n var _this = this;\r\n return tslib.__generator(this, function (_a) {\r\n return [2, new Promise(function (r) { return tslib.__awaiter(_this, void 0, void 0, function () {\r\n var josnData, texture;\r\n var _this = this;\r\n return tslib.__generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n josnData = getJosnData(key);\r\n if (!josnData) {\r\n getJsonAsset(key);\r\n josnData = getJosnData(key);\r\n }\r\n texture = createTextureSheet(getTextureByName(key).baseTexture, josnData);\r\n if (!texture) return [3, 2];\r\n return [4, createMc(parent, texture, frames, frameInterval)];\r\n case 1:\r\n _a.sent();\r\n r(1);\r\n return [3, 3];\r\n case 2:\r\n wait(300).then(function () { return tslib.__awaiter(_this, void 0, void 0, function () {\r\n var josnData;\r\n return tslib.__generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n josnData = getJosnData(key);\r\n if (!josnData) {\r\n getJsonAsset(key);\r\n josnData = getJosnData(key);\r\n }\r\n texture = createTextureSheet(getTextureByName(key).baseTexture, josnData);\r\n if (!texture) return [3, 2];\r\n return [4, createMc(parent, texture, frames, frameInterval)];\r\n case 1:\r\n _a.sent();\r\n r(1);\r\n return [3, 3];\r\n case 2:\r\n r(0);\r\n _a.label = 3;\r\n case 3: return [2];\r\n }\r\n });\r\n }); });\r\n _a.label = 3;\r\n case 3: return [2];\r\n }\r\n });\r\n }); })];\r\n });\r\n });\r\n }\r\n function createMc(parent, spritesheet, frames, frameInterval) {\r\n if (frameInterval === void 0) { frameInterval = 5; }\r\n return new Promise(function (r) {\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: frameInterval,\r\n frames: frames,\r\n position: [0, 150],\r\n scale: 1,\r\n anchor: [0, 0],\r\n loop: false,\r\n callBack: function () {\r\n setTimeout(function () {\r\n parent.removeChild(movieclip);\r\n r(1);\r\n }, 100);\r\n }\r\n });\r\n parent.addChild(movieclip);\r\n });\r\n }\r\n var playBoom = function (parent) {\r\n return playMovieClip(parent, 'fail', ['fail1.png', 'fail2.png', 'fail3.png', 'fail4.png', 'fail5.png', 'fail6.png', 'fail7.png', 'fail8.png'], 5);\r\n };\r\n var playSuccess = function (parent) {\r\n return playMovieClip(parent, 'success', ['success1.png', 'success2.png', 'success3.png', 'success4.png', 'success5.png', 'success6.png', 'success7.png', 'success8.png', 'success9.png'], 5);\r\n };\r\n //# sourceMappingURL=playMovieClip.js.map\n\n var createCoin = function (scale) {\r\n var josnData = getJosnData('coin');\r\n if (!josnData) {\r\n getJsonAsset('coin');\r\n josnData = getJosnData('coin');\r\n }\r\n var texture = createTextureSheet(getTextureByName('coin').baseTexture, josnData);\r\n var animation = createMovieClip(texture, 0.6);\r\n var baseItem = new BaseItem(animation, LabelType$1.coin);\r\n baseItem.scaleX = baseItem.scaleY = scale;\r\n return baseItem;\r\n };\r\n var createMovieClip = function (spritesheet, scale) {\r\n if (scale === void 0) { scale = 1; }\r\n var list = ['coin1.png', 'coin2.png', 'coin3.png', 'coin4.png', 'coin5.png', 'coin6.png', 'coin7.png', 'coin8.png'];\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: 6,\r\n frames: list,\r\n position: [0, 0],\r\n scale: scale,\r\n anchor: [.5, .5]\r\n });\r\n return movieclip;\r\n };\r\n //# sourceMappingURL=createCoin.js.map\n\n var createBoom = function (scale) {\r\n var josnData = getJosnData('boom');\r\n if (!josnData) {\r\n getJsonAsset('boom');\r\n josnData = getJosnData('boom');\r\n }\r\n var boomTexture = createTextureSheet(getTextureByName('boom').baseTexture, josnData);\r\n var animation = createMovieClip$1(boomTexture);\r\n var baseItem = new BaseItem(animation, LabelType$1.boom);\r\n baseItem.scaleX = baseItem.scaleY = scale;\r\n return baseItem;\r\n };\r\n var createMovieClip$1 = function (spritesheet, scale) {\r\n if (scale === void 0) { scale = 1; }\r\n var list = ['boom1.png', 'boom2.png', 'boom3.png', 'boom4.png', 'boom5.png', 'boom6.png', 'boom7.png', 'boom8.png', 'boom9.png', 'boom10.png'];\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: 5,\r\n frames: list,\r\n position: [0, 0],\r\n scale: scale,\r\n anchor: [.5, .5]\r\n });\r\n return movieclip;\r\n };\r\n //# sourceMappingURL=createBoom.js.map\n\n var createGift = function (scale) {\r\n var josnData = getJosnData('gift');\r\n if (!josnData) {\r\n getJsonAsset('gift');\r\n josnData = getJosnData('gift');\r\n }\r\n var texture = createTextureSheet(getTextureByName('gift').baseTexture, josnData);\r\n var animation = createMovieClip$2(texture, 0.6);\r\n var baseItem = new BaseItem(animation, LabelType$1.gift);\r\n baseItem.scaleX = baseItem.scaleY = scale;\r\n return baseItem;\r\n };\r\n var createMovieClip$2 = function (spritesheet, scale) {\r\n if (scale === void 0) { scale = 1; }\r\n var list = ['gift1.png', 'gift2.png', 'gift3.png', 'gift4.png', 'gift5.png', 'gift6.png', 'gift7.png', 'gift8.png', 'gift9.png', 'gift10.png'];\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: 5,\r\n frames: list,\r\n position: [0, 0],\r\n scale: scale,\r\n anchor: [.5, .5]\r\n });\r\n return movieclip;\r\n };\r\n //# sourceMappingURL=createGift.js.map\n\n var createCandy = function (scale) {\r\n var josnData = getJosnData('candy');\r\n if (!josnData) {\r\n getJsonAsset('candy');\r\n josnData = getJosnData('candy');\r\n }\r\n var boomTexture = createTextureSheet(getTextureByName('candy').baseTexture, josnData);\r\n var animation = createMovieClip$3(boomTexture);\r\n var baseItem = new BaseItem(animation, LabelType$1.candy);\r\n baseItem.scaleX = baseItem.scaleY = scale;\r\n return baseItem;\r\n };\r\n var createMovieClip$3 = function (spritesheet, scale) {\r\n if (scale === void 0) { scale = 1; }\r\n var list = ['candy1.png', 'candy2.png', 'candy3.png', 'candy4.png', 'candy5.png', 'candy6.png', 'candy7.png', 'candy8.png'];\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: 6,\r\n frames: list,\r\n position: [0, 0],\r\n scale: scale,\r\n anchor: [.5, .5]\r\n });\r\n return movieclip;\r\n };\r\n //# sourceMappingURL=createCandy.js.map\n\n var createEgg = function (scale) {\r\n var josnData = getJosnData('egg');\r\n if (!josnData) {\r\n getJsonAsset('gift');\r\n josnData = getJosnData('egg');\r\n }\r\n var texture = createTextureSheet(getTextureByName('egg').baseTexture, josnData);\r\n var animation = createMovieClip$4(texture, 0.6);\r\n var baseItem = new BaseItem(animation, LabelType$1.egg);\r\n baseItem.scaleX = baseItem.scaleY = scale;\r\n return baseItem;\r\n };\r\n var createMovieClip$4 = function (spritesheet, scale) {\r\n if (scale === void 0) { scale = 1; }\r\n var list = ['egg1.png', 'egg2.png', 'egg3.png', 'egg4.png', 'egg5.png', 'egg6.png', 'egg7.png', 'egg8.png', 'egg9.png'];\r\n var movieclip = new MovieClip({\r\n spritesheet: spritesheet,\r\n frameInterval: 5,\r\n frames: list,\r\n position: [0, 0],\r\n scale: scale,\r\n anchor: [.5, .5]\r\n });\r\n return movieclip;\r\n };\r\n //# sourceMappingURL=createEgg.js.map\n\n var createItem = function (scale, type) {\r\n var funcs = {\r\n 'boom': createBoom,\r\n 'gift': createGift,\r\n 'candy': createCandy,\r\n 'egg': createEgg,\r\n 'coin': createCoin\r\n };\r\n var func = funcs[type];\r\n return func(scale);\r\n };\r\n //# sourceMappingURL=createItem.js.map\n\n var createBubble = function (_this, type, x, y, force, density) {\r\n if (force === void 0) { force = { x: 0, y: 0 }; }\r\n if (density === void 0) { density = 0.001; }\r\n var scale;\r\n var size = random(85, 100);\r\n var maxsize = 100;\r\n scale = size / maxsize;\r\n var baseItem = createItem(scale, type);\r\n var angle;\r\n angle = 0;\r\n _this._egretRender.circle(x, y, (size - 17) / 2, baseItem, {\r\n frictionAir: 0,\r\n collisionFilter: { group: award, category: award, mask: awardMask },\r\n angle: angle,\r\n label: baseItem.type,\r\n friction: 0,\r\n force: force,\r\n density: density\r\n });\r\n };\r\n var random = function (start, end) {\r\n var n = end - start;\r\n return Math.random() * n + start;\r\n };\r\n var createItems = (function (_this) {\r\n var score = getScore();\r\n var items = getCurrentItems();\r\n var list = [];\r\n for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {\r\n var item = items_1[_i];\r\n var type = item[0];\r\n var nums = item[1];\r\n if (type == LabelType$1.coin)\r\n nums = nums - score;\r\n for (var i = 0; i < nums; i++) {\r\n list.push(type);\r\n }\r\n }\r\n var count = 0;\r\n var coinsFall = setInterval(function () {\r\n if (count <= list.length - 1) {\r\n var type = list[count];\r\n createBubble(_this, type, 375 + Math.random() * 200 - 100, 400 + 200 + 200);\r\n count++;\r\n }\r\n }, 100);\r\n });\r\n //# sourceMappingURL=createItems.js.map\n\n var clear = function (that) {\r\n TextList.forEach(function (i) {\r\n engine.Tween.removeTweens(that.gameHint[i]);\r\n that.gameHint[i].alpha = 0;\r\n });\r\n };\r\n var playgreat = function (image) {\r\n engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 20 }).to({ x: 540.5, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(2)).wait(500).to({ alpha: 0 }, 200);\r\n };\r\n var playcool = function (image) {\r\n engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 60 }).to({ x: 526.09, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(7)).wait(500).to({ alpha: 0 }, 200);\r\n };\r\n var playperfect = function (image) {\r\n engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, }).to({ scaleX: 1, scaleY: 1 }, 200, engine.Ease.getBackOut(10)).wait(500).to({ alpha: 0 }, 200);\r\n };\r\n var playawesome = function (image) {\r\n engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -20 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(20)).wait(500).to({ alpha: 0 }, 200);\r\n };\r\n var playunbelievable = function (image) {\r\n engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -60 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(40)).wait(500).to({ alpha: 0 }, 200);\r\n };\r\n var funcs = [playgreat, playcool, playperfect, playawesome, playunbelievable];\r\n var cdtimer;\r\n var count = 0;\r\n var playTextAni = function (that) { return tslib.__awaiter(void 0, void 0, void 0, function () {\r\n var image;\r\n return tslib.__generator(this, function (_a) {\r\n clear(that);\r\n count++;\r\n if (count >= TextList.length)\r\n count = TextList.length;\r\n console.log(count);\r\n image = that.gameHint[TextList[count - 1]];\r\n image.visible = true;\r\n funcs[count - 1](image);\r\n if (cdtimer > 0)\r\n clearTimeout(cdtimer);\r\n cdtimer = setTimeout(function () {\r\n count = 0;\r\n console.log('clear');\r\n }, 5000);\r\n return [2];\r\n });\r\n }); };\r\n var TextList = ['great', 'cool', 'perfect', 'awesome', 'unbelievable'];\r\n //# sourceMappingURL=playTextAni.js.map\n\n function check(_this) {\r\n var egretRenderContainer = _this.egretRenderContainer;\r\n var center = 375;\r\n var paddingX = 50;\r\n var ypos = 570;\r\n var h = 40;\r\n var bodies = Matter.Composite.allBodies(_this._engine.world);\r\n var isAward = function (i) { return i.collisionFilter.group == award; };\r\n bodies.forEach(function (i) {\r\n if (!isAward(i))\r\n return;\r\n if (i['timer']) {\r\n var t0 = Date.now() - i['timer'];\r\n if (t0 > 3000) {\r\n delete i['timer'];\r\n }\r\n }\r\n var _a = i.position, x = _a.x, y = _a.y;\r\n var xResult = x > (center - paddingX) && x < (center + paddingX);\r\n var yResult = y > ypos && y < (ypos + h);\r\n if (xResult && yResult && i.velocity.y > 0 && !i['timer']) {\r\n i['timer'] = Date.now();\r\n if (i.label == LabelType$1.boom) {\r\n _this._egretRender.remove(i);\r\n vibrate(_this, 2);\r\n playBoom(egretRenderContainer);\r\n _this.onBoom();\r\n }\r\n else if (i.label == LabelType$1.egg) {\r\n _this._egretRender.remove(i);\r\n }\r\n else if (i.label == LabelType$1.candy) {\r\n _this._egretRender.remove(i);\r\n }\r\n else if (i.label == LabelType$1.gift) {\r\n _this._egretRender.remove(i);\r\n }\r\n else {\r\n playSuccess(_this.egretRenderContainer);\r\n _this._egretRender.remove(i);\r\n _this.addScore();\r\n playTextAni(_this);\r\n }\r\n }\r\n });\r\n }\r\n //# sourceMappingURL=check.js.map\n\n var createBox = function (_this) {\r\n var path1 = Matter.Vertices.fromPath('385 370 630 380 670 728 620 1080 370 1100 109 1090 57 728 108 370 0 370 0 1624 750 1624 750 0', null);\r\n var body = Matter.Bodies.fromVertices(400, 880, [path1], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);\r\n Matter.World.add(_this._engine.world, body);\r\n var path2 = Matter.Vertices.fromPath('108 370 385 370 385 300', null);\r\n var body2 = Matter.Bodies.fromVertices(296, 365, [path2], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);\r\n Matter.World.add(_this._engine.world, body2);\r\n var basketpath1 = Matter.Vertices.fromPath('290 560 324 600 326 600 313 565', null);\r\n var basketbody1 = Matter.Bodies.fromVertices(305, 575, [basketpath1], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);\r\n Matter.World.add(_this._engine.world, basketbody1);\r\n var basketpath2 = Matter.Vertices.fromPath('465 563 443 605 441 605 456 560', null);\r\n var basketbody2 = Matter.Bodies.fromVertices(453, 570, [basketpath2], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);\r\n Matter.World.add(_this._engine.world, basketbody2);\r\n var basketLeft = Matter.Bodies.circle(285, 560, 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } });\r\n Matter.World.add(_this._engine.world, basketLeft);\r\n var basketRight = Matter.Bodies.circle(461, 560, 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } });\r\n Matter.World.add(_this._engine.world, basketRight);\r\n var w = 100;\r\n var h = 50;\r\n var rect = _this._egretRender.rectangle(180, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });\r\n var rect2 = _this._egretRender.rectangle(560, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });\r\n var w2 = 300;\r\n var h2 = 10;\r\n var rect3 = _this._egretRender.rectangle(375, 1100, w2, h2, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });\r\n };\r\n //# sourceMappingURL=createBox.js.map\n\n var createBubblePic = function (r) {\r\n var bubbleTexture = getTextureByName('bubble');\r\n var bubblePic = new engine.Sprite(bubbleTexture);\r\n bubblePic.scaleX = bubblePic.scaleY = r * 2 / 100;\r\n return bubblePic;\r\n };\r\n //# sourceMappingURL=createBubblePic.js.map\n\n var timerLeft;\r\n var timerRight;\r\n var startStandbyBubblesLeft = function (egretRender) {\r\n timerLeft = setInterval(function () {\r\n var scale = 0.2;\r\n var p1 = { x: 180, y: 1050 };\r\n var r = random$1(8, 10);\r\n var bubblePic = createBubblePic(r);\r\n var body = egretRender.circle(p1.x, p1.y, r, bubblePic, {\r\n restitution: 0,\r\n frictionAir: 0,\r\n force: { x: random$1(-0.005, 0.005) * scale, y: -0.02 * scale },\r\n collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }\r\n });\r\n setTimeout(function () {\r\n egretRender.remove(body);\r\n }, 1000);\r\n }, 700);\r\n };\r\n var startStandbyBubblesRight = function (egretRender) {\r\n timerRight = setInterval(function () {\r\n var scale = 0.2;\r\n var p2 = { x: 560, y: 1050 };\r\n var r2 = random$1(8, 10);\r\n var bubblePic2 = createBubblePic(r2);\r\n var body2 = egretRender.circle(p2.x, p2.y, r2, bubblePic2, {\r\n restitution: 0,\r\n frictionAir: 0,\r\n force: { x: random$1(-0.005, 0.005) * scale, y: -0.02 * scale },\r\n collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }\r\n });\r\n setTimeout(function () {\r\n egretRender.remove(body2);\r\n }, 1000);\r\n }, 700);\r\n };\r\n var stopStandbyBubblesLeft = function () {\r\n clearInterval(timerLeft);\r\n };\r\n var stopStandbyBubblesRight = function () {\r\n clearInterval(timerRight);\r\n };\r\n var random$1 = function (start, end) {\r\n var n = end - start;\r\n return Math.random() * n + start;\r\n };\r\n //# sourceMappingURL=standbyBubbles.js.map\n\n var createBtns = (function (that) {\r\n var createShape = function () {\r\n var shape = new engine.Shape();\r\n shape.beginFill(0, .6);\r\n shape.drawCircle(0, 0, that._leftBtn.width / 2);\r\n shape.endFill();\r\n return shape;\r\n };\r\n [that._leftBtn, that._rightBtn].forEach(function (btn) {\r\n btn.addEventListener(engine.MouseEvent.MOUSE_DOWN, function (e) {\r\n var btn = e.target;\r\n engine.Tween.removeTweens(btn);\r\n engine.Tween.get(btn)\r\n .to({ scaleY: 0.9 }, 200);\r\n }, that);\r\n });\r\n [that._leftBtn, that._rightBtn].forEach(function (btn) {\r\n btn.addEventListener(engine.MouseEvent.MOUSE_UP, function (e) {\r\n var btn = e.target;\r\n engine.Tween.removeTweens(btn);\r\n engine.Tween.get(btn)\r\n .to({ scaleX: 1, scaleY: 1 }, 200);\r\n }, that);\r\n });\r\n [that._leftBtn, that._rightBtn].forEach(function (btn) {\r\n btn.addEventListener(engine.MouseEvent.MOUSE_OUT, function (e) {\r\n var btn = e.target;\r\n engine.Tween.removeTweens(btn);\r\n engine.Tween.get(btn)\r\n .to({ scaleX: 1, scaleY: 1 }, 200);\r\n }, that);\r\n });\r\n var shapeLeft = createShape();\r\n shapeLeft.x = that._leftBtn.width / 2;\r\n shapeLeft.y = that._leftBtn.height / 2;\r\n that._leftBtn.addChild(shapeLeft);\r\n var shapeR = createShape();\r\n shapeR.x = that._rightBtn.width / 2;\r\n shapeR.y = that._rightBtn.height / 2;\r\n that._rightBtn.addChild(shapeR);\r\n shapeLeft.alpha = shapeR.alpha = 0;\r\n });\r\n //# sourceMappingURL=createBtns.js.map\n\n var GameView = (function (_super) {\r\n tslib.__extends(GameView, _super);\r\n function GameView() {\r\n var _this = _super.call(this) || this;\r\n _this.gameHint = {};\r\n _this.addForce = false;\r\n _this.stageX = 0;\r\n _this.stageY = 0;\r\n _this._frameCount = 0;\r\n return _this;\r\n }\r\n GameView.prototype.start = function (color) {\r\n return tslib.__awaiter(this, void 0, void 0, function () {\r\n var a, gameNode, contPng, leftBtn, rightBtn, light, basket_bottom, tmpRect, basket_top, glass, gameData, countDown, countDownLabel;\r\n return tslib.__generator(this, function (_a) {\r\n a = new engine.Shape();\r\n this.addChild(a);\r\n engine.globalLoader.loadImage('//yun.duiba.com.cn/aurora/assets/66ab48ff49a741f0c93335d4eb0c9e50b7ab6e1e.png', 'bg_dot')\r\n .then(function (img) {\r\n a.beginBitmapFill(img, null);\r\n a.drawRect(0, 0, 750, 1624);\r\n a.endFill();\r\n });\r\n gameNode = this._gameNode = new engine.Sprite(getTextureByName('机子'));\r\n gameNode.y = 260;\r\n this.addChild(gameNode);\r\n contPng = new engine.Image(getTextureByName('contPng'));\r\n contPng.x = (750 - contPng.width) / 2;\r\n contPng.y = 215;\r\n this.addChild(contPng);\r\n leftBtn = this._leftBtn = new engine.Sprite(getTextureByName('左按钮'));\r\n leftBtn.anchorY = leftBtn.height - 50;\r\n leftBtn.x = 83;\r\n leftBtn.y = 920;\r\n gameNode.addChild(leftBtn);\r\n rightBtn = this._rightBtn = new engine.Sprite(getTextureByName('右按钮'));\r\n rightBtn.anchorY = rightBtn.height - 50;\r\n rightBtn.x = 400;\r\n rightBtn.y = 920;\r\n gameNode.addChild(rightBtn);\r\n light = this._light = new engine.Sprite(getTextureByName('灯'));\r\n light.x = 12;\r\n light.y = 44;\r\n gameNode.addChild(light);\r\n basket_bottom = this._basket_bottom = new engine.Sprite(getTextureByName('basket_bottom'));\r\n basket_bottom.x = (contPng.width - basket_bottom.width) / 2;\r\n basket_bottom.y = 85;\r\n contPng.addChild(basket_bottom);\r\n tmpRect = new engine.Rect();\r\n tmpRect.x = 230;\r\n tmpRect.y = 372;\r\n tmpRect.width = 300;\r\n tmpRect.height = 300;\r\n this.addChild(tmpRect);\r\n basket_bottom.mask = tmpRect;\r\n basket_top = this._basket_top = new engine.Sprite(getTextureByName('basket_top'));\r\n basket_top.x = 287;\r\n basket_top.y = 485;\r\n this.addChild(basket_top);\r\n glass = this._basket_top = new engine.Sprite(getTextureByName('玻璃'));\r\n glass.x = (750 - glass.width) / 2;\r\n glass.y = 340;\r\n this.addChild(glass);\r\n gameData = this._gameData = new GameData(contPng, color);\r\n contPng.addChild(gameData);\r\n countDown = this._countDown = new engine.Sprite(getTextureByName('倒计时'));\r\n countDown.x = 5;\r\n countDown.y = 180;\r\n this.addChild(countDown);\r\n this._curLevelTime = getlevelTime();\r\n countDownLabel = this._countDownLabel = Tool.getLabel(this._curLevelTime, 48, \"#ffffff\");\r\n countDownLabel.x = (countDown.width - countDownLabel.width) / 2;\r\n countDownLabel.y = (countDown.height - countDownLabel.height) / 2 - 5;\r\n countDown.addChild(countDownLabel);\r\n this.initGameHint();\r\n this.startHandle();\r\n this.levelHint();\r\n return [2];\r\n });\r\n });\r\n };\r\n GameView.prototype.levelHint = function () {\r\n var lvBg = this._lvbg = new engine.Rect();\r\n lvBg.fillColor = 0x000000;\r\n lvBg.alpha = 0.7;\r\n lvBg.width = 750;\r\n lvBg.height = 1624;\r\n lvBg.x = lvBg.y = 0;\r\n lvBg.visible = false;\r\n this.addChild(lvBg);\r\n var lv_common = this._lv_common = new engine.Sprite(getTextureByName('lv_common'));\r\n lv_common.x = (750 - lv_common.width) / 2;\r\n lv_common.y = 500;\r\n lv_common.visible = false;\r\n this.addChild(lv_common);\r\n var lv1 = this._lv = new engine.Sprite(getTextureByName('lv1'));\r\n lv1.anchorTexture.set(0.5, 0.5);\r\n lv1.x = lv_common.width / 2;\r\n lv1.y = 80;\r\n lv_common.addChild(lv1);\r\n var lv1_label = this._lv_label = Tool.getLabel(\"5\", 38, \"#28c1ec\", true, engine.TEXT_ALIGN.CENTER);\r\n lv1_label.width = 100;\r\n lv1_label.x = 205;\r\n lv1_label.y = 205;\r\n lv1_label.fillColor = 0xffffff;\r\n lv_common.addChild(lv1_label);\r\n };\r\n GameView.prototype.initGameHint = function () {\r\n var awesome = new engine.Sprite(getTextureByName('awesome'));\r\n awesome.anchorTexture.set(0.5, 0.5);\r\n awesome.x = 520;\r\n awesome.y = 490;\r\n awesome.alpha = 0;\r\n this.addChild(awesome);\r\n this.gameHint['awesome'] = awesome;\r\n var cool = new engine.Sprite(getTextureByName('cool'));\r\n cool.anchorTexture.set(0.5, 0.5);\r\n cool.x = 520;\r\n cool.y = 490;\r\n cool.alpha = 0;\r\n this.addChild(cool);\r\n this.gameHint['cool'] = cool;\r\n var good = new engine.Sprite(getTextureByName('good'));\r\n good.anchorTexture.set(0.5, 0.5);\r\n good.x = 520;\r\n good.y = 490;\r\n good.alpha = 0;\r\n this.addChild(good);\r\n this.gameHint['good'] = good;\r\n var great = new engine.Sprite(getTextureByName('great'));\r\n great.anchorTexture.set(0.5, 0.5);\r\n great.x = 520;\r\n great.y = 490;\r\n great.alpha = 0;\r\n this.addChild(great);\r\n this.gameHint['great'] = great;\r\n var perfect = new engine.Sprite(getTextureByName('perfect'));\r\n perfect.anchorTexture.set(0.5, 0.5);\r\n perfect.x = 530;\r\n perfect.y = 490;\r\n perfect.alpha = 0;\r\n this.addChild(perfect);\r\n this.gameHint['perfect'] = perfect;\r\n var unbelievable = new engine.Sprite(getTextureByName('unbelievable'));\r\n unbelievable.anchorTexture.set(0.5, 0.5);\r\n unbelievable.x = 480;\r\n unbelievable.y = 460;\r\n unbelievable.alpha = 0;\r\n this.addChild(unbelievable);\r\n this.gameHint['unbelievable'] = unbelievable;\r\n };\r\n GameView.prototype.startNextLevel = function () {\r\n this.clearAwardBody();\r\n this.playLevelAni();\r\n setTouchEnabled(true);\r\n createItems(this);\r\n this._gameData.scorePosUpdate();\r\n this._gameData.resetMask();\r\n this._gameData.levelUpdate();\r\n this._curLevelTime = getlevelTime();\r\n this._countDownLabel.text = this._curLevelTime;\r\n this._countDownLabel.x = (this._countDown.width - this._countDownLabel.width) / 2;\r\n this.runEngine();\r\n };\r\n GameView.prototype.themeChange = function (data) {\r\n this._countDown.texture = engine.Texture.fromImage(data.gameCountdownImage);\r\n this._leftBtn.texture = engine.Texture.fromImage(data.leftButtonImage);\r\n this._leftBtn.anchorY = this._leftBtn.height - 50;\r\n this._leftBtn.x = 83;\r\n this._leftBtn.y = 920;\r\n this._rightBtn.texture = engine.Texture.fromImage(data.rightButtonImage);\r\n this._rightBtn.anchorY = this._rightBtn.height - 50;\r\n this._rightBtn.x = 400;\r\n this._rightBtn.y = 920;\r\n };\r\n GameView.prototype.revive = function () {\r\n setTouchEnabled(true);\r\n this.runEngine();\r\n };\r\n GameView.prototype.startHandle = function () {\r\n var engineMatter = Matter.Engine.create();\r\n this._engine = engineMatter;\r\n this._engine.world.gravity.y = 0.2;\r\n this.egretRenderContainer = new engine.Sprite();\r\n this.addChild(this.egretRenderContainer);\r\n this._egretRender = new EgretRender(this.egretRenderContainer, this._engine);\r\n var options = {\r\n width: 750,\r\n height: 1624,\r\n wireframes: !1,\r\n };\r\n var render = Matter.Render.create({\r\n element: document.getElementById('debugCanvas'),\r\n engine: engineMatter,\r\n options: options\r\n });\r\n Matter.Render.run(render);\r\n this.runGame();\r\n };\r\n GameView.prototype.runGame = function () {\r\n var _this = this;\r\n createBox(this);\r\n Matter.Events.on(this._engine, 'beforeUpdate', function () {\r\n if (!_this.addForce)\r\n return;\r\n _this.addForce = false;\r\n var isleft = _this.stageX < 375;\r\n var start = isleft ? { x: 180, y: 1050 } : { x: 560, y: 1050 };\r\n var scale = 2.2;\r\n for (var i = 0; i < 15; i++) {\r\n setTimeout(function () {\r\n var r = _this.random(10, 14);\r\n var bubblePic;\r\n bubblePic = createBubblePic(r);\r\n var basex = 0.02;\r\n var xoffset = 0.007;\r\n var fx = isleft ? _this.random(-basex, basex) : _this.random(-basex, basex);\r\n var padding = 50;\r\n var startx = _this.random(start.x - padding, start.x + padding);\r\n if (fx < -xoffset || fx > xoffset)\r\n bubblePic = null;\r\n var body = _this._egretRender.circle(startx, start.y, r, bubblePic, {\r\n density: 0.001 * 3,\r\n restitution: 1,\r\n force: { x: fx * scale, y: -0.02 * scale },\r\n collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }\r\n });\r\n setTimeout(function () {\r\n _this._egretRender.remove(body);\r\n }, 1000);\r\n }, Math.random() * 200);\r\n }\r\n var _loop_1 = function (j) {\r\n var start_1 = isleft ? { x: 180 + 50, y: 1050 + 30 } : { x: 560 - 50, y: 1050 + 30 };\r\n var r = _this.random(10, 14);\r\n var body = _this._egretRender.circle(start_1.x, start_1.y, r, null, {\r\n density: 0.001 * 3,\r\n restitution: 1,\r\n force: { x: (isleft ? 1 : -1) * 0.02 * 1.7, y: 0 },\r\n collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }\r\n });\r\n setTimeout(function () {\r\n _this._egretRender.remove(body);\r\n }, 1000);\r\n };\r\n for (var j = 0; j < 1; j++) {\r\n _loop_1();\r\n }\r\n });\r\n this._leftBtn.addEventListener(engine.MouseEvent.CLICK, function (e) {\r\n if (!getTouchEnabled())\r\n return;\r\n _this.addForce = true;\r\n _this.stageX = e.stageX;\r\n stopStandbyBubblesLeft();\r\n clearTimeout(_this._startStandbyBubblesLeft);\r\n _this._startStandbyBubblesLeft = setTimeout(function () {\r\n startStandbyBubblesLeft(_this._egretRender);\r\n }, 1000);\r\n }, this);\r\n this._rightBtn.addEventListener(engine.MouseEvent.CLICK, function (e) {\r\n if (!getTouchEnabled())\r\n return;\r\n _this.addForce = true;\r\n _this.stageX = e.stageX;\r\n stopStandbyBubblesRight();\r\n clearTimeout(_this._startStandbyBubblesRight);\r\n _this._startStandbyBubblesRight = setTimeout(function () {\r\n startStandbyBubblesRight(_this._egretRender);\r\n }, 1000);\r\n }, this);\r\n createBtns(this);\r\n startStandbyBubblesLeft(this._egretRender);\r\n startStandbyBubblesRight(this._egretRender);\r\n };\r\n GameView.prototype.enterFrame = function () {\r\n var now = Date.now();\r\n var deltaTime = this.lastTime ? now - this.lastTime : 16.7;\r\n this.lastTime = now;\r\n this._frameCount += deltaTime;\r\n if (this._frameCount >= 1000) {\r\n this._frameCount = 0;\r\n this.updateCountDown();\r\n }\r\n if (deltaTime > 20)\r\n deltaTime = 20;\r\n Matter.Engine.update(this._engine, deltaTime);\r\n this._egretRender.run();\r\n check(this);\r\n return false;\r\n };\r\n GameView.prototype.random = function (start, end) {\r\n var n = end - start;\r\n return Math.random() * n + start;\r\n };\r\n GameView.prototype.runEngine = function () {\r\n engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);\r\n };\r\n GameView.prototype.updateCountDown = function () {\r\n this._curLevelTime--;\r\n this._countDownLabel.text = this._curLevelTime;\r\n this._countDownLabel.x = (this._countDown.width - this._countDownLabel.width) / 2;\r\n if (this._curLevelTime <= 0) {\r\n this.end();\r\n console.log('时间结束');\r\n }\r\n };\r\n GameView.prototype.onBoom = function () {\r\n this.end();\r\n };\r\n GameView.prototype.addScore = function () {\r\n addScore(1);\r\n if (getScore() >= getlevelMax()) {\r\n setTouchEnabled(false);\r\n engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);\r\n engine.globalEvent.dispatchEvent('seabed-game-success', { level: getCurLevel(), score: getScore() });\r\n }\r\n this._gameData.scorePosUpdate();\r\n };\r\n GameView.prototype.playLevelAni = function () {\r\n var _this = this;\r\n var lv = getCurLevel();\r\n this._lv.texture = getTextureByName(\"lv\" + lv);\r\n this._lv_label.text = getlevelMax() + '';\r\n this._lvbg.visible = true;\r\n this._lv_common.visible = true;\r\n engine.Tween.get(this._lv_common).set({ y: 500 - 1624 }).to({ y: 500 }, 700, engine.Ease.backOut)\r\n .wait(1000).to({ y: 1624 + 500 }, 500, engine.Ease.backIn)\r\n .call(function () {\r\n _this._lvbg.visible = false;\r\n });\r\n };\r\n GameView.prototype.clearAwardBody = function () {\r\n var _this = this;\r\n var bodies = Matter.Composite.allBodies(this._engine.world);\r\n var isAward = function (i) { return i.collisionFilter.group == award; };\r\n bodies.forEach(function (i) {\r\n if (isAward(i))\r\n _this._egretRender.remove(i);\r\n });\r\n };\r\n GameView.prototype.end = function () {\r\n engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);\r\n engine.globalEvent.dispatchEvent('seabed-game-fail', { level: getCurLevel(), score: getScore(), time: this._curLevelTime });\r\n setTouchEnabled(false);\r\n };\r\n return GameView;\r\n }(engine.Container));\r\n //# sourceMappingURL=GameView.js.map\n\n var GameWrapper = (function (_super) {\r\n tslib.__extends(GameWrapper, _super);\r\n function GameWrapper() {\r\n var _this = _super.call(this) || this;\r\n engine.globalEvent.addEventListener('seabed-game-start', _this.start, _this);\r\n engine.globalEvent.addEventListener('seabed-game-revive', _this.revive, _this);\r\n engine.globalEvent.addEventListener('seabed-game-startNextLevel', _this.startNextLevel, _this);\r\n engine.globalEvent.addEventListener('seabed-game-themeChange', _this.themeChange, _this);\r\n var gameView = _this._gameView = new GameView();\r\n _this.addChild(gameView);\r\n return _this;\r\n }\r\n GameWrapper.prototype.start = function (event) {\r\n setlevelData();\r\n this.initData();\r\n this._gameView.start(event.data.color);\r\n ['coin', 'boom', 'fail', 'success'].forEach(function (element) {\r\n getJsonAsset(element);\r\n });\r\n };\r\n GameWrapper.prototype.startNextLevel = function (event) {\r\n setScore(0);\r\n setCurLevel(parseInt(event.data.level));\r\n this._gameView.startNextLevel();\r\n };\r\n GameWrapper.prototype.initData = function () {\r\n setScore(0);\r\n setCurLevel(1);\r\n };\r\n GameWrapper.prototype.revive = function () {\r\n this._gameView.revive();\r\n };\r\n GameWrapper.prototype.themeChange = function (event) {\r\n this._gameView.themeChange(event.data.resData);\r\n };\r\n return GameWrapper;\r\n }(engine.Container));\n\n function index (props) {\r\n prepareProps();\r\n injectProps(props);\r\n var instance = new GameWrapper();\r\n return instance;\r\n }\r\n //# sourceMappingURL=index.js.map\n\n return index;\n\n})));\n"
}
......@@ -47,37 +47,40 @@
var turnTableNode = this._turnTableNode = new engine.Container();
this.addChild(turnTableNode);
for (var index_Y = 0; index_Y < 3; index_Y++) {
var _loop_1 = function (index_X) {
for (var index_X = 0; index_X < 3; index_X++) {
if (index_X == 1 && index_Y == 1)
return "continue";
continue;
var tmpNode = new engine.Container();
var unchecked = this_1.getImage('unchecked', 1);
var checked = this_1.getImage('checked', 0);
var unchecked = this.getImage('unchecked', 1);
var checked = this.getImage('checked', 0);
tmpNode.width = Math.max(unchecked.width, checked.width);
this_1._singleNodeWidth = this_1._singleNodeWidth ? this_1._singleNodeWidth : tmpNode.width;
this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;
tmpNode.height = Math.max(unchecked.height, checked.height);
tmpNode.x = index_X * (tmpNode.width + this_1._horizontal_X);
tmpNode.y = index_Y * (tmpNode.height + this_1._vertical_Y);
tmpNode.x = index_X * (tmpNode.width + this._horizontal_X);
tmpNode.y = index_Y * (tmpNode.height + this._vertical_Y);
checked.x = (tmpNode.width - checked.width) / 2;
checked.y = (tmpNode.height - checked.height) / 2;
unchecked.x = (tmpNode.width - unchecked.width) / 2;
unchecked.y = (tmpNode.height - unchecked.height) / 2;
if (props.layer) {
tmpNode.addChild(checked);
tmpNode.addChild(unchecked);
}
else {
tmpNode.addChild(unchecked);
tmpNode.addChild(checked);
}
turnTableNode.addChild(tmpNode);
var tmpTexture = engine.Texture.fromImage(res[this_1._prizeIndex].img, undefined);
var prizeID = res[this_1._prizeIndex].id;
tmpTexture.addEventListener('loaded', function () {
var prize = new engine.Sprite(tmpTexture);
var prize = new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img));
var prizeID = res[this._prizeIndex].id;
prize.width = props.icon_width;
prize.height = props.icon_height;
prize.x = (tmpNode.width - prize.width) / 2 + props.icon_X;
prize.y = (tmpNode.height - prize.height) / 2 + props.icon_Y;
tmpNode.prizeID = prizeID;
tmpNode.addChild(prize);
}, this_1);
this_1._prizeIndex++;
this_1._boxArray.push(tmpNode);
};
var this_1 = this;
for (var index_X = 0; index_X < 3; index_X++) {
_loop_1(index_X);
this._prizeIndex++;
this._boxArray.push(tmpNode);
}
}
turnTableNode.x = (750 - (this._singleNodeWidth * 3 + this._horizontal_X * 2)) / 2;
......@@ -188,7 +191,6 @@
};
return Turntable;
}(engine.Container));
//# sourceMappingURL=turntable.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
......
{"version":3,"file":"index.js","sources":["src/custom/jiugong-turntable/src/game/utils.ts","src/custom/jiugong-turntable/src/props.ts","src/custom/jiugong-turntable/src/game/turntable.ts","src/custom/jiugong-turntable/src/game/GameView.ts","src/custom/jiugong-turntable/src/game/GameWrapper.ts","src/custom/jiugong-turntable/src/index.ts"],"sourcesContent":["\r\n/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function getStage(){\r\n\treturn engine.gameStage.stage;\r\n}","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","\r\nimport {getTextureByName} from \"./utils\";\r\nimport {getStage} from \"./utils\";\r\n\r\nimport { props } from '../props';\r\n\r\nexport class Turntable extends engine.Container{\r\n private _turnTableNode;\r\n private _vertical_Y = props.vertical || 20;//纵向间距\r\n private _horizontal_X = props.horizontal || 20;//横向间距\r\n private _prizeIndex = 0;\r\n\r\n private _boxArray = [];\r\n private _boxIndex = 0;//当前下标\r\n\r\n private tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n private slowTweenTime = props.slowTweenTime || 200;\r\n private circleNumber = 0;//圈数\r\n\r\n private turntableOrder = [1,2,3,5,8,7,6,4]; \r\n private recordID = -1;//中奖奖品ID\r\n private boxPrizeIndex = -1;//中奖奖品节点下标 \r\n private slowDown = false;//是否开始缓速\r\n private isStop = false;\r\n\r\n private _singleNodeWidth;//单个节点宽度\r\n constructor(res){\r\n super()\r\n this.initTurntable(res);\r\n this.setNodeOrder();\r\n }\r\n initTurntable(res){\r\n let turnTableNode = this._turnTableNode = new engine.Container();\r\n //turnTableNode.y = 50;\r\n this.addChild(turnTableNode);\r\n for (let index_Y = 0; index_Y < 3; index_Y++) {\r\n for (let index_X = 0; index_X < 3; index_X++) { \r\n if(index_X == 1 && index_Y == 1)continue;\r\n let tmpNode:any = new engine.Container()\r\n\r\n let unchecked = this.getImage('unchecked',1);\r\n let checked = this.getImage('checked',0);\r\n\r\n tmpNode.width = Math.max(unchecked.width,checked.width);\r\n this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;\r\n tmpNode.height = Math.max(unchecked.height,checked.height);\r\n tmpNode.x = index_X*(tmpNode.width + this._horizontal_X);\r\n tmpNode.y = index_Y*(tmpNode.height + this._vertical_Y);\r\n tmpNode.addChild(unchecked);\r\n tmpNode.addChild(checked);\r\n turnTableNode.addChild(tmpNode);\r\n\r\n let tmpTexture:engine.Texture = engine.Texture.fromImage(res[this._prizeIndex].img,undefined);\r\n let prizeID = res[this._prizeIndex].id;\r\n tmpTexture.addEventListener('loaded',()=>{\r\n let prize = new engine.Sprite(tmpTexture);\r\n prize.width = props.icon_width;\r\n prize.height = props.icon_height;\r\n prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;\r\n prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;\r\n tmpNode.prizeID = prizeID;\r\n tmpNode.addChild(prize);\r\n },this)\r\n this._prizeIndex ++ ;\r\n this._boxArray.push(tmpNode); \r\n }\r\n }\r\n turnTableNode.x = (750 - (this._singleNodeWidth*3 + this._horizontal_X*2))/2;\r\n }\r\n\r\n setNodeOrder(){\r\n let tmpNodeArray = [];\r\n for (let index = 0; index < this.turntableOrder.length; index++) {\r\n let order = this.turntableOrder[index];\r\n tmpNodeArray.push(this._boxArray[order-1]);\r\n }\r\n this._boxArray = tmpNodeArray;\r\n }\r\n\r\n getImage(resName,alpha){\r\n let tmpImage = new engine.Sprite(getTextureByName(resName));\r\n tmpImage.x = 0\r\n tmpImage.y = 0\r\n tmpImage.alpha = alpha;\r\n tmpImage.name = resName;\r\n return tmpImage;\r\n }\r\n startDraw(){\r\n let tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');\r\n if(this.isStop){engine.Tween.removeTweens(tmpCheckNode);return}\r\n if(this.slowDown)\r\n {\r\n if(this._boxIndex != this.getNodeIndexOFprize()){\r\n this.tweenTime += this.slowTweenTime;\r\n }else{\r\n this.isStop = true;\r\n this.twinkle(tmpCheckNode);\r\n }\r\n }\r\n engine.Tween.get(tmpCheckNode)\r\n .to({alpha:1},this.tweenTime/2)\r\n .to({alpha:0},this.tweenTime/2)\r\n .call(()=>{\r\n if(this.circleNumber >= props.circleNumber && this.getSlowStart() == this._boxIndex){\r\n this.slowDown = true;\r\n }\r\n this._boxIndex ++;\r\n if(this._boxIndex >= this._boxArray.length){\r\n this._boxIndex = 0;\r\n this.circleNumber++;\r\n }\r\n \r\n this.startDraw();\r\n \r\n \r\n })\r\n }\r\n //获取开始减速的下标\r\n private getSlowStart(){\r\n if(this.recordID < 0)return -1;\r\n let tmpIndex = this.getNodeIndexOFprize();\r\n if(tmpIndex < 4){\r\n return tmpIndex + 4;\r\n }else{\r\n return tmpIndex - 4\r\n }\r\n }\r\n //获取奖品节点下标\r\n getNodeIndexOFprize(){\r\n if(this.recordID < 0)return -1;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n if(element.prizeID === this.recordID){\r\n return index;\r\n } \r\n }\r\n return -1;\r\n }\r\n //中奖节点闪烁\r\n twinkle(tmpNode){\r\n engine.Tween.removeTweens(tmpNode)\r\n let twinkleTime = 1;\r\n engine.Tween.get(tmpNode, {loop:true})\r\n .to({alpha:0}, 30)\r\n .to({alpha:1}, 30)\r\n .call(()=>{\r\n if(twinkleTime > 5){\r\n engine.Tween.removeTweens(tmpNode);\r\n engine.globalEvent.dispatchEvent('jiugong-turntable-over')\r\n return;\r\n }else{\r\n twinkleTime++;\r\n }\r\n })\r\n }\r\n setRecordID(prizeID){\r\n this.recordID = prizeID;\r\n }\r\n reset(){\r\n engine.Tween.removeAllTweens();\r\n this._boxIndex = 0;//当前下标\r\n this.tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n this.slowTweenTime = props.slowTweenTime || 200;\r\n this.circleNumber = 0;//圈数\r\n this.recordID = -1;//中奖奖品ID\r\n this.boxPrizeIndex = -1;//中奖奖品节点下标 \r\n this.slowDown = false;//是否开始缓速\r\n this.isStop = false;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n element.getChildByName('checked').alpha = 0;\r\n }\r\n \r\n }\r\n\r\n}","\r\n/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport {props} from \"../props\";\r\nimport { Turntable } from \"./turntable\";\r\n\r\n\r\n\r\n\r\n\r\nexport default class GameView extends engine.Container {\r\n\r\n\t\r\n\tprivate _hasSetup;\r\n\tprivate _turntable:Turntable;\r\n\tconstructor() {\r\n\t\tsuper();\t\r\n\t}\r\n\t setup(res){\r\n\t\tif (this._hasSetup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._hasSetup = true;\r\n\t\t\r\n\t\tlet turntable = this._turntable = new Turntable(res);\r\n\t\tthis.addChild(turntable);\r\n\t}\r\n\tstartDraw(){\r\n\t\tthis._turntable.startDraw();\r\n\t}\r\n\tsetRecordID(prizeID){\r\n\t\tthis._turntable.setRecordID(prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._turntable.reset();\r\n\t}\r\n}\r\n","\r\n\r\nimport { props } from './../props';\r\n\r\n\r\n/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\tprivate _gameView: GameView;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-init', this.init, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-start', this.start, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-winPrize', this.winPrize, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-reset', this.reset, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-abnormal', this.reset, this);\r\n\t}\r\n\r\n\tinit(event: engine.Event) {\r\n\t\t//初始化场景\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\t\tconsole.log('奖品图',event.data.resources); \r\n\t\tthis._gameView.setup(event.data.resources);\r\n\t}\r\n\r\n\t//开始抽奖\r\n\tstart(event: engine.Event){\r\n\t\tthis._gameView.startDraw();\r\n\t}\r\n\twinPrize(event: engine.Event){\r\n\t\tthis._gameView.setRecordID(event.data.prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._gameView.reset();\r\n\t}\r\n\t// private visibilitychange(){\r\n\t// \tdocument.addEventListener('visibilitychange', function () {\r\n // if (document.visibilityState === 'hidden') {\r\n\t// \t\t\tconsole.log('放置后台');\r\n\t// \t\t\tengine.globalEvent.dispatchEvent('answer-game-visibilitychange',{hidden:true});\r\n // }\r\n // });\r\n\t// }\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":"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"}
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/jiugong-turntable/src/game/utils.ts","src/custom/jiugong-turntable/src/props.ts","src/custom/jiugong-turntable/src/game/turntable.ts","src/custom/jiugong-turntable/src/game/GameView.ts","src/custom/jiugong-turntable/src/game/GameWrapper.ts","src/custom/jiugong-turntable/src/index.ts"],"sourcesContent":["\r\n/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function getStage(){\r\n\treturn engine.gameStage.stage;\r\n}","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","\r\nimport {getTextureByName} from \"./utils\";\r\nimport {getStage} from \"./utils\";\r\n\r\nimport { props } from '../props';\r\n\r\nexport class Turntable extends engine.Container{\r\n private _turnTableNode;\r\n private _vertical_Y = props.vertical || 20;//纵向间距\r\n private _horizontal_X = props.horizontal || 20;//横向间距\r\n private _prizeIndex = 0;\r\n\r\n private _boxArray = [];\r\n private _boxIndex = 0;//当前下标\r\n\r\n private tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n private slowTweenTime = props.slowTweenTime || 200;\r\n private circleNumber = 0;//圈数\r\n\r\n private turntableOrder = [1,2,3,5,8,7,6,4]; \r\n private recordID = -1;//中奖奖品ID\r\n private boxPrizeIndex = -1;//中奖奖品节点下标 \r\n private slowDown = false;//是否开始缓速\r\n private isStop = false;\r\n\r\n private _singleNodeWidth;//单个节点宽度\r\n constructor(res){\r\n super()\r\n this.initTurntable(res);\r\n this.setNodeOrder();\r\n }\r\n initTurntable(res){\r\n let turnTableNode = this._turnTableNode = new engine.Container();\r\n //turnTableNode.y = 50;\r\n this.addChild(turnTableNode);\r\n for (let index_Y = 0; index_Y < 3; index_Y++) {\r\n for (let index_X = 0; index_X < 3; index_X++) { \r\n if(index_X == 1 && index_Y == 1)continue;\r\n let tmpNode:any = new engine.Container()\r\n\r\n let unchecked = this.getImage('unchecked',1);\r\n let checked = this.getImage('checked',0);\r\n \r\n tmpNode.width = Math.max(unchecked.width,checked.width);\r\n this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;\r\n \r\n tmpNode.height = Math.max(unchecked.height,checked.height);\r\n tmpNode.x = index_X*(tmpNode.width + this._horizontal_X);\r\n tmpNode.y = index_Y*(tmpNode.height + this._vertical_Y);\r\n\r\n checked.x = (tmpNode.width -checked.width)/2\r\n checked.y = (tmpNode.height -checked.height)/2\r\n\r\n unchecked.x = (tmpNode.width -unchecked.width)/2\r\n unchecked.y = (tmpNode.height -unchecked.height)/2\r\n\r\n if(props.layer){\r\n \r\n tmpNode.addChild(checked);\r\n tmpNode.addChild(unchecked);\r\n \r\n }else{\r\n tmpNode.addChild(unchecked);\r\n tmpNode.addChild(checked);\r\n }\r\n\r\n turnTableNode.addChild(tmpNode);\r\n\r\n // let tmpTexture:engine.Texture = engine.Texture.fromImage(res[this._prizeIndex].img,undefined);\r\n // let prizeID = res[this._prizeIndex].id;\r\n // tmpTexture.addEventListener('loaded',()=>{\r\n // let prize = new engine.Sprite(tmpTexture);\r\n // prize.width = props.icon_width;\r\n // prize.height = props.icon_height;\r\n // prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;\r\n // prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;\r\n // tmpNode.prizeID = prizeID;\r\n // tmpNode.addChild(prize);\r\n // },this)\r\n\r\n let prize =new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img)) ;\r\n let prizeID = res[this._prizeIndex].id;\r\n prize.width = props.icon_width;\r\n prize.height = props.icon_height;\r\n prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;\r\n prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;\r\n tmpNode.prizeID = prizeID;\r\n tmpNode.addChild(prize);\r\n\r\n this._prizeIndex ++ ;\r\n this._boxArray.push(tmpNode); \r\n }\r\n }\r\n turnTableNode.x = (750 - (this._singleNodeWidth*3 + this._horizontal_X*2))/2;\r\n }\r\n\r\n setNodeOrder(){\r\n let tmpNodeArray = [];\r\n for (let index = 0; index < this.turntableOrder.length; index++) {\r\n let order = this.turntableOrder[index];\r\n tmpNodeArray.push(this._boxArray[order-1]);\r\n }\r\n this._boxArray = tmpNodeArray;\r\n }\r\n\r\n getImage(resName,alpha){\r\n let tmpImage = new engine.Sprite(getTextureByName(resName));\r\n tmpImage.x = 0\r\n tmpImage.y = 0\r\n tmpImage.alpha = alpha;\r\n tmpImage.name = resName;\r\n return tmpImage;\r\n }\r\n startDraw(){\r\n let tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');\r\n if(this.isStop){engine.Tween.removeTweens(tmpCheckNode);return}\r\n if(this.slowDown)\r\n {\r\n if(this._boxIndex != this.getNodeIndexOFprize()){\r\n this.tweenTime += this.slowTweenTime;\r\n }else{\r\n this.isStop = true;\r\n this.twinkle(tmpCheckNode);\r\n }\r\n }\r\n engine.Tween.get(tmpCheckNode)\r\n .to({alpha:1},this.tweenTime/2)\r\n .to({alpha:0},this.tweenTime/2)\r\n .call(()=>{\r\n if(this.circleNumber >= props.circleNumber && this.getSlowStart() == this._boxIndex){\r\n this.slowDown = true;\r\n }\r\n this._boxIndex ++;\r\n if(this._boxIndex >= this._boxArray.length){\r\n this._boxIndex = 0;\r\n this.circleNumber++;\r\n }\r\n \r\n this.startDraw();\r\n \r\n \r\n })\r\n }\r\n //获取开始减速的下标\r\n private getSlowStart(){\r\n if(this.recordID < 0)return -1;\r\n let tmpIndex = this.getNodeIndexOFprize();\r\n if(tmpIndex < 4){\r\n return tmpIndex + 4;\r\n }else{\r\n return tmpIndex - 4\r\n }\r\n }\r\n //获取奖品节点下标\r\n getNodeIndexOFprize(){\r\n if(this.recordID < 0)return -1;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n if(element.prizeID === this.recordID){\r\n return index;\r\n } \r\n }\r\n return -1;\r\n }\r\n //中奖节点闪烁\r\n twinkle(tmpNode){\r\n engine.Tween.removeTweens(tmpNode)\r\n let twinkleTime = 1;\r\n engine.Tween.get(tmpNode, {loop:true})\r\n .to({alpha:0}, 30)\r\n .to({alpha:1}, 30)\r\n .call(()=>{\r\n if(twinkleTime > 5){\r\n engine.Tween.removeTweens(tmpNode);\r\n engine.globalEvent.dispatchEvent('jiugong-turntable-over')\r\n return;\r\n }else{\r\n twinkleTime++;\r\n }\r\n })\r\n }\r\n setRecordID(prizeID){\r\n this.recordID = prizeID;\r\n }\r\n reset(){\r\n engine.Tween.removeAllTweens();\r\n this._boxIndex = 0;//当前下标\r\n this.tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n this.slowTweenTime = props.slowTweenTime || 200;\r\n this.circleNumber = 0;//圈数\r\n this.recordID = -1;//中奖奖品ID\r\n this.boxPrizeIndex = -1;//中奖奖品节点下标 \r\n this.slowDown = false;//是否开始缓速\r\n this.isStop = false;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n element.getChildByName('checked').alpha = 0;\r\n }\r\n \r\n }\r\n\r\n}","\r\n/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport {props} from \"../props\";\r\nimport { Turntable } from \"./turntable\";\r\n\r\n\r\n\r\n\r\n\r\nexport default class GameView extends engine.Container {\r\n\r\n\t\r\n\tprivate _hasSetup;\r\n\tprivate _turntable:Turntable;\r\n\tconstructor() {\r\n\t\tsuper();\t\r\n\t}\r\n\t setup(res){\r\n\t\tif (this._hasSetup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._hasSetup = true;\r\n\t\t\r\n\t\tlet turntable = this._turntable = new Turntable(res);\r\n\t\tthis.addChild(turntable);\r\n\t}\r\n\tstartDraw(){\r\n\t\tthis._turntable.startDraw();\r\n\t}\r\n\tsetRecordID(prizeID){\r\n\t\tthis._turntable.setRecordID(prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._turntable.reset();\r\n\t}\r\n}\r\n","\r\n\r\nimport { props } from './../props';\r\n\r\n\r\n/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\tprivate _gameView: GameView;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-init', this.init, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-start', this.start, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-winPrize', this.winPrize, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-reset', this.reset, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-abnormal', this.reset, this);\r\n\t}\r\n\r\n\tinit(event: engine.Event) {\r\n\t\t//初始化场景\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\t\tconsole.log('奖品图',event.data.resources); \r\n\t\tthis._gameView.setup(event.data.resources);\r\n\t}\r\n\r\n\t//开始抽奖\r\n\tstart(event: engine.Event){\r\n\t\tthis._gameView.startDraw();\r\n\t}\r\n\twinPrize(event: engine.Event){\r\n\t\tthis._gameView.setRecordID(event.data.prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._gameView.reset();\r\n\t}\r\n\t// private visibilitychange(){\r\n\t// \tdocument.addEventListener('visibilitychange', function () {\r\n // if (document.visibilityState === 'hidden') {\r\n\t// \t\t\tconsole.log('放置后台');\r\n\t// \t\t\tengine.globalEvent.dispatchEvent('answer-game-visibilitychange',{hidden:true});\r\n // }\r\n // });\r\n\t// }\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":"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"}
\ No newline at end of file
......@@ -46,6 +46,11 @@
"alias": "奖品Y轴偏移量(底框背景有透明)",
"type": "number",
"default": -20
},
"layer": {
"alias": "中奖标志是否在最下层",
"type": "boolean",
"default": false
}
},
"assets": [
......
......@@ -43,24 +43,50 @@ export class Turntable extends engine.Container{
tmpNode.width = Math.max(unchecked.width,checked.width);
this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;
tmpNode.height = Math.max(unchecked.height,checked.height);
tmpNode.x = index_X*(tmpNode.width + this._horizontal_X);
tmpNode.y = index_Y*(tmpNode.height + this._vertical_Y);
checked.x = (tmpNode.width -checked.width)/2
checked.y = (tmpNode.height -checked.height)/2
unchecked.x = (tmpNode.width -unchecked.width)/2
unchecked.y = (tmpNode.height -unchecked.height)/2
if(props.layer){
tmpNode.addChild(checked);
tmpNode.addChild(unchecked);
}else{
tmpNode.addChild(unchecked);
tmpNode.addChild(checked);
}
turnTableNode.addChild(tmpNode);
let tmpTexture:engine.Texture = engine.Texture.fromImage(res[this._prizeIndex].img,undefined);
// let tmpTexture:engine.Texture = engine.Texture.fromImage(res[this._prizeIndex].img,undefined);
// let prizeID = res[this._prizeIndex].id;
// tmpTexture.addEventListener('loaded',()=>{
// let prize = new engine.Sprite(tmpTexture);
// prize.width = props.icon_width;
// prize.height = props.icon_height;
// prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;
// prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;
// tmpNode.prizeID = prizeID;
// tmpNode.addChild(prize);
// },this)
let prize =new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img)) ;
let prizeID = res[this._prizeIndex].id;
tmpTexture.addEventListener('loaded',()=>{
let prize = new engine.Sprite(tmpTexture);
prize.width = props.icon_width;
prize.height = props.icon_height;
prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;
prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;
tmpNode.prizeID = prizeID;
tmpNode.addChild(prize);
},this)
this._prizeIndex ++ ;
this._boxArray.push(tmpNode);
}
......
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'seabed-game';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const { props: propsOption, assets } = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
customs: [],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('seabed-game-start',{color:"0x000000"});
}, 150);
});
engine.globalEvent.addEventListener('seabed-game-time-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('seabed-game-game-fail', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('seabed-game-game-success', (e) => {
console.log(e.type, e.data);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>海底游戏机</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: gray;
}
.game-container{
width: 100%;
height: 100%;
line-height:0;
font-size:0;
}
</style>
</head>
<body>
<div id="game-container" class="game-container"></div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.1de84ff79dba19e949088de63aa75af51a515e5c.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script src="matter.min.js"></script>
<script src="matter_decomp.min.js"></script>
<div id="debugCanvas" style="position:absolute;opacity: .5;pointer-events: none"></div>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae",
"ext": ".svga"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
"ext": ".svga"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global['seabed-game'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var LabelType;
(function (LabelType) {
LabelType["boom"] = "boom";
LabelType["candy"] = "candy";
LabelType["coin"] = "coin";
LabelType["gift"] = "gift";
LabelType["egg"] = "egg";
})(LabelType || (LabelType = {}));
var LabelType$1 = LabelType;
//# sourceMappingURL=LabelType.js.map
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var levels;
var setlevelData = function () {
levels = {
'1': { max: props.level_1[0], items: [[LabelType$1.boom, props.level_1[1]], [LabelType$1.coin, props.level_1[2]]], time: props.level_1[3] },
'2': { max: props.level_2[0], items: [[LabelType$1.boom, props.level_2[1]], [LabelType$1.coin, props.level_2[2]]], time: props.level_2[3] },
'3': { max: props.level_3[0], items: [[LabelType$1.boom, props.level_3[1]], [LabelType$1.coin, props.level_3[2]]], time: props.level_3[3] },
};
};
var touchEnabled = false;
var getTouchEnabled = function () {
return touchEnabled;
};
var setTouchEnabled = function (b) {
touchEnabled = b;
};
//# sourceMappingURL=GoldData.js.map
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
//# sourceMappingURL=utils.js.map
var Tool = (function () {
function Tool() {
}
Tool.getLabel = function (txt, size, color, bold, align, x, y) {
if (color === void 0) { color = "#ffffff"; }
if (bold === void 0) { bold = false; }
if (align === void 0) { align = engine.TEXT_ALIGN.LEFT; }
if (x === void 0) { x = 0; }
if (y === void 0) { y = 0; }
var label = new engine.Label();
label.fillColor = color;
label.bold = bold;
label.size = size;
label.textAlign = align;
label.x = x;
label.y = y;
label.text = txt;
return label;
};
return Tool;
}());
//# sourceMappingURL=Tools.js.map
var curScore;
function getScore() {
return curScore;
}
function addScore(addCount) {
curScore += addCount;
return curScore;
}
function setScore(scoreCount) {
curScore = scoreCount;
}
var curLevel;
function getCurLevel() {
return curLevel;
}
function setCurLevel(level) {
curLevel = level;
return curLevel;
}
var levels$1;
var setlevelData$1 = function () {
levels$1 = {
'1': { max: props.level_1[0], items: [[LabelType$1.boom, props.level_1[1]], [LabelType$1.coin, props.level_1[2]]], time: props.level_1[3] },
'2': { max: props.level_2[0], items: [[LabelType$1.boom, props.level_2[1]], [LabelType$1.coin, props.level_2[2]]], time: props.level_2[3] },
'3': { max: props.level_3[0], items: [[LabelType$1.boom, props.level_3[1]], [LabelType$1.coin, props.level_3[2]]], time: props.level_3[3] },
};
};
var getLevelData = function () {
if (!levels$1) {
setlevelData$1();
}
return levels$1[getCurLevel()];
};
var getCurrentItems = function () {
if (!levels$1) {
setlevelData$1();
}
return getLevelData().items;
};
var getlevelTime = function () {
if (!levels$1) {
setlevelData$1();
}
return getLevelData().time;
};
var getlevelMax = function () {
if (!levels$1) {
setlevelData$1();
}
return getLevelData().max;
};
//# sourceMappingURL=goldData.js.map
var GameData = (function (_super) {
tslib.__extends(GameData, _super);
function GameData(parentNode, color) {
var _this = _super.call(this) || this;
_this.starList = [];
_this._parentNode = parentNode;
_this._color = color;
_this.init();
return _this;
}
GameData.prototype.init = function () {
var scoreCount = this._scoreCount = Tool.getLabel('', 36, "#ffffff", true);
scoreCount.y = 48;
this.addChild(scoreCount);
var scorelabel = this._scorelabel = Tool.getLabel('分', 22, "#ffffff");
scorelabel.y = 56;
this.addChild(scorelabel);
var progress = new engine.Sprite(getTextureByName('进度'));
progress.x = 212;
progress.y = 8;
this.addChild(progress);
var progressMask = this._progressMask = new engine.Rect();
progressMask.fillColor = 0x000000;
progressMask.width = 245;
progressMask.height = 100;
progressMask.x = 213;
progressMask.y = 5;
progressMask.scaleX = 0;
this.addChild(progressMask);
progress.mask = progressMask;
var star1 = new engine.Sprite(getTextureByName('点亮'));
star1.x = 270;
star1.y = 6;
star1.visible = false;
this.addChild(star1);
this.starList.push(star1);
var star2 = new engine.Sprite(getTextureByName('点亮'));
star2.x = 365;
star2.y = 6;
star2.visible = false;
this.addChild(star2);
this.starList.push(star2);
var star3 = new engine.Sprite(getTextureByName('点亮'));
star3.x = 435;
star3.y = 50;
star3.visible = false;
this.addChild(star3);
this.starList.push(star3);
this.scorePosUpdate();
var levelLabel = this._levelLabel = Tool.getLabel('', 28, this._color || "#28c1ec", false);
levelLabel.y = 98;
this.addChild(levelLabel);
this.levelUpdate();
this.updateProgressMask();
};
GameData.prototype.scorePosUpdate = function () {
this._scoreCount.text = getScore();
this._scoreCount.x = (this._parentNode.width - this._scoreCount.width - this._scorelabel.width - 5) / 2;
this._scorelabel.x = this._scoreCount.x + this._scoreCount.width + 5;
this.updateProgressMask();
};
GameData.prototype.levelUpdate = function (color) {
this._levelLabel.text = "\u7B2C" + getCurLevel() + "/3\u5173";
this._levelLabel.x = (this._parentNode.width - this._levelLabel.width) / 2;
};
GameData.prototype.updateProgressMask = function () {
var ratio = getScore() / getlevelMax();
this._progressMask.scaleX = ratio;
if (ratio >= 0.35) {
this.starList[0].visible = true;
}
if (ratio >= 0.75) {
this.starList[1].visible = true;
}
if (ratio >= 1) {
this.starList[2].visible = true;
}
};
GameData.prototype.resetMask = function () {
this.starList.forEach(function (element) {
element.visible = false;
});
};
return GameData;
}(engine.Container));
//# sourceMappingURL=gameData.js.map
var BaseItem = (function (_super) {
tslib.__extends(BaseItem, _super);
function BaseItem(mc, type) {
var _this = _super.call(this) || this;
_this.type = type;
_this._mc = mc;
var bubble = getTextureByName('bubble');
var bubblePic = new engine.Sprite(bubble);
bubblePic.anchorTexture.set(0.5, 0.5);
_this._mc.anchorTexture.set(0.5, 0.5);
_this._mc.x = bubblePic.x / 4;
_this._mc.y = bubblePic.y / 4;
_this.addChild(bubblePic);
_this.addChild(_this._mc);
return _this;
}
Object.defineProperty(BaseItem.prototype, "mc", {
get: function () { return this._mc; },
enumerable: true,
configurable: true
});
return BaseItem;
}(engine.Sprite));
//# sourceMappingURL=BaseItem.js.map
var EgretRender = (function () {
function EgretRender(root, engine) {
this._root = root;
this._engine = engine;
}
EgretRender.prototype.addBody = function (body, display, x, y) {
if (display) {
body['display'] = display;
this._root.addChildAt(display, 0);
display.x = x;
display.y = y;
}
return body;
};
EgretRender.prototype.remove = function (body) {
this.removeBody(body);
this.removeDisplay(body);
};
EgretRender.prototype.removeBody = function (body) {
Matter.World.remove(this._engine.world, body);
};
EgretRender.prototype.removeDisplay = function (body) {
var display = body['display'];
if (display && display.parent)
display.parent.removeChild(display);
};
EgretRender.prototype.run = function () {
var bodies = Matter.Composite.allBodies(this._engine.world);
for (var i = 0; i < bodies.length; i++) {
var body = bodies[i];
var display = body['display'];
if (!display)
continue;
var x1 = Math.round(display.x);
var x2 = Math.round(body.position.x);
var y1 = Math.round(display.y);
var y2 = Math.round(body.position.y);
var distanceX = Math.abs(x1 - x2);
var distanceY = Math.abs(y1 - y2);
var precision = 1;
if (distanceX > precision || distanceY > precision) {
if (display instanceof BaseItem)
display.mc.resume();
}
else {
if (display instanceof BaseItem)
display.mc.pause();
}
display.x = body.position.x;
display.y = body.position.y;
display.rotation = this.getRotation(body.angle);
}
};
EgretRender.prototype.rectangle = function (x, y, width, height, display, options) {
var body = this.rectangleToRender(x, y, width, height, display, options);
this.addBodyToWorld(body);
return body;
};
EgretRender.prototype.circle = function (x, y, radius, display, options) {
var body = this.circleToRender(x, y, radius, display, options);
this.addBodyToWorld(body);
return body;
};
EgretRender.prototype.addBodyToWorld = function (body) {
Matter.World.add(this._engine.world, body);
return body;
};
EgretRender.prototype.rectangleToRender = function (x, y, width, height, display, options) {
var body = Matter.Bodies.rectangle(x, y, width, height, options);
this.addBody(body, display, x, y);
return body;
};
EgretRender.prototype.circleToRender = function (x, y, radius, display, options) {
var body = Matter.Bodies.circle(x, y, radius, options);
this.addBody(body, display, x, y);
return body;
};
EgretRender.prototype.getRotation = function (angle) {
return angle / Math.PI / 2 * 360;
};
return EgretRender;
}());
//# sourceMappingURL=EgretRender.js.map
var wall = 1;
var basket = 2;
var award = 4;
var bubble = 8;
var bubbleStandby = 16;
var bubbleGroup = -1;
var bubbleStandbyGroup = -2;
var wallMask = award + bubble + bubbleStandby;
var basketMask = award + bubble + bubbleStandby;
var awardMask = wall + basket + bubble;
var bubbleMask = wall + basket + award;
var bubbleStandbyMask = wall + basket;
//# sourceMappingURL=collisionConfig.js.map
var vibrate = (function (view, count, strength) {
if (count === void 0) { count = 2; }
if (strength === void 0) { strength = 10; }
return new Promise(function (r) {
var pos = [
{ x: strength, y: 0 },
{ x: 0, y: -strength },
{ x: -strength, y: 0 },
{ x: 0, y: strength },
{ x: 0, y: 0 },
];
var list = [];
for (var i = 0; i < count; i++) {
list = list.concat(pos);
}
var x0 = view.x;
var y0 = view.y;
var counter = list.length;
var _loop_1 = function (i) {
var element = list[i];
setTimeout(function () {
view.x = element.x + x0;
view.y = element.y + y0;
counter--;
if (counter == 0) {
view.x = x0;
view.y = y0;
r();
}
}, 1000 / 60 * i);
};
for (var i = 0; i < list.length; i++) {
_loop_1(i);
}
});
});
//# sourceMappingURL=vibrate.js.map
var MovieClip = (function (_super) {
tslib.__extends(MovieClip, _super);
function MovieClip(_a) {
var spritesheet = _a.spritesheet, frames = _a.frames, scale = _a.scale, position = _a.position, _b = _a.keys, keys = _b === void 0 ? null : _b, _c = _a.autoplay, autoplay = _c === void 0 ? true : _c, _d = _a.loop, loop = _d === void 0 ? true : _d, anchor = _a.anchor, _e = _a.frameInterval, frameInterval = _e === void 0 ? 1 : _e, _f = _a.callBack, callBack = _f === void 0 ? null : _f;
var _this = _super.call(this) || this;
_this.frames = frames;
_this.frameInterval = frameInterval;
_this.keys = keys;
_this.autoplay = autoplay;
_this.loop = loop;
_this.anchorXtmp = anchor;
_this.anchorYtmp = anchor;
_this._callBack = callBack;
if (Array.isArray(anchor)) {
_this.anchorXtmp = anchor[0];
_this.anchorYtmp = anchor[1];
}
_this.x = position[0];
_this.y = position[1];
_this.spritesheet = spritesheet;
if (_this.autoplay) {
_this.play();
}
_this.scaleX = _this.scaleY = scale;
return _this;
}
MovieClip.prototype.pause = function () {
this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this);
};
MovieClip.prototype.resume = function () {
this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this);
};
MovieClip.prototype.play = function (start) {
if (start === void 0) { start = 0; }
this.goto(start);
this.currentFrame = 0;
this.counter = 0;
this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this);
};
MovieClip.prototype.goto = function (frame) {
this.texture = this.textures[frame];
};
MovieClip.prototype.onTick = function () {
this.counter++;
if (this.counter == this.frameInterval) {
this.counter = 0;
this.currentFrame++;
this.goto(this.currentFrame);
if (this.currentFrame == this.frames.length - 1) {
if (this.loop) {
this.currentFrame = 0;
}
else {
this.stop();
if (this._callBack) {
this._callBack();
this._callBack = null;
}
}
}
}
return false;
};
MovieClip.prototype.stop = function () {
this.currentFrame = 0;
this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this);
};
Object.defineProperty(MovieClip.prototype, "spritesheet", {
set: function (value) {
this.textures = this.frames.map(function (frame) { return value[frame]; });
this.anchorTexture.set(this.anchorXtmp, this.anchorYtmp);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MovieClip.prototype, "textureItemWidth", {
get: function () { return this.textures[0].width; },
enumerable: true,
configurable: true
});
Object.defineProperty(MovieClip.prototype, "textureItemHeight", {
get: function () { return this.textures[0].height; },
enumerable: true,
configurable: true
});
return MovieClip;
}(engine.Image));
//# sourceMappingURL=MovieClip.js.map
var wait = function (duration) { return tslib.__awaiter(void 0, void 0, void 0, function () {
return tslib.__generator(this, function (_a) {
return [2, new Promise(function (resolve) { return setTimeout(resolve, duration); })];
});
}); };
//# sourceMappingURL=wait.js.map
var josnData = {};
function getJsonAsset(name) {
var config = engine.getAssetByName(name + '_json');
var tmpJosnData = engine.globalLoader.get(config.uuid);
if (tmpJosnData) {
josnData[name] = convert(tmpJosnData);
}
}
function convert(data) {
var frames = data.frames;
var jsonName = data.file.split('.')[0];
var obj = {};
for (var key in frames) {
var f = frames[key];
obj[jsonName + key + ".png"] = {
"x": f.x,
"y": f.y,
"w": f.w,
"h": f.h,
"ox": f.offX,
"oy": f.offY,
"sw": f.sourceW,
"sh": f.sourceH,
"ro": false,
};
}
return obj || null;
}
function getJosnData(jsonName) {
return josnData[jsonName] || null;
}
//# sourceMappingURL=JsonTools.js.map
function createTextureSheet(baseTexture, altaData) {
var frames = altaData;
var frameKeys = Object.keys(frames);
var frameIndex = 0;
var textures = {};
while (frameIndex < frameKeys.length) {
var i = frameKeys[frameIndex];
var data = frames[i];
var frame = null;
var trim = null;
var orig = new engine.Rectangle(0, 0, Math.floor(data.sw), Math.floor(data.sh));
if (data.ro) {
frame = new engine.Rectangle(Math.floor(data.x), Math.floor(data.y), Math.floor(data.h), Math.floor(data.w));
}
else {
frame = new engine.Rectangle(Math.floor(data.x), Math.floor(data.y), Math.floor(data.w), Math.floor(data.h));
}
if (data.ox || data.oy) {
trim = new engine.Rectangle(Math.floor(data.ox), Math.floor(data.oy), Math.floor(data.w), Math.floor(data.h));
}
var texture = new engine.Texture(baseTexture, frame, orig, trim, data.ro ? 2 : 0);
engine.Texture.addToCache(texture, i);
textures[i] = texture;
frameIndex++;
}
return textures;
}
//# sourceMappingURL=createTextureSheet.js.map
function playMovieClip(parent, key, frames, frameInterval) {
if (frameInterval === void 0) { frameInterval = 5; }
return tslib.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib.__generator(this, function (_a) {
return [2, new Promise(function (r) { return tslib.__awaiter(_this, void 0, void 0, function () {
var josnData, texture;
var _this = this;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
josnData = getJosnData(key);
if (!josnData) {
getJsonAsset(key);
josnData = getJosnData(key);
}
texture = createTextureSheet(getTextureByName(key).baseTexture, josnData);
if (!texture) return [3, 2];
return [4, createMc(parent, texture, frames, frameInterval)];
case 1:
_a.sent();
r(1);
return [3, 3];
case 2:
wait(300).then(function () { return tslib.__awaiter(_this, void 0, void 0, function () {
var josnData;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
josnData = getJosnData(key);
if (!josnData) {
getJsonAsset(key);
josnData = getJosnData(key);
}
texture = createTextureSheet(getTextureByName(key).baseTexture, josnData);
if (!texture) return [3, 2];
return [4, createMc(parent, texture, frames, frameInterval)];
case 1:
_a.sent();
r(1);
return [3, 3];
case 2:
r(0);
_a.label = 3;
case 3: return [2];
}
});
}); });
_a.label = 3;
case 3: return [2];
}
});
}); })];
});
});
}
function createMc(parent, spritesheet, frames, frameInterval) {
if (frameInterval === void 0) { frameInterval = 5; }
return new Promise(function (r) {
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: frameInterval,
frames: frames,
position: [0, 150],
scale: 1,
anchor: [0, 0],
loop: false,
callBack: function () {
setTimeout(function () {
parent.removeChild(movieclip);
r(1);
}, 100);
}
});
parent.addChild(movieclip);
});
}
var playBoom = function (parent) {
return playMovieClip(parent, 'fail', ['fail1.png', 'fail2.png', 'fail3.png', 'fail4.png', 'fail5.png', 'fail6.png', 'fail7.png', 'fail8.png'], 5);
};
var playSuccess = function (parent) {
return playMovieClip(parent, 'success', ['success1.png', 'success2.png', 'success3.png', 'success4.png', 'success5.png', 'success6.png', 'success7.png', 'success8.png', 'success9.png'], 5);
};
//# sourceMappingURL=playMovieClip.js.map
var createCoin = function (scale) {
var josnData = getJosnData('coin');
if (!josnData) {
getJsonAsset('coin');
josnData = getJosnData('coin');
}
var texture = createTextureSheet(getTextureByName('coin').baseTexture, josnData);
var animation = createMovieClip(texture, 0.6);
var baseItem = new BaseItem(animation, LabelType$1.coin);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem;
};
var createMovieClip = function (spritesheet, scale) {
if (scale === void 0) { scale = 1; }
var list = ['coin1.png', 'coin2.png', 'coin3.png', 'coin4.png', 'coin5.png', 'coin6.png', 'coin7.png', 'coin8.png'];
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 6,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip;
};
//# sourceMappingURL=createCoin.js.map
var createBoom = function (scale) {
var josnData = getJosnData('boom');
if (!josnData) {
getJsonAsset('boom');
josnData = getJosnData('boom');
}
var boomTexture = createTextureSheet(getTextureByName('boom').baseTexture, josnData);
var animation = createMovieClip$1(boomTexture);
var baseItem = new BaseItem(animation, LabelType$1.boom);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem;
};
var createMovieClip$1 = function (spritesheet, scale) {
if (scale === void 0) { scale = 1; }
var list = ['boom1.png', 'boom2.png', 'boom3.png', 'boom4.png', 'boom5.png', 'boom6.png', 'boom7.png', 'boom8.png', 'boom9.png', 'boom10.png'];
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip;
};
//# sourceMappingURL=createBoom.js.map
var createGift = function (scale) {
var josnData = getJosnData('gift');
if (!josnData) {
getJsonAsset('gift');
josnData = getJosnData('gift');
}
var texture = createTextureSheet(getTextureByName('gift').baseTexture, josnData);
var animation = createMovieClip$2(texture, 0.6);
var baseItem = new BaseItem(animation, LabelType$1.gift);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem;
};
var createMovieClip$2 = function (spritesheet, scale) {
if (scale === void 0) { scale = 1; }
var list = ['gift1.png', 'gift2.png', 'gift3.png', 'gift4.png', 'gift5.png', 'gift6.png', 'gift7.png', 'gift8.png', 'gift9.png', 'gift10.png'];
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip;
};
//# sourceMappingURL=createGift.js.map
var createCandy = function (scale) {
var josnData = getJosnData('candy');
if (!josnData) {
getJsonAsset('candy');
josnData = getJosnData('candy');
}
var boomTexture = createTextureSheet(getTextureByName('candy').baseTexture, josnData);
var animation = createMovieClip$3(boomTexture);
var baseItem = new BaseItem(animation, LabelType$1.candy);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem;
};
var createMovieClip$3 = function (spritesheet, scale) {
if (scale === void 0) { scale = 1; }
var list = ['candy1.png', 'candy2.png', 'candy3.png', 'candy4.png', 'candy5.png', 'candy6.png', 'candy7.png', 'candy8.png'];
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 6,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip;
};
//# sourceMappingURL=createCandy.js.map
var createEgg = function (scale) {
var josnData = getJosnData('egg');
if (!josnData) {
getJsonAsset('gift');
josnData = getJosnData('egg');
}
var texture = createTextureSheet(getTextureByName('egg').baseTexture, josnData);
var animation = createMovieClip$4(texture, 0.6);
var baseItem = new BaseItem(animation, LabelType$1.egg);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem;
};
var createMovieClip$4 = function (spritesheet, scale) {
if (scale === void 0) { scale = 1; }
var list = ['egg1.png', 'egg2.png', 'egg3.png', 'egg4.png', 'egg5.png', 'egg6.png', 'egg7.png', 'egg8.png', 'egg9.png'];
var movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip;
};
//# sourceMappingURL=createEgg.js.map
var createItem = function (scale, type) {
var funcs = {
'boom': createBoom,
'gift': createGift,
'candy': createCandy,
'egg': createEgg,
'coin': createCoin
};
var func = funcs[type];
return func(scale);
};
//# sourceMappingURL=createItem.js.map
var createBubble = function (_this, type, x, y, force, density) {
if (force === void 0) { force = { x: 0, y: 0 }; }
if (density === void 0) { density = 0.001; }
var scale;
var size = random(85, 100);
var maxsize = 100;
scale = size / maxsize;
var baseItem = createItem(scale, type);
var angle;
angle = 0;
_this._egretRender.circle(x, y, (size - 17) / 2, baseItem, {
frictionAir: 0,
collisionFilter: { group: award, category: award, mask: awardMask },
angle: angle,
label: baseItem.type,
friction: 0,
force: force,
density: density
});
};
var random = function (start, end) {
var n = end - start;
return Math.random() * n + start;
};
var createItems = (function (_this) {
var score = getScore();
var items = getCurrentItems();
var list = [];
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
var item = items_1[_i];
var type = item[0];
var nums = item[1];
if (type == LabelType$1.coin)
nums = nums - score;
for (var i = 0; i < nums; i++) {
list.push(type);
}
}
var count = 0;
var coinsFall = setInterval(function () {
if (count <= list.length - 1) {
var type = list[count];
createBubble(_this, type, 375 + Math.random() * 200 - 100, 400 + 200 + 200);
count++;
}
}, 100);
});
//# sourceMappingURL=createItems.js.map
var clear = function (that) {
TextList.forEach(function (i) {
engine.Tween.removeTweens(that.gameHint[i]);
that.gameHint[i].alpha = 0;
});
};
var playgreat = function (image) {
engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 20 }).to({ x: 540.5, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(2)).wait(500).to({ alpha: 0 }, 200);
};
var playcool = function (image) {
engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 60 }).to({ x: 526.09, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(7)).wait(500).to({ alpha: 0 }, 200);
};
var playperfect = function (image) {
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, }).to({ scaleX: 1, scaleY: 1 }, 200, engine.Ease.getBackOut(10)).wait(500).to({ alpha: 0 }, 200);
};
var playawesome = function (image) {
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -20 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(20)).wait(500).to({ alpha: 0 }, 200);
};
var playunbelievable = function (image) {
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -60 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(40)).wait(500).to({ alpha: 0 }, 200);
};
var funcs = [playgreat, playcool, playperfect, playawesome, playunbelievable];
var cdtimer;
var count = 0;
var playTextAni = function (that) { return tslib.__awaiter(void 0, void 0, void 0, function () {
var image;
return tslib.__generator(this, function (_a) {
clear(that);
count++;
if (count >= TextList.length)
count = TextList.length;
console.log(count);
image = that.gameHint[TextList[count - 1]];
image.visible = true;
funcs[count - 1](image);
if (cdtimer > 0)
clearTimeout(cdtimer);
cdtimer = setTimeout(function () {
count = 0;
console.log('clear');
}, 5000);
return [2];
});
}); };
var TextList = ['great', 'cool', 'perfect', 'awesome', 'unbelievable'];
//# sourceMappingURL=playTextAni.js.map
function check(_this) {
var egretRenderContainer = _this.egretRenderContainer;
var center = 375;
var paddingX = 50;
var ypos = 570;
var h = 40;
var bodies = Matter.Composite.allBodies(_this._engine.world);
var isAward = function (i) { return i.collisionFilter.group == award; };
bodies.forEach(function (i) {
if (!isAward(i))
return;
if (i['timer']) {
var t0 = Date.now() - i['timer'];
if (t0 > 3000) {
delete i['timer'];
}
}
var _a = i.position, x = _a.x, y = _a.y;
var xResult = x > (center - paddingX) && x < (center + paddingX);
var yResult = y > ypos && y < (ypos + h);
if (xResult && yResult && i.velocity.y > 0 && !i['timer']) {
i['timer'] = Date.now();
if (i.label == LabelType$1.boom) {
_this._egretRender.remove(i);
vibrate(_this, 2);
playBoom(egretRenderContainer);
_this.onBoom();
}
else if (i.label == LabelType$1.egg) {
_this._egretRender.remove(i);
}
else if (i.label == LabelType$1.candy) {
_this._egretRender.remove(i);
}
else if (i.label == LabelType$1.gift) {
_this._egretRender.remove(i);
}
else {
playSuccess(_this.egretRenderContainer);
_this._egretRender.remove(i);
_this.addScore();
playTextAni(_this);
}
}
});
}
//# sourceMappingURL=check.js.map
var createBox = function (_this) {
var path1 = Matter.Vertices.fromPath('385 370 630 380 670 728 620 1080 370 1100 109 1090 57 728 108 370 0 370 0 1624 750 1624 750 0', null);
var body = Matter.Bodies.fromVertices(400, 880, [path1], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);
Matter.World.add(_this._engine.world, body);
var path2 = Matter.Vertices.fromPath('108 370 385 370 385 300', null);
var body2 = Matter.Bodies.fromVertices(296, 365, [path2], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);
Matter.World.add(_this._engine.world, body2);
var basketpath1 = Matter.Vertices.fromPath('290 560 324 600 326 600 313 565', null);
var basketbody1 = Matter.Bodies.fromVertices(305, 575, [basketpath1], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);
Matter.World.add(_this._engine.world, basketbody1);
var basketpath2 = Matter.Vertices.fromPath('465 563 443 605 441 605 456 560', null);
var basketbody2 = Matter.Bodies.fromVertices(453, 570, [basketpath2], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);
Matter.World.add(_this._engine.world, basketbody2);
var basketLeft = Matter.Bodies.circle(285, 560, 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } });
Matter.World.add(_this._engine.world, basketLeft);
var basketRight = Matter.Bodies.circle(461, 560, 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } });
Matter.World.add(_this._engine.world, basketRight);
var w = 100;
var h = 50;
var rect = _this._egretRender.rectangle(180, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
var rect2 = _this._egretRender.rectangle(560, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
var w2 = 300;
var h2 = 10;
var rect3 = _this._egretRender.rectangle(375, 1100, w2, h2, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
};
//# sourceMappingURL=createBox.js.map
var createBubblePic = function (r) {
var bubbleTexture = getTextureByName('bubble');
var bubblePic = new engine.Sprite(bubbleTexture);
bubblePic.scaleX = bubblePic.scaleY = r * 2 / 100;
return bubblePic;
};
//# sourceMappingURL=createBubblePic.js.map
var timerLeft;
var timerRight;
var startStandbyBubblesLeft = function (egretRender) {
timerLeft = setInterval(function () {
var scale = 0.2;
var p1 = { x: 180, y: 1050 };
var r = random$1(8, 10);
var bubblePic = createBubblePic(r);
var body = egretRender.circle(p1.x, p1.y, r, bubblePic, {
restitution: 0,
frictionAir: 0,
force: { x: random$1(-0.005, 0.005) * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }
});
setTimeout(function () {
egretRender.remove(body);
}, 1000);
}, 700);
};
var startStandbyBubblesRight = function (egretRender) {
timerRight = setInterval(function () {
var scale = 0.2;
var p2 = { x: 560, y: 1050 };
var r2 = random$1(8, 10);
var bubblePic2 = createBubblePic(r2);
var body2 = egretRender.circle(p2.x, p2.y, r2, bubblePic2, {
restitution: 0,
frictionAir: 0,
force: { x: random$1(-0.005, 0.005) * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }
});
setTimeout(function () {
egretRender.remove(body2);
}, 1000);
}, 700);
};
var stopStandbyBubblesLeft = function () {
clearInterval(timerLeft);
};
var stopStandbyBubblesRight = function () {
clearInterval(timerRight);
};
var random$1 = function (start, end) {
var n = end - start;
return Math.random() * n + start;
};
//# sourceMappingURL=standbyBubbles.js.map
var createBtns = (function (that) {
var createShape = function () {
var shape = new engine.Shape();
shape.beginFill(0, .6);
shape.drawCircle(0, 0, that._leftBtn.width / 2);
shape.endFill();
return shape;
};
[that._leftBtn, that._rightBtn].forEach(function (btn) {
btn.addEventListener(engine.MouseEvent.MOUSE_DOWN, function (e) {
var btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({ scaleY: 0.9 }, 200);
}, that);
});
[that._leftBtn, that._rightBtn].forEach(function (btn) {
btn.addEventListener(engine.MouseEvent.MOUSE_UP, function (e) {
var btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({ scaleX: 1, scaleY: 1 }, 200);
}, that);
});
[that._leftBtn, that._rightBtn].forEach(function (btn) {
btn.addEventListener(engine.MouseEvent.MOUSE_OUT, function (e) {
var btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({ scaleX: 1, scaleY: 1 }, 200);
}, that);
});
var shapeLeft = createShape();
shapeLeft.x = that._leftBtn.width / 2;
shapeLeft.y = that._leftBtn.height / 2;
that._leftBtn.addChild(shapeLeft);
var shapeR = createShape();
shapeR.x = that._rightBtn.width / 2;
shapeR.y = that._rightBtn.height / 2;
that._rightBtn.addChild(shapeR);
shapeLeft.alpha = shapeR.alpha = 0;
});
//# sourceMappingURL=createBtns.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.gameHint = {};
_this.addForce = false;
_this.stageX = 0;
_this.stageY = 0;
_this._frameCount = 0;
return _this;
}
GameView.prototype.start = function (color) {
return tslib.__awaiter(this, void 0, void 0, function () {
var a, gameNode, contPng, leftBtn, rightBtn, light, basket_bottom, tmpRect, basket_top, glass, gameData, countDown, countDownLabel;
return tslib.__generator(this, function (_a) {
a = new engine.Shape();
this.addChild(a);
engine.globalLoader.loadImage('//yun.duiba.com.cn/aurora/assets/66ab48ff49a741f0c93335d4eb0c9e50b7ab6e1e.png', 'bg_dot')
.then(function (img) {
a.beginBitmapFill(img, null);
a.drawRect(0, 0, 750, 1624);
a.endFill();
});
gameNode = this._gameNode = new engine.Sprite(getTextureByName('机子'));
gameNode.y = 260;
this.addChild(gameNode);
contPng = new engine.Image(getTextureByName('contPng'));
contPng.x = (750 - contPng.width) / 2;
contPng.y = 215;
this.addChild(contPng);
leftBtn = this._leftBtn = new engine.Sprite(getTextureByName('左按钮'));
leftBtn.anchorY = leftBtn.height - 50;
leftBtn.x = 83;
leftBtn.y = 920;
gameNode.addChild(leftBtn);
rightBtn = this._rightBtn = new engine.Sprite(getTextureByName('右按钮'));
rightBtn.anchorY = rightBtn.height - 50;
rightBtn.x = 400;
rightBtn.y = 920;
gameNode.addChild(rightBtn);
light = this._light = new engine.Sprite(getTextureByName('灯'));
light.x = 12;
light.y = 44;
gameNode.addChild(light);
basket_bottom = this._basket_bottom = new engine.Sprite(getTextureByName('basket_bottom'));
basket_bottom.x = (contPng.width - basket_bottom.width) / 2;
basket_bottom.y = 85;
contPng.addChild(basket_bottom);
tmpRect = new engine.Rect();
tmpRect.x = 230;
tmpRect.y = 372;
tmpRect.width = 300;
tmpRect.height = 300;
this.addChild(tmpRect);
basket_bottom.mask = tmpRect;
basket_top = this._basket_top = new engine.Sprite(getTextureByName('basket_top'));
basket_top.x = 287;
basket_top.y = 485;
this.addChild(basket_top);
glass = this._basket_top = new engine.Sprite(getTextureByName('玻璃'));
glass.x = (750 - glass.width) / 2;
glass.y = 340;
this.addChild(glass);
gameData = this._gameData = new GameData(contPng, color);
contPng.addChild(gameData);
countDown = this._countDown = new engine.Sprite(getTextureByName('倒计时'));
countDown.x = 5;
countDown.y = 180;
this.addChild(countDown);
this._curLevelTime = getlevelTime();
countDownLabel = this._countDownLabel = Tool.getLabel(this._curLevelTime, 48, "#ffffff");
countDownLabel.x = (countDown.width - countDownLabel.width) / 2;
countDownLabel.y = (countDown.height - countDownLabel.height) / 2 - 5;
countDown.addChild(countDownLabel);
this.initGameHint();
this.startHandle();
this.levelHint();
return [2];
});
});
};
GameView.prototype.levelHint = function () {
var lvBg = this._lvbg = new engine.Rect();
lvBg.fillColor = 0x000000;
lvBg.alpha = 0.7;
lvBg.width = 750;
lvBg.height = 1624;
lvBg.x = lvBg.y = 0;
lvBg.visible = false;
this.addChild(lvBg);
var lv_common = this._lv_common = new engine.Sprite(getTextureByName('lv_common'));
lv_common.x = (750 - lv_common.width) / 2;
lv_common.y = 500;
lv_common.visible = false;
this.addChild(lv_common);
var lv1 = this._lv = new engine.Sprite(getTextureByName('lv1'));
lv1.anchorTexture.set(0.5, 0.5);
lv1.x = lv_common.width / 2;
lv1.y = 80;
lv_common.addChild(lv1);
var lv1_label = this._lv_label = Tool.getLabel("5", 38, "#28c1ec", true, engine.TEXT_ALIGN.CENTER);
lv1_label.width = 100;
lv1_label.x = 205;
lv1_label.y = 205;
lv1_label.fillColor = 0xffffff;
lv_common.addChild(lv1_label);
};
GameView.prototype.initGameHint = function () {
var awesome = new engine.Sprite(getTextureByName('awesome'));
awesome.anchorTexture.set(0.5, 0.5);
awesome.x = 520;
awesome.y = 490;
awesome.alpha = 0;
this.addChild(awesome);
this.gameHint['awesome'] = awesome;
var cool = new engine.Sprite(getTextureByName('cool'));
cool.anchorTexture.set(0.5, 0.5);
cool.x = 520;
cool.y = 490;
cool.alpha = 0;
this.addChild(cool);
this.gameHint['cool'] = cool;
var good = new engine.Sprite(getTextureByName('good'));
good.anchorTexture.set(0.5, 0.5);
good.x = 520;
good.y = 490;
good.alpha = 0;
this.addChild(good);
this.gameHint['good'] = good;
var great = new engine.Sprite(getTextureByName('great'));
great.anchorTexture.set(0.5, 0.5);
great.x = 520;
great.y = 490;
great.alpha = 0;
this.addChild(great);
this.gameHint['great'] = great;
var perfect = new engine.Sprite(getTextureByName('perfect'));
perfect.anchorTexture.set(0.5, 0.5);
perfect.x = 530;
perfect.y = 490;
perfect.alpha = 0;
this.addChild(perfect);
this.gameHint['perfect'] = perfect;
var unbelievable = new engine.Sprite(getTextureByName('unbelievable'));
unbelievable.anchorTexture.set(0.5, 0.5);
unbelievable.x = 480;
unbelievable.y = 460;
unbelievable.alpha = 0;
this.addChild(unbelievable);
this.gameHint['unbelievable'] = unbelievable;
};
GameView.prototype.startNextLevel = function () {
this.clearAwardBody();
this.playLevelAni();
setTouchEnabled(true);
createItems(this);
this._gameData.scorePosUpdate();
this._gameData.resetMask();
this._gameData.levelUpdate();
this._curLevelTime = getlevelTime();
this._countDownLabel.text = this._curLevelTime;
this._countDownLabel.x = (this._countDown.width - this._countDownLabel.width) / 2;
this.runEngine();
};
GameView.prototype.themeChange = function (data) {
this._countDown.texture = engine.Texture.fromImage(data.gameCountdownImage);
this._leftBtn.texture = engine.Texture.fromImage(data.leftButtonImage);
this._leftBtn.anchorY = this._leftBtn.height - 50;
this._leftBtn.x = 83;
this._leftBtn.y = 920;
this._rightBtn.texture = engine.Texture.fromImage(data.rightButtonImage);
this._rightBtn.anchorY = this._rightBtn.height - 50;
this._rightBtn.x = 400;
this._rightBtn.y = 920;
};
GameView.prototype.revive = function () {
setTouchEnabled(true);
this.runEngine();
};
GameView.prototype.startHandle = function () {
var engineMatter = Matter.Engine.create();
this._engine = engineMatter;
this._engine.world.gravity.y = 0.2;
this.egretRenderContainer = new engine.Sprite();
this.addChild(this.egretRenderContainer);
this._egretRender = new EgretRender(this.egretRenderContainer, this._engine);
var options = {
width: 750,
height: 1624,
wireframes: !1,
};
var render = Matter.Render.create({
element: document.getElementById('debugCanvas'),
engine: engineMatter,
options: options
});
Matter.Render.run(render);
this.runGame();
};
GameView.prototype.runGame = function () {
var _this = this;
createBox(this);
Matter.Events.on(this._engine, 'beforeUpdate', function () {
if (!_this.addForce)
return;
_this.addForce = false;
var isleft = _this.stageX < 375;
var start = isleft ? { x: 180, y: 1050 } : { x: 560, y: 1050 };
var scale = 2.2;
for (var i = 0; i < 15; i++) {
setTimeout(function () {
var r = _this.random(10, 14);
var bubblePic;
bubblePic = createBubblePic(r);
var basex = 0.02;
var xoffset = 0.007;
var fx = isleft ? _this.random(-basex, basex) : _this.random(-basex, basex);
var padding = 50;
var startx = _this.random(start.x - padding, start.x + padding);
if (fx < -xoffset || fx > xoffset)
bubblePic = null;
var body = _this._egretRender.circle(startx, start.y, r, bubblePic, {
density: 0.001 * 3,
restitution: 1,
force: { x: fx * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }
});
setTimeout(function () {
_this._egretRender.remove(body);
}, 1000);
}, Math.random() * 200);
}
var _loop_1 = function (j) {
var start_1 = isleft ? { x: 180 + 50, y: 1050 + 30 } : { x: 560 - 50, y: 1050 + 30 };
var r = _this.random(10, 14);
var body = _this._egretRender.circle(start_1.x, start_1.y, r, null, {
density: 0.001 * 3,
restitution: 1,
force: { x: (isleft ? 1 : -1) * 0.02 * 1.7, y: 0 },
collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }
});
setTimeout(function () {
_this._egretRender.remove(body);
}, 1000);
};
for (var j = 0; j < 1; j++) {
_loop_1();
}
});
this._leftBtn.addEventListener(engine.MouseEvent.CLICK, function (e) {
if (!getTouchEnabled())
return;
_this.addForce = true;
_this.stageX = e.stageX;
stopStandbyBubblesLeft();
clearTimeout(_this._startStandbyBubblesLeft);
_this._startStandbyBubblesLeft = setTimeout(function () {
startStandbyBubblesLeft(_this._egretRender);
}, 1000);
}, this);
this._rightBtn.addEventListener(engine.MouseEvent.CLICK, function (e) {
if (!getTouchEnabled())
return;
_this.addForce = true;
_this.stageX = e.stageX;
stopStandbyBubblesRight();
clearTimeout(_this._startStandbyBubblesRight);
_this._startStandbyBubblesRight = setTimeout(function () {
startStandbyBubblesRight(_this._egretRender);
}, 1000);
}, this);
createBtns(this);
startStandbyBubblesLeft(this._egretRender);
startStandbyBubblesRight(this._egretRender);
};
GameView.prototype.enterFrame = function () {
var now = Date.now();
var deltaTime = this.lastTime ? now - this.lastTime : 16.7;
this.lastTime = now;
this._frameCount += deltaTime;
if (this._frameCount >= 1000) {
this._frameCount = 0;
this.updateCountDown();
}
if (deltaTime > 20)
deltaTime = 20;
Matter.Engine.update(this._engine, deltaTime);
this._egretRender.run();
check(this);
return false;
};
GameView.prototype.random = function (start, end) {
var n = end - start;
return Math.random() * n + start;
};
GameView.prototype.runEngine = function () {
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);
};
GameView.prototype.updateCountDown = function () {
this._curLevelTime--;
this._countDownLabel.text = this._curLevelTime;
this._countDownLabel.x = (this._countDown.width - this._countDownLabel.width) / 2;
if (this._curLevelTime <= 0) {
this.end();
console.log('时间结束');
}
};
GameView.prototype.onBoom = function () {
this.end();
};
GameView.prototype.addScore = function () {
addScore(1);
if (getScore() >= getlevelMax()) {
setTouchEnabled(false);
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);
engine.globalEvent.dispatchEvent('seabed-game-success', { level: getCurLevel(), score: getScore() });
}
this._gameData.scorePosUpdate();
};
GameView.prototype.playLevelAni = function () {
var _this = this;
var lv = getCurLevel();
this._lv.texture = getTextureByName("lv" + lv);
this._lv_label.text = getlevelMax() + '';
this._lvbg.visible = true;
this._lv_common.visible = true;
engine.Tween.get(this._lv_common).set({ y: 500 - 1624 }).to({ y: 500 }, 700, engine.Ease.backOut)
.wait(1000).to({ y: 1624 + 500 }, 500, engine.Ease.backIn)
.call(function () {
_this._lvbg.visible = false;
});
};
GameView.prototype.clearAwardBody = function () {
var _this = this;
var bodies = Matter.Composite.allBodies(this._engine.world);
var isAward = function (i) { return i.collisionFilter.group == award; };
bodies.forEach(function (i) {
if (isAward(i))
_this._egretRender.remove(i);
});
};
GameView.prototype.end = function () {
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);
engine.globalEvent.dispatchEvent('seabed-game-fail', { level: getCurLevel(), score: getScore(), time: this._curLevelTime });
setTouchEnabled(false);
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('seabed-game-start', _this.start, _this);
engine.globalEvent.addEventListener('seabed-game-revive', _this.revive, _this);
engine.globalEvent.addEventListener('seabed-game-startNextLevel', _this.startNextLevel, _this);
engine.globalEvent.addEventListener('seabed-game-themeChange', _this.themeChange, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
setlevelData();
this.initData();
this._gameView.start(event.data.color);
['coin', 'boom', 'fail', 'success'].forEach(function (element) {
getJsonAsset(element);
});
};
GameWrapper.prototype.startNextLevel = function (event) {
setScore(0);
setCurLevel(parseInt(event.data.level));
this._gameView.startNextLevel();
};
GameWrapper.prototype.initData = function () {
setScore(0);
setCurLevel(1);
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.themeChange = function (event) {
this._gameView.themeChange(event.data.resData);
};
return GameWrapper;
}(engine.Container));
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* matter-js 0.14.2 by @liabru 2018-06-11
* http://brm.io/matter-js/
* License MIT
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Matter=e()}}(function(){return function(){function e(t,n,o){function i(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[s]={exports:{}};t[s][0].call(d.exports,function(e){return i(t[s][1][e]||e)},d,d.exports,e,t,n,o)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}return e}()({1:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=(e("../render/Render"),e("../core/Common")),l=e("../geometry/Bounds"),c=e("../geometry/Axes");!function(){o._inertiaScale=4,
o._nextCollidingGroupId=1,o._nextNonCollidingGroupId=-1,o._nextCategory=1,o.create=function(t){var n={id:a.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:i.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0},lineWidth:0}},o=a.extend(n,t);return e(o,t),o},o.nextGroup=function(e){return e?o._nextNonCollidingGroupId--:o._nextCollidingGroupId++},o.nextCategory=function(){return o._nextCategory=o._nextCategory<<1,o._nextCategory};var e=function(e,t){t=t||{},o.set(e,{bounds:e.bounds||l.create(e.vertices),
positionPrev:e.positionPrev||r.clone(e.position),anglePrev:e.anglePrev||e.angle,vertices:e.vertices,parts:e.parts||[e],isStatic:e.isStatic,isSleeping:e.isSleeping,parent:e.parent||e}),i.rotate(e.vertices,e.angle,e.position),c.rotate(e.axes,e.angle),l.update(e.bounds,e.vertices,e.velocity),o.set(e,{axes:t.axes||e.axes,area:t.area||e.area,mass:t.mass||e.mass,inertia:t.inertia||e.inertia});var n=e.isStatic?"#2e2b44":a.choose(["#006BA6","#0496FF","#FFBC42","#D81159","#8F2D56"]);e.render.fillStyle=e.render.fillStyle||n,e.render.strokeStyle=e.render.strokeStyle||"#000",e.render.sprite.xOffset+=-(e.bounds.min.x-e.position.x)/(e.bounds.max.x-e.bounds.min.x),e.render.sprite.yOffset+=-(e.bounds.min.y-e.position.y)/(e.bounds.max.y-e.bounds.min.y)};o.set=function(e,t,n){var i;"string"==typeof t&&(i=t,t={},t[i]=n);for(i in t)if(n=t[i],t.hasOwnProperty(i))switch(i){case"isStatic":o.setStatic(e,n);break;case"isSleeping":s.set(e,n);break;case"mass":o.setMass(e,n);break;case"density":o.setDensity(e,n)
;break;case"inertia":o.setInertia(e,n);break;case"vertices":o.setVertices(e,n);break;case"position":o.setPosition(e,n);break;case"angle":o.setAngle(e,n);break;case"velocity":o.setVelocity(e,n);break;case"angularVelocity":o.setAngularVelocity(e,n);break;case"parts":o.setParts(e,n);break;default:e[i]=n}},o.setStatic=function(e,t){for(var n=0;n<e.parts.length;n++){var o=e.parts[n];o.isStatic=t,t?(o._original={restitution:o.restitution,friction:o.friction,mass:o.mass,inertia:o.inertia,density:o.density,inverseMass:o.inverseMass,inverseInertia:o.inverseInertia},o.restitution=0,o.friction=1,o.mass=o.inertia=o.density=1/0,o.inverseMass=o.inverseInertia=0,o.positionPrev.x=o.position.x,o.positionPrev.y=o.position.y,o.anglePrev=o.angle,o.angularVelocity=0,o.speed=0,o.angularSpeed=0,o.motion=0):o._original&&(o.restitution=o._original.restitution,o.friction=o._original.friction,o.mass=o._original.mass,o.inertia=o._original.inertia,o.density=o._original.density,
o.inverseMass=o._original.inverseMass,o.inverseInertia=o._original.inverseInertia,delete o._original)}},o.setMass=function(e,t){var n=e.inertia/(e.mass/6);e.inertia=n*(t/6),e.inverseInertia=1/e.inertia,e.mass=t,e.inverseMass=1/e.mass,e.density=e.mass/e.area},o.setDensity=function(e,t){o.setMass(e,t*e.area),e.density=t},o.setInertia=function(e,t){e.inertia=t,e.inverseInertia=1/e.inertia},o.setVertices=function(e,t){t[0].body===e?e.vertices=t:e.vertices=i.create(t,e),e.axes=c.fromVertices(e.vertices),e.area=i.area(e.vertices),o.setMass(e,e.density*e.area);var n=i.centre(e.vertices);i.translate(e.vertices,n,-1),o.setInertia(e,o._inertiaScale*i.inertia(e.vertices,e.mass)),i.translate(e.vertices,e.position),l.update(e.bounds,e.vertices,e.velocity)},o.setParts=function(e,t,n){var r;for(t=t.slice(0),e.parts.length=0,e.parts.push(e),e.parent=e,r=0;r<t.length;r++){var s=t[r];s!==e&&(s.parent=e,e.parts.push(s))}if(1!==e.parts.length){if(n=void 0===n||n){var a=[]
;for(r=0;r<t.length;r++)a=a.concat(t[r].vertices);i.clockwiseSort(a);var l=i.hull(a),c=i.centre(l);o.setVertices(e,l),i.translate(e.vertices,c)}var d=o._totalProperties(e);e.area=d.area,e.parent=e,e.position.x=d.centre.x,e.position.y=d.centre.y,e.positionPrev.x=d.centre.x,e.positionPrev.y=d.centre.y,o.setMass(e,d.mass),o.setInertia(e,d.inertia),o.setPosition(e,d.centre)}},o.setPosition=function(e,t){var n=r.sub(t,e.position);e.positionPrev.x+=n.x,e.positionPrev.y+=n.y;for(var o=0;o<e.parts.length;o++){var s=e.parts[o];s.position.x+=n.x,s.position.y+=n.y,i.translate(s.vertices,n),l.update(s.bounds,s.vertices,e.velocity)}},o.setAngle=function(e,t){var n=t-e.angle;e.anglePrev+=n;for(var o=0;o<e.parts.length;o++){var s=e.parts[o];s.angle+=n,i.rotate(s.vertices,n,e.position),c.rotate(s.axes,n),l.update(s.bounds,s.vertices,e.velocity),o>0&&r.rotateAbout(s.position,n,e.position,s.position)}},o.setVelocity=function(e,t){e.positionPrev.x=e.position.x-t.x,e.positionPrev.y=e.position.y-t.y,
e.velocity.x=t.x,e.velocity.y=t.y,e.speed=r.magnitude(e.velocity)},o.setAngularVelocity=function(e,t){e.anglePrev=e.angle-t,e.angularVelocity=t,e.angularSpeed=Math.abs(e.angularVelocity)},o.translate=function(e,t){o.setPosition(e,r.add(e.position,t))},o.rotate=function(e,t,n){if(n){var i=Math.cos(t),r=Math.sin(t),s=e.position.x-n.x,a=e.position.y-n.y;o.setPosition(e,{x:n.x+(s*i-a*r),y:n.y+(s*r+a*i)}),o.setAngle(e,e.angle+t)}else o.setAngle(e,e.angle+t)},o.scale=function(e,t,n,r){var s=0,a=0;r=r||e.position;for(var d=0;d<e.parts.length;d++){var u=e.parts[d];i.scale(u.vertices,t,n,r),u.axes=c.fromVertices(u.vertices),u.area=i.area(u.vertices),o.setMass(u,e.density*u.area),i.translate(u.vertices,{x:-u.position.x,y:-u.position.y}),o.setInertia(u,o._inertiaScale*i.inertia(u.vertices,u.mass)),i.translate(u.vertices,{x:u.position.x,y:u.position.y}),d>0&&(s+=u.area,a+=u.inertia),u.position.x=r.x+(u.position.x-r.x)*t,u.position.y=r.y+(u.position.y-r.y)*n,l.update(u.bounds,u.vertices,e.velocity)
}e.parts.length>1&&(e.area=s,e.isStatic||(o.setMass(e,e.density*s),o.setInertia(e,a))),e.circleRadius&&(t===n?e.circleRadius*=t:e.circleRadius=null)},o.update=function(e,t,n,o){var s=Math.pow(t*n*e.timeScale,2),a=1-e.frictionAir*n*e.timeScale,d=e.position.x-e.positionPrev.x,u=e.position.y-e.positionPrev.y;e.velocity.x=d*a*o+e.force.x/e.mass*s,e.velocity.y=u*a*o+e.force.y/e.mass*s,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.position.x+=e.velocity.x,e.position.y+=e.velocity.y,e.angularVelocity=(e.angle-e.anglePrev)*a*o+e.torque/e.inertia*s,e.anglePrev=e.angle,e.angle+=e.angularVelocity,e.speed=r.magnitude(e.velocity),e.angularSpeed=Math.abs(e.angularVelocity);for(var p=0;p<e.parts.length;p++){var f=e.parts[p];i.translate(f.vertices,e.velocity),p>0&&(f.position.x+=e.velocity.x,f.position.y+=e.velocity.y),0!==e.angularVelocity&&(i.rotate(f.vertices,e.angularVelocity,e.position),c.rotate(f.axes,e.angularVelocity),
p>0&&r.rotateAbout(f.position,e.angularVelocity,e.position,f.position)),l.update(f.bounds,f.vertices,e.velocity)}},o.applyForce=function(e,t,n){e.force.x+=n.x,e.force.y+=n.y;var o={x:t.x-e.position.x,y:t.y-e.position.y};e.torque+=o.x*n.y-o.y*n.x},o._totalProperties=function(e){for(var t={mass:0,area:0,inertia:0,centre:{x:0,y:0}},n=1===e.parts.length?0:1;n<e.parts.length;n++){var o=e.parts[n],i=o.mass!==1/0?o.mass:1;t.mass+=i,t.area+=o.area,t.inertia+=o.inertia,t.centre=r.add(t.centre,r.mult(o.position,i))}return t.centre=r.div(t.centre,t.mass),t}}()},{"../core/Common":14,"../core/Sleeping":22,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29,"../render/Render":31}],2:[function(e,t,n){var o={};t.exports=o;var i=e("../core/Events"),r=e("../core/Common"),s=e("../geometry/Bounds"),a=e("./Body");!function(){o.create=function(e){return r.extend({id:r.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],
label:"Composite",plugin:{}},e)},o.setModified=function(e,t,n,i){if(e.isModified=t,n&&e.parent&&o.setModified(e.parent,t,n,i),i)for(var r=0;r<e.composites.length;r++){var s=e.composites[r];o.setModified(s,t,n,i)}},o.add=function(e,t){var n=[].concat(t);i.trigger(e,"beforeAdd",{object:t});for(var s=0;s<n.length;s++){var a=n[s];switch(a.type){case"body":if(a.parent!==a){r.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}o.addBody(e,a);break;case"constraint":o.addConstraint(e,a);break;case"composite":o.addComposite(e,a);break;case"mouseConstraint":o.addConstraint(e,a.constraint)}}return i.trigger(e,"afterAdd",{object:t}),e},o.remove=function(e,t,n){var r=[].concat(t);i.trigger(e,"beforeRemove",{object:t});for(var s=0;s<r.length;s++){var a=r[s];switch(a.type){case"body":o.removeBody(e,a,n);break;case"constraint":o.removeConstraint(e,a,n);break;case"composite":o.removeComposite(e,a,n);break;case"mouseConstraint":
o.removeConstraint(e,a.constraint)}}return i.trigger(e,"afterRemove",{object:t}),e},o.addComposite=function(e,t){return e.composites.push(t),t.parent=e,o.setModified(e,!0,!0,!1),e},o.removeComposite=function(e,t,n){var i=r.indexOf(e.composites,t);if(-1!==i&&(o.removeCompositeAt(e,i),o.setModified(e,!0,!0,!1)),n)for(var s=0;s<e.composites.length;s++)o.removeComposite(e.composites[s],t,!0);return e},o.removeCompositeAt=function(e,t){return e.composites.splice(t,1),o.setModified(e,!0,!0,!1),e},o.addBody=function(e,t){return e.bodies.push(t),o.setModified(e,!0,!0,!1),e},o.removeBody=function(e,t,n){var i=r.indexOf(e.bodies,t);if(-1!==i&&(o.removeBodyAt(e,i),o.setModified(e,!0,!0,!1)),n)for(var s=0;s<e.composites.length;s++)o.removeBody(e.composites[s],t,!0);return e},o.removeBodyAt=function(e,t){return e.bodies.splice(t,1),o.setModified(e,!0,!0,!1),e},o.addConstraint=function(e,t){return e.constraints.push(t),o.setModified(e,!0,!0,!1),e},o.removeConstraint=function(e,t,n){
var i=r.indexOf(e.constraints,t);if(-1!==i&&o.removeConstraintAt(e,i),n)for(var s=0;s<e.composites.length;s++)o.removeConstraint(e.composites[s],t,!0);return e},o.removeConstraintAt=function(e,t){return e.constraints.splice(t,1),o.setModified(e,!0,!0,!1),e},o.clear=function(e,t,n){if(n)for(var i=0;i<e.composites.length;i++)o.clear(e.composites[i],t,!0);return t?e.bodies=e.bodies.filter(function(e){return e.isStatic}):e.bodies.length=0,e.constraints.length=0,e.composites.length=0,o.setModified(e,!0,!0,!1),e},o.allBodies=function(e){for(var t=[].concat(e.bodies),n=0;n<e.composites.length;n++)t=t.concat(o.allBodies(e.composites[n]));return t},o.allConstraints=function(e){for(var t=[].concat(e.constraints),n=0;n<e.composites.length;n++)t=t.concat(o.allConstraints(e.composites[n]));return t},o.allComposites=function(e){for(var t=[].concat(e.composites),n=0;n<e.composites.length;n++)t=t.concat(o.allComposites(e.composites[n]));return t},o.get=function(e,t,n){var i,r;switch(n){case"body":
i=o.allBodies(e);break;case"constraint":i=o.allConstraints(e);break;case"composite":i=o.allComposites(e).concat(e)}return i?(r=i.filter(function(e){return e.id.toString()===t.toString()}),0===r.length?null:r[0]):null},o.move=function(e,t,n){return o.remove(e,t),o.add(n,t),e},o.rebase=function(e){for(var t=o.allBodies(e).concat(o.allConstraints(e)).concat(o.allComposites(e)),n=0;n<t.length;n++)t[n].id=r.nextId();return o.setModified(e,!0,!0,!1),e},o.translate=function(e,t,n){for(var i=n?o.allBodies(e):e.bodies,r=0;r<i.length;r++)a.translate(i[r],t);return o.setModified(e,!0,!0,!1),e},o.rotate=function(e,t,n,i){for(var r=Math.cos(t),s=Math.sin(t),l=i?o.allBodies(e):e.bodies,c=0;c<l.length;c++){var d=l[c],u=d.position.x-n.x,p=d.position.y-n.y;a.setPosition(d,{x:n.x+(u*r-p*s),y:n.y+(u*s+p*r)}),a.rotate(d,t)}return o.setModified(e,!0,!0,!1),e},o.scale=function(e,t,n,i,r){for(var s=r?o.allBodies(e):e.bodies,l=0;l<s.length;l++){var c=s[l],d=c.position.x-i.x,u=c.position.y-i.y
;a.setPosition(c,{x:i.x+d*t,y:i.y+u*n}),a.scale(c,t,n)}return o.setModified(e,!0,!0,!1),e},o.bounds=function(e){for(var t=o.allBodies(e),n=[],i=0;i<t.length;i+=1){var r=t[i];n.push(r.bounds.min,r.bounds.max)}return s.create(n)}}()},{"../core/Common":14,"../core/Events":16,"../geometry/Bounds":26,"./Body":1}],3:[function(e,t,n){var o={};t.exports=o;var i=e("./Composite"),r=(e("../constraint/Constraint"),e("../core/Common"));!function(){o.create=function(e){var t=i.create(),n={label:"World",gravity:{x:0,y:1,scale:.001},bounds:{min:{x:-1/0,y:-1/0},max:{x:1/0,y:1/0}}};return r.extend(t,n,e)}}()},{"../constraint/Constraint":12,"../core/Common":14,"./Composite":2}],4:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e){return{id:o.id(e),vertex:e,normalImpulse:0,tangentImpulse:0}},o.id=function(e){return e.body.id+"_"+e.index}}()},{}],5:[function(e,t,n){var o={};t.exports=o;var i=e("./SAT"),r=e("./Pair"),s=e("../geometry/Bounds");!function(){o.collisions=function(e,t){
for(var n=[],a=t.pairs.table,l=0;l<e.length;l++){var c=e[l][0],d=e[l][1];if((!c.isStatic&&!c.isSleeping||!d.isStatic&&!d.isSleeping)&&(o.canCollide(c.collisionFilter,d.collisionFilter)&&s.overlaps(c.bounds,d.bounds)))for(var u=c.parts.length>1?1:0;u<c.parts.length;u++)for(var p=c.parts[u],f=d.parts.length>1?1:0;f<d.parts.length;f++){var m=d.parts[f];if(p===c&&m===d||s.overlaps(p.bounds,m.bounds)){var v,y=r.id(p,m),g=a[y];v=g&&g.isActive?g.collision:null;var x=i.collides(p,m,v);x.collided&&n.push(x)}}}return n},o.canCollide=function(e,t){return e.group===t.group&&0!==e.group?e.group>0:0!=(e.mask&t.category)&&0!=(t.mask&e.category)}}()},{"../geometry/Bounds":26,"./Pair":7,"./SAT":11}],6:[function(e,t,n){var o={};t.exports=o;var i=e("./Pair"),r=e("./Detector"),s=e("../core/Common");!function(){o.create=function(e){var t={controller:o,detector:r.collisions,buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return s.extend(t,e)},o.update=function(e,t,n,i){
var r,s,a,l,c,d=n.world,u=e.buckets,p=!1;for(r=0;r<t.length;r++){var f=t[r];if((!f.isSleeping||i)&&!(f.bounds.max.x<d.bounds.min.x||f.bounds.min.x>d.bounds.max.x||f.bounds.max.y<d.bounds.min.y||f.bounds.min.y>d.bounds.max.y)){var m=o._getRegion(e,f);if(!f.region||m.id!==f.region.id||i){f.region&&!i||(f.region=m);var v=o._regionUnion(m,f.region);for(s=v.startCol;s<=v.endCol;s++)for(a=v.startRow;a<=v.endRow;a++){c=o._getBucketId(s,a),l=u[c];var y=s>=m.startCol&&s<=m.endCol&&a>=m.startRow&&a<=m.endRow,g=s>=f.region.startCol&&s<=f.region.endCol&&a>=f.region.startRow&&a<=f.region.endRow;!y&&g&&g&&l&&o._bucketRemoveBody(e,l,f),(f.region===m||y&&!g||i)&&(l||(l=o._createBucket(u,c)),o._bucketAddBody(e,l,f))}f.region=m,p=!0}}}p&&(e.pairsList=o._createActivePairsList(e))},o.clear=function(e){e.buckets={},e.pairs={},e.pairsList=[]},o._regionUnion=function(e,t){var n=Math.min(e.startCol,t.startCol),i=Math.max(e.endCol,t.endCol),r=Math.min(e.startRow,t.startRow),s=Math.max(e.endRow,t.endRow)
;return o._createRegion(n,i,r,s)},o._getRegion=function(e,t){var n=t.bounds,i=Math.floor(n.min.x/e.bucketWidth),r=Math.floor(n.max.x/e.bucketWidth),s=Math.floor(n.min.y/e.bucketHeight),a=Math.floor(n.max.y/e.bucketHeight);return o._createRegion(i,r,s,a)},o._createRegion=function(e,t,n,o){return{id:e+","+t+","+n+","+o,startCol:e,endCol:t,startRow:n,endRow:o}},o._getBucketId=function(e,t){return"C"+e+"R"+t},o._createBucket=function(e,t){return e[t]=[]},o._bucketAddBody=function(e,t,n){for(var o=0;o<t.length;o++){var r=t[o];if(!(n.id===r.id||n.isStatic&&r.isStatic)){var s=i.id(n,r),a=e.pairs[s];a?a[2]+=1:e.pairs[s]=[n,r,1]}}t.push(n)},o._bucketRemoveBody=function(e,t,n){t.splice(s.indexOf(t,n),1);for(var o=0;o<t.length;o++){var r=t[o],a=i.id(n,r),l=e.pairs[a];l&&(l[2]-=1)}},o._createActivePairsList=function(e){var t,n,o=[];t=s.keys(e.pairs);for(var i=0;i<t.length;i++)n=e.pairs[t[i]],n[2]>0?o.push(n):delete e.pairs[t[i]];return o}}()},{"../core/Common":14,"./Detector":5,"./Pair":7}],
7:[function(e,t,n){var o={};t.exports=o;var i=e("./Contact");!function(){o.create=function(e,t){var n=e.bodyA,i=e.bodyB,r=e.parentA,s=e.parentB,a={id:o.id(n,i),bodyA:n,bodyB:i,contacts:{},activeContacts:[],separation:0,isActive:!0,isSensor:n.isSensor||i.isSensor,timeCreated:t,timeUpdated:t,inverseMass:r.inverseMass+s.inverseMass,friction:Math.min(r.friction,s.friction),frictionStatic:Math.max(r.frictionStatic,s.frictionStatic),restitution:Math.max(r.restitution,s.restitution),slop:Math.max(r.slop,s.slop)};return o.update(a,e,t),a},o.update=function(e,t,n){var r=e.contacts,s=t.supports,a=e.activeContacts,l=t.parentA,c=t.parentB;if(e.collision=t,e.inverseMass=l.inverseMass+c.inverseMass,e.friction=Math.min(l.friction,c.friction),e.frictionStatic=Math.max(l.frictionStatic,c.frictionStatic),e.restitution=Math.max(l.restitution,c.restitution),e.slop=Math.max(l.slop,c.slop),a.length=0,t.collided){for(var d=0;d<s.length;d++){var u=s[d],p=i.id(u),f=r[p];f?a.push(f):a.push(r[p]=i.create(u))}
e.separation=t.depth,o.setActive(e,!0,n)}else!0===e.isActive&&o.setActive(e,!1,n)},o.setActive=function(e,t,n){t?(e.isActive=!0,e.timeUpdated=n):(e.isActive=!1,e.activeContacts.length=0)},o.id=function(e,t){return e.id<t.id?"A"+e.id+"B"+t.id:"A"+t.id+"B"+e.id}}()},{"./Contact":4}],8:[function(e,t,n){var o={};t.exports=o;var i=e("./Pair"),r=e("../core/Common");!function(){o._pairMaxIdleLife=1e3,o.create=function(e){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},e)},o.update=function(e,t,n){var o,s,a,l,c=e.list,d=e.table,u=e.collisionStart,p=e.collisionEnd,f=e.collisionActive,m=[];for(u.length=0,p.length=0,f.length=0,l=0;l<t.length;l++)o=t[l],o.collided&&(s=i.id(o.bodyA,o.bodyB),m.push(s),a=d[s],a?(a.isActive?f.push(a):u.push(a),i.update(a,o,n)):(a=i.create(o,n),d[s]=a,u.push(a),c.push(a)));for(l=0;l<c.length;l++)a=c[l],a.isActive&&-1===r.indexOf(m,a.id)&&(i.setActive(a,!1,n),p.push(a))},o.removeOld=function(e,t){
var n,i,r,s,a=e.list,l=e.table,c=[];for(s=0;s<a.length;s++)n=a[s],i=n.collision,i.bodyA.isSleeping||i.bodyB.isSleeping?n.timeUpdated=t:t-n.timeUpdated>o._pairMaxIdleLife&&c.push(s);for(s=0;s<c.length;s++)r=c[s]-s,n=a[r],delete l[n.id],a.splice(r,1)},o.clear=function(e){return e.table={},e.list.length=0,e.collisionStart.length=0,e.collisionActive.length=0,e.collisionEnd.length=0,e}}()},{"../core/Common":14,"./Pair":7}],9:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("./SAT"),s=e("../geometry/Bounds"),a=e("../factory/Bodies"),l=e("../geometry/Vertices");!function(){o.collides=function(e,t){for(var n=[],o=0;o<t.length;o++){var i=t[o];if(s.overlaps(i.bounds,e.bounds))for(var a=1===i.parts.length?0:1;a<i.parts.length;a++){var l=i.parts[a];if(s.overlaps(l.bounds,e.bounds)){var c=r.collides(l,e);if(c.collided){n.push(c);break}}}}return n},o.ray=function(e,t,n,r){r=r||1e-100
;for(var s=i.angle(t,n),l=i.magnitude(i.sub(t,n)),c=.5*(n.x+t.x),d=.5*(n.y+t.y),u=a.rectangle(c,d,l,r,{angle:s}),p=o.collides(u,e),f=0;f<p.length;f+=1){var m=p[f];m.body=m.bodyB=m.bodyA}return p},o.region=function(e,t,n){for(var o=[],i=0;i<e.length;i++){var r=e[i],a=s.overlaps(r.bounds,t);(a&&!n||!a&&n)&&o.push(r)}return o},o.point=function(e,t){for(var n=[],o=0;o<e.length;o++){var i=e[o];if(s.contains(i.bounds,t))for(var r=1===i.parts.length?0:1;r<i.parts.length;r++){var a=i.parts[r];if(s.contains(a.bounds,t)&&l.contains(a.vertices,t)){n.push(i);break}}}return n}}()},{"../factory/Bodies":23,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29,"./SAT":11}],10:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Common"),a=e("../geometry/Bounds");!function(){o._restingThresh=4,o._restingThreshTangent=6,o._positionDampen=.9,o._positionWarming=.8,o._frictionNormalMultiplier=5,o.preSolvePosition=function(e){
var t,n,o;for(t=0;t<e.length;t++)n=e[t],n.isActive&&(o=n.activeContacts.length,n.collision.parentA.totalContacts+=o,n.collision.parentB.totalContacts+=o)},o.solvePosition=function(e,t){var n,i,s,a,l,c,d,u,p,f=r._temp[0],m=r._temp[1],v=r._temp[2],y=r._temp[3];for(n=0;n<e.length;n++)i=e[n],i.isActive&&!i.isSensor&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,d=r.sub(r.add(l.positionImpulse,l.position,f),r.add(a.positionImpulse,r.sub(l.position,s.penetration,m),v),y),i.separation=r.dot(c,d));for(n=0;n<e.length;n++)i=e[n],i.isActive&&!i.isSensor&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,p=(i.separation-i.slop)*t,(a.isStatic||l.isStatic)&&(p*=2),a.isStatic||a.isSleeping||(u=o._positionDampen/a.totalContacts,a.positionImpulse.x+=c.x*p*u,a.positionImpulse.y+=c.y*p*u),l.isStatic||l.isSleeping||(u=o._positionDampen/l.totalContacts,l.positionImpulse.x-=c.x*p*u,l.positionImpulse.y-=c.y*p*u))},o.postSolvePosition=function(e){for(var t=0;t<e.length;t++){var n=e[t]
;if(n.totalContacts=0,0!==n.positionImpulse.x||0!==n.positionImpulse.y){for(var s=0;s<n.parts.length;s++){var l=n.parts[s];i.translate(l.vertices,n.positionImpulse),a.update(l.bounds,l.vertices,n.velocity),l.position.x+=n.positionImpulse.x,l.position.y+=n.positionImpulse.y}n.positionPrev.x+=n.positionImpulse.x,n.positionPrev.y+=n.positionImpulse.y,r.dot(n.positionImpulse,n.velocity)<0?(n.positionImpulse.x=0,n.positionImpulse.y=0):(n.positionImpulse.x*=o._positionWarming,n.positionImpulse.y*=o._positionWarming)}}},o.preSolveVelocity=function(e){var t,n,o,i,s,a,l,c,d,u,p,f,m,v,y=r._temp[0],g=r._temp[1];for(t=0;t<e.length;t++)if(o=e[t],o.isActive&&!o.isSensor)for(i=o.activeContacts,s=o.collision,a=s.parentA,l=s.parentB,c=s.normal,d=s.tangent,n=0;n<i.length;n++)u=i[n],p=u.vertex,f=u.normalImpulse,m=u.tangentImpulse,0===f&&0===m||(y.x=c.x*f+d.x*m,y.y=c.y*f+d.y*m,a.isStatic||a.isSleeping||(v=r.sub(p,a.position,g),a.positionPrev.x+=y.x*a.inverseMass,a.positionPrev.y+=y.y*a.inverseMass,
a.anglePrev+=r.cross(v,y)*a.inverseInertia),l.isStatic||l.isSleeping||(v=r.sub(p,l.position,g),l.positionPrev.x-=y.x*l.inverseMass,l.positionPrev.y-=y.y*l.inverseMass,l.anglePrev-=r.cross(v,y)*l.inverseInertia))},o.solveVelocity=function(e,t){for(var n=t*t,i=r._temp[0],a=r._temp[1],l=r._temp[2],c=r._temp[3],d=r._temp[4],u=r._temp[5],p=0;p<e.length;p++){var f=e[p];if(f.isActive&&!f.isSensor){var m=f.collision,v=m.parentA,y=m.parentB,g=m.normal,x=m.tangent,h=f.activeContacts,b=1/h.length;v.velocity.x=v.position.x-v.positionPrev.x,v.velocity.y=v.position.y-v.positionPrev.y,y.velocity.x=y.position.x-y.positionPrev.x,y.velocity.y=y.position.y-y.positionPrev.y,v.angularVelocity=v.angle-v.anglePrev,y.angularVelocity=y.angle-y.anglePrev;for(var w=0;w<h.length;w++){
var S=h[w],C=S.vertex,A=r.sub(C,v.position,a),P=r.sub(C,y.position,l),B=r.add(v.velocity,r.mult(r.perp(A),v.angularVelocity),c),M=r.add(y.velocity,r.mult(r.perp(P),y.angularVelocity),d),k=r.sub(B,M,u),I=r.dot(g,k),_=r.dot(x,k),T=Math.abs(_),R=s.sign(_),V=(1+f.restitution)*I,E=s.clamp(f.separation+I,0,1)*o._frictionNormalMultiplier,L=_,F=1/0;T>f.friction*f.frictionStatic*E*n&&(F=T,L=s.clamp(f.friction*R*n,-F,F));var O=r.cross(A,g),q=r.cross(P,g),W=b/(v.inverseMass+y.inverseMass+v.inverseInertia*O*O+y.inverseInertia*q*q);if(V*=W,L*=W,I<0&&I*I>o._restingThresh*n)S.normalImpulse=0;else{var D=S.normalImpulse;S.normalImpulse=Math.min(S.normalImpulse+V,0),V=S.normalImpulse-D}if(_*_>o._restingThreshTangent*n)S.tangentImpulse=0;else{var N=S.tangentImpulse;S.tangentImpulse=s.clamp(S.tangentImpulse+L,-F,F),L=S.tangentImpulse-N}i.x=g.x*V+x.x*L,i.y=g.y*V+x.y*L,v.isStatic||v.isSleeping||(v.positionPrev.x+=i.x*v.inverseMass,v.positionPrev.y+=i.y*v.inverseMass,
v.anglePrev+=r.cross(A,i)*v.inverseInertia),y.isStatic||y.isSleeping||(y.positionPrev.x-=i.x*y.inverseMass,y.positionPrev.y-=i.y*y.inverseMass,y.anglePrev-=r.cross(P,i)*y.inverseInertia)}}}}}()},{"../core/Common":14,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],11:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector");!function(){o.collides=function(e,t,n){var s,a,l,c,d=!1;if(n){var u=e.parent,p=t.parent,f=u.speed*u.speed+u.angularSpeed*u.angularSpeed+p.speed*p.speed+p.angularSpeed*p.angularSpeed;d=n&&n.collided&&f<.2,c=n}else c={collided:!1,bodyA:e,bodyB:t};if(n&&d){var m=c.axisBody,v=m===e?t:e,y=[m.axes[n.axisNumber]];if(l=o._overlapAxes(m.vertices,v.vertices,y),c.reused=!0,l.overlap<=0)return c.collided=!1,c}else{if(s=o._overlapAxes(e.vertices,t.vertices,e.axes),s.overlap<=0)return c.collided=!1,c;if(a=o._overlapAxes(t.vertices,e.vertices,t.axes),a.overlap<=0)return c.collided=!1,c;s.overlap<a.overlap?(l=s,
c.axisBody=e):(l=a,c.axisBody=t),c.axisNumber=l.axisNumber}c.bodyA=e.id<t.id?e:t,c.bodyB=e.id<t.id?t:e,c.collided=!0,c.depth=l.overlap,c.parentA=c.bodyA.parent,c.parentB=c.bodyB.parent,e=c.bodyA,t=c.bodyB,r.dot(l.axis,r.sub(t.position,e.position))<0?c.normal={x:l.axis.x,y:l.axis.y}:c.normal={x:-l.axis.x,y:-l.axis.y},c.tangent=r.perp(c.normal),c.penetration=c.penetration||{},c.penetration.x=c.normal.x*c.depth,c.penetration.y=c.normal.y*c.depth;var g=o._findSupports(e,t,c.normal),x=[];if(i.contains(e.vertices,g[0])&&x.push(g[0]),i.contains(e.vertices,g[1])&&x.push(g[1]),x.length<2){var h=o._findSupports(t,e,r.neg(c.normal));i.contains(t.vertices,h[0])&&x.push(h[0]),x.length<2&&i.contains(t.vertices,h[1])&&x.push(h[1])}return x.length<1&&(x=[g[0]]),c.supports=x,c},o._overlapAxes=function(e,t,n){for(var i,s,a=r._temp[0],l=r._temp[1],c={overlap:Number.MAX_VALUE},d=0;d<n.length;d++){if(s=n[d],o._projectToAxis(a,e,s),o._projectToAxis(l,t,s),
(i=Math.min(a.max-l.min,l.max-a.min))<=0)return c.overlap=i,c;i<c.overlap&&(c.overlap=i,c.axis=s,c.axisNumber=d)}return c},o._projectToAxis=function(e,t,n){for(var o=r.dot(t[0],n),i=o,s=1;s<t.length;s+=1){var a=r.dot(t[s],n);a>i?i=a:a<o&&(o=a)}e.min=o,e.max=i},o._findSupports=function(e,t,n){for(var o,i,s,a,l=Number.MAX_VALUE,c=r._temp[0],d=t.vertices,u=e.position,p=0;p<d.length;p++)i=d[p],c.x=i.x-u.x,c.y=i.y-u.y,(o=-r.dot(n,c))<l&&(l=o,s=i);return i=d[s.index-1>=0?s.index-1:d.length-1],c.x=i.x-u.x,c.y=i.y-u.y,l=-r.dot(n,c),a=i,i=d[(s.index+1)%d.length],c.x=i.x-u.x,c.y=i.y-u.y,o=-r.dot(n,c),o<l&&(a=i),[s,a]}}()},{"../geometry/Vector":28,"../geometry/Vertices":29}],12:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=e("../geometry/Bounds"),l=e("../geometry/Axes"),c=e("../core/Common");!function(){o._warming=.4,o._torqueDampen=1,o._minLength=1e-6,o.create=function(e){var t=e;t.bodyA&&!t.pointA&&(t.pointA={x:0,y:0}),
t.bodyB&&!t.pointB&&(t.pointB={x:0,y:0});var n=t.bodyA?r.add(t.bodyA.position,t.pointA):t.pointA,o=t.bodyB?r.add(t.bodyB.position,t.pointB):t.pointB,i=r.magnitude(r.sub(n,o));t.length=void 0!==t.length?t.length:i,t.id=t.id||c.nextId(),t.label=t.label||"Constraint",t.type="constraint",t.stiffness=t.stiffness||(t.length>0?1:.7),t.damping=t.damping||0,t.angularStiffness=t.angularStiffness||0,t.angleA=t.bodyA?t.bodyA.angle:t.angleA,t.angleB=t.bodyB?t.bodyB.angle:t.angleB,t.plugin={};var s={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===t.length&&t.stiffness>.1?(s.type="pin",s.anchors=!1):t.stiffness<.9&&(s.type="spring"),t.render=c.extend(s,t.render),t},o.preSolveAll=function(e){for(var t=0;t<e.length;t+=1){var n=e[t],o=n.constraintImpulse;n.isStatic||0===o.x&&0===o.y&&0===o.angle||(n.position.x+=o.x,n.position.y+=o.y,n.angle+=o.angle)}},o.solveAll=function(e,t){for(var n=0;n<e.length;n+=1){
var i=e[n],r=!i.bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic;(r||s)&&o.solve(e[n],t)}for(n=0;n<e.length;n+=1)i=e[n],r=!i.bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic,r||s||o.solve(e[n],t)},o.solve=function(e,t){var n=e.bodyA,i=e.bodyB,s=e.pointA,a=e.pointB;if(n||i){n&&!n.isStatic&&(r.rotate(s,n.angle-e.angleA,s),e.angleA=n.angle),i&&!i.isStatic&&(r.rotate(a,i.angle-e.angleB,a),e.angleB=i.angle);var l=s,c=a;if(n&&(l=r.add(n.position,s)),i&&(c=r.add(i.position,a)),l&&c){var d=r.sub(l,c),u=r.magnitude(d);u<o._minLength&&(u=o._minLength);var p,f,m,v,y,g=(u-e.length)/u,x=e.stiffness<1?e.stiffness*t:e.stiffness,h=r.mult(d,g*x),b=(n?n.inverseMass:0)+(i?i.inverseMass:0),w=(n?n.inverseInertia:0)+(i?i.inverseInertia:0),S=b+w;if(e.damping){var C=r.create();m=r.div(d,u),y=r.sub(i&&r.sub(i.position,i.positionPrev)||C,n&&r.sub(n.position,n.positionPrev)||C),v=r.dot(m,y)}n&&!n.isStatic&&(f=n.inverseMass/b,n.constraintImpulse.x-=h.x*f,
n.constraintImpulse.y-=h.y*f,n.position.x-=h.x*f,n.position.y-=h.y*f,e.damping&&(n.positionPrev.x-=e.damping*m.x*v*f,n.positionPrev.y-=e.damping*m.y*v*f),p=r.cross(s,h)/S*o._torqueDampen*n.inverseInertia*(1-e.angularStiffness),n.constraintImpulse.angle-=p,n.angle-=p),i&&!i.isStatic&&(f=i.inverseMass/b,i.constraintImpulse.x+=h.x*f,i.constraintImpulse.y+=h.y*f,i.position.x+=h.x*f,i.position.y+=h.y*f,e.damping&&(i.positionPrev.x+=e.damping*m.x*v*f,i.positionPrev.y+=e.damping*m.y*v*f),p=r.cross(a,h)/S*o._torqueDampen*i.inverseInertia*(1-e.angularStiffness),i.constraintImpulse.angle+=p,i.angle+=p)}}},o.postSolveAll=function(e){for(var t=0;t<e.length;t++){var n=e[t],c=n.constraintImpulse;if(!(n.isStatic||0===c.x&&0===c.y&&0===c.angle)){s.set(n,!1);for(var d=0;d<n.parts.length;d++){var u=n.parts[d];i.translate(u.vertices,c),d>0&&(u.position.x+=c.x,u.position.y+=c.y),0!==c.angle&&(i.rotate(u.vertices,c.angle,n.position),l.rotate(u.axes,c.angle),
d>0&&r.rotateAbout(u.position,c.angle,n.position,u.position)),a.update(u.bounds,u.vertices,n.velocity)}c.angle*=o._warming,c.x*=o._warming,c.y*=o._warming}}}}()},{"../core/Common":14,"../core/Sleeping":22,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],13:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../core/Sleeping"),s=e("../core/Mouse"),a=e("../core/Events"),l=e("../collision/Detector"),c=e("./Constraint"),d=e("../body/Composite"),u=e("../core/Common"),p=e("../geometry/Bounds");!function(){o.create=function(e,t){var n=(e?e.mouse:null)||(t?t.mouse:null);n||(e&&e.render&&e.render.canvas?n=s.create(e.render.canvas):t&&t.element?n=s.create(t.element):(n=s.create(),u.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var i=c.create({label:"Mouse Constraint",pointA:n.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,
render:{strokeStyle:"#90EE90",lineWidth:3}}),r={type:"mouseConstraint",mouse:n,element:null,body:null,constraint:i,collisionFilter:{category:1,mask:4294967295,group:0}},l=u.extend(r,t);return a.on(e,"beforeUpdate",function(){var t=d.allBodies(e.world);o.update(l,t),o._triggerEvents(l)}),l},o.update=function(e,t){var n=e.mouse,o=e.constraint,s=e.body;if(0===n.button){if(o.bodyB)r.set(o.bodyB,!1),o.pointA=n.position;else for(var c=0;c<t.length;c++)if(s=t[c],p.contains(s.bounds,n.position)&&l.canCollide(s.collisionFilter,e.collisionFilter))for(var d=s.parts.length>1?1:0;d<s.parts.length;d++){var u=s.parts[d];if(i.contains(u.vertices,n.position)){o.pointA=n.position,o.bodyB=e.body=s,o.pointB={x:n.position.x-s.position.x,y:n.position.y-s.position.y},o.angleB=s.angle,r.set(s,!1),a.trigger(e,"startdrag",{mouse:n,body:s});break}}}else o.bodyB=e.body=null,o.pointB=null,s&&a.trigger(e,"enddrag",{mouse:n,body:s})},o._triggerEvents=function(e){var t=e.mouse,n=t.sourceEvents
;n.mousemove&&a.trigger(e,"mousemove",{mouse:t}),n.mousedown&&a.trigger(e,"mousedown",{mouse:t}),n.mouseup&&a.trigger(e,"mouseup",{mouse:t}),s.clearSourceEvents(t)}}()},{"../body/Composite":2,"../collision/Detector":5,"../core/Common":14,"../core/Events":16,"../core/Mouse":19,"../core/Sleeping":22,"../geometry/Bounds":26,"../geometry/Vertices":29,"./Constraint":12}],14:[function(e,t,n){(function(n){var o={};t.exports=o,function(){o._nextId=0,o._seed=0,o._nowStartTime=+new Date,o.extend=function(e,t){var n,i;"boolean"==typeof t?(n=2,i=t):(n=1,i=!0);for(var r=n;r<arguments.length;r++){var s=arguments[r];if(s)for(var a in s)i&&s[a]&&s[a].constructor===Object?e[a]&&e[a].constructor!==Object?e[a]=s[a]:(e[a]=e[a]||{},o.extend(e[a],i,s[a])):e[a]=s[a]}return e},o.clone=function(e,t){return o.extend({},t,e)},o.keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var n in e)t.push(n);return t},o.values=function(e){var t=[];if(Object.keys){
for(var n=Object.keys(e),o=0;o<n.length;o++)t.push(e[n[o]]);return t}for(var i in e)t.push(e[i]);return t},o.get=function(e,t,n,o){t=t.split(".").slice(n,o);for(var i=0;i<t.length;i+=1)e=e[t[i]];return e},o.set=function(e,t,n,i,r){var s=t.split(".").slice(i,r);return o.get(e,t,0,-1)[s[s.length-1]]=n,n},o.shuffle=function(e){for(var t=e.length-1;t>0;t--){var n=Math.floor(o.random()*(t+1)),i=e[t];e[t]=e[n],e[n]=i}return e},o.choose=function(e){return e[Math.floor(o.random()*e.length)]},o.isElement=function(e){return"undefined"!=typeof HTMLElement?e instanceof HTMLElement:!!(e&&e.nodeType&&e.nodeName)},o.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},o.isFunction=function(e){return"function"==typeof e},o.isPlainObject=function(e){return"object"==typeof e&&e.constructor===Object},o.isString=function(e){return"[object String]"===toString.call(e)},o.clamp=function(e,t,n){return e<t?t:e>n?n:e},o.sign=function(e){return e<0?-1:1},o.now=function(){
if(window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return new Date-o._nowStartTime},o.random=function(e,n){return e=void 0!==e?e:0,n=void 0!==n?n:1,e+t()*(n-e)};var t=function(){return o._seed=(9301*o._seed+49297)%233280,o._seed/233280};o.colorToNumber=function(e){return e=e.replace("#",""),3==e.length&&(e=e.charAt(0)+e.charAt(0)+e.charAt(1)+e.charAt(1)+e.charAt(2)+e.charAt(2)),parseInt(e,16)},o.logLevel=1,o.log=function(){console&&o.logLevel>0&&o.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.info=function(){console&&o.logLevel>0&&o.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.warn=function(){console&&o.logLevel>0&&o.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.nextId=function(){return o._nextId++},
o.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},o.map=function(e,t){if(e.map)return e.map(t);for(var n=[],o=0;o<e.length;o+=1)n.push(t(e[o]));return n},o.topologicalSort=function(e){var t=[],n=[],i=[];for(var r in e)n[r]||i[r]||o._topologicalSort(r,n,i,e,t);return t},o._topologicalSort=function(e,t,n,i,r){var s=i[e]||[];n[e]=!0;for(var a=0;a<s.length;a+=1){var l=s[a];n[l]||(t[l]||o._topologicalSort(l,t,n,i,r))}n[e]=!1,t[e]=!0,r.push(e)},o.chain=function(){for(var e=[],t=0;t<arguments.length;t+=1){var n=arguments[t];n._chained?e.push.apply(e,n._chained):e.push(n)}var o=function(){for(var t,n=new Array(arguments.length),o=0,i=arguments.length;o<i;o++)n[o]=arguments[o];for(o=0;o<e.length;o+=1){var r=e[o].apply(t,n);void 0!==r&&(t=r)}return t};return o._chained=e,o},o.chainPathBefore=function(e,t,n){return o.set(e,t,o.chain(n,o.get(e,t)))},o.chainPathAfter=function(e,t,n){return o.set(e,t,o.chain(o.get(e,t),n))},
o._requireGlobal=function(t,o){return("undefined"!=typeof window?window[t]:void 0!==n?n[t]:null)||e(o)}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],15:[function(e,t,n){var o={};t.exports=o;var i=e("../body/World"),r=e("./Sleeping"),s=e("../collision/Resolver"),a=e("../render/Render"),l=e("../collision/Pairs"),c=(e("./Metrics"),e("../collision/Grid")),d=e("./Events"),u=e("../body/Composite"),p=e("../constraint/Constraint"),f=e("./Common"),m=e("../body/Body");!function(){o.create=function(e,t){t=f.isElement(e)?t:e,e=f.isElement(e)?e:null,t=t||{},(e||t.render)&&f.warn("Engine.create: engine.render is deprecated (see docs)");var n={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},timing:{timestamp:0,timeScale:1},broadphase:{controller:c}},o=f.extend(n,t);if(e||o.render){var r={element:e,controller:a};o.render=f.extend(r,o.render)}
return o.render&&o.render.controller&&(o.render=o.render.controller.create(o.render)),o.render&&(o.render.engine=o),o.world=t.world||i.create(o.world),o.pairs=l.create(),o.broadphase=o.broadphase.controller.create(o.broadphase),o.metrics=o.metrics||{extended:!1},o},o.update=function(e,t,n){t=t||1e3/60,n=n||1;var i,a=e.world,c=e.timing,f=e.broadphase,m=[];c.timestamp+=t*c.timeScale;var v={timestamp:c.timestamp};d.trigger(e,"beforeUpdate",v);var y=u.allBodies(a),g=u.allConstraints(a);for(e.enableSleeping&&r.update(y,c.timeScale),o._bodiesApplyGravity(y,a.gravity),o._bodiesUpdate(y,t,c.timeScale,n,a.bounds),p.preSolveAll(y),i=0;i<e.constraintIterations;i++)p.solveAll(g,c.timeScale);p.postSolveAll(y),f.controller?(a.isModified&&f.controller.clear(f),f.controller.update(f,y,e,a.isModified),m=f.pairsList):m=y,a.isModified&&u.setModified(a,!1,!1,!0);var x=f.detector(m,e),h=e.pairs,b=c.timestamp;for(l.update(h,x,b),l.removeOld(h,b),e.enableSleeping&&r.afterCollisions(h.list,c.timeScale),
h.collisionStart.length>0&&d.trigger(e,"collisionStart",{pairs:h.collisionStart}),s.preSolvePosition(h.list),i=0;i<e.positionIterations;i++)s.solvePosition(h.list,c.timeScale);for(s.postSolvePosition(y),p.preSolveAll(y),i=0;i<e.constraintIterations;i++)p.solveAll(g,c.timeScale);for(p.postSolveAll(y),s.preSolveVelocity(h.list),i=0;i<e.velocityIterations;i++)s.solveVelocity(h.list,c.timeScale);return h.collisionActive.length>0&&d.trigger(e,"collisionActive",{pairs:h.collisionActive}),h.collisionEnd.length>0&&d.trigger(e,"collisionEnd",{pairs:h.collisionEnd}),o._bodiesClearForces(y),d.trigger(e,"afterUpdate",v),e},o.merge=function(e,t){if(f.extend(e,t),t.world){e.world=t.world,o.clear(e);for(var n=u.allBodies(e.world),i=0;i<n.length;i++){var s=n[i];r.set(s,!1),s.id=f.nextId()}}},o.clear=function(e){var t=e.world;l.clear(e.pairs);var n=e.broadphase;if(n.controller){var o=u.allBodies(t);n.controller.clear(n),n.controller.update(n,o,e,!0)}},o._bodiesClearForces=function(e){
for(var t=0;t<e.length;t++){var n=e[t];n.force.x=0,n.force.y=0,n.torque=0}},o._bodiesApplyGravity=function(e,t){var n=void 0!==t.scale?t.scale:.001;if((0!==t.x||0!==t.y)&&0!==n)for(var o=0;o<e.length;o++){var i=e[o];i.isStatic||i.isSleeping||(i.force.y+=i.mass*t.y*n,i.force.x+=i.mass*t.x*n)}},o._bodiesUpdate=function(e,t,n,o,i){for(var r=0;r<e.length;r++){var s=e[r];s.isStatic||s.isSleeping||m.update(s,t,n,o)}}}()},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Grid":6,"../collision/Pairs":8,"../collision/Resolver":10,"../constraint/Constraint":12,"../render/Render":31,"./Common":14,"./Events":16,"./Metrics":18,"./Sleeping":22}],16:[function(e,t,n){var o={};t.exports=o;var i=e("./Common");!function(){o.on=function(e,t,n){for(var o,i=t.split(" "),r=0;r<i.length;r++)o=i[r],e.events=e.events||{},e.events[o]=e.events[o]||[],e.events[o].push(n);return n},o.off=function(e,t,n){if(!t)return void(e.events={});"function"==typeof t&&(n=t,t=i.keys(e.events).join(" "))
;for(var o=t.split(" "),r=0;r<o.length;r++){var s=e.events[o[r]],a=[];if(n&&s)for(var l=0;l<s.length;l++)s[l]!==n&&a.push(s[l]);e.events[o[r]]=a}},o.trigger=function(e,t,n){var o,r,s,a;if(e.events){n||(n={}),o=t.split(" ");for(var l=0;l<o.length;l++)if(r=o[l],s=e.events[r]){a=i.clone(n,!1),a.name=r,a.source=e;for(var c=0;c<s.length;c++)s[c].apply(e,[a])}}}}()},{"./Common":14}],17:[function(e,t,n){var o={};t.exports=o;var i=e("./Plugin"),r=e("./Common");!function(){o.name="matter-js",o.version="0.14.2",o.uses=[],o.used=[],o.use=function(){i.use(o,Array.prototype.slice.call(arguments))},o.before=function(e,t){return e=e.replace(/^Matter./,""),r.chainPathBefore(o,e,t)},o.after=function(e,t){return e=e.replace(/^Matter./,""),r.chainPathAfter(o,e,t)}}()},{"./Common":14,"./Plugin":20}],18:[function(e,t,n){},{"../body/Composite":2,"./Common":14}],19:[function(e,t,n){var o={};t.exports=o;var i=e("../core/Common");!function(){o.create=function(e){var t={}
;return e||i.log("Mouse.create: element was undefined, defaulting to document.body","warn"),t.element=e||document.body,t.absolute={x:0,y:0},t.position={x:0,y:0},t.mousedownPosition={x:0,y:0},t.mouseupPosition={x:0,y:0},t.offset={x:0,y:0},t.scale={x:1,y:1},t.wheelDelta=0,t.button=-1,t.pixelRatio=t.element.getAttribute("data-pixel-ratio")||1,t.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},t.mousemove=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&(t.button=0,e.preventDefault()),t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.sourceEvents.mousemove=e},t.mousedown=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches?(t.button=0,e.preventDefault()):t.button=e.button,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,
t.mousedownPosition.x=t.position.x,t.mousedownPosition.y=t.position.y,t.sourceEvents.mousedown=e},t.mouseup=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&e.preventDefault(),t.button=-1,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.mouseupPosition.x=t.position.x,t.mouseupPosition.y=t.position.y,t.sourceEvents.mouseup=e},t.mousewheel=function(e){t.wheelDelta=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),e.preventDefault()},o.setElement(t,t.element),t},o.setElement=function(e,t){e.element=t,t.addEventListener("mousemove",e.mousemove),t.addEventListener("mousedown",e.mousedown),t.addEventListener("mouseup",e.mouseup),t.addEventListener("mousewheel",e.mousewheel),t.addEventListener("DOMMouseScroll",e.mousewheel),t.addEventListener("touchmove",e.mousemove),t.addEventListener("touchstart",e.mousedown),t.addEventListener("touchend",e.mouseup)},
o.clearSourceEvents=function(e){e.sourceEvents.mousemove=null,e.sourceEvents.mousedown=null,e.sourceEvents.mouseup=null,e.sourceEvents.mousewheel=null,e.wheelDelta=0},o.setOffset=function(e,t){e.offset.x=t.x,e.offset.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},o.setScale=function(e,t){e.scale.x=t.x,e.scale.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},o._getRelativeMousePosition=function(e,t,n){var o,i,r=t.getBoundingClientRect(),s=document.documentElement||document.body.parentNode||document.body,a=void 0!==window.pageXOffset?window.pageXOffset:s.scrollLeft,l=void 0!==window.pageYOffset?window.pageYOffset:s.scrollTop,c=e.changedTouches;return c?(o=c[0].pageX-r.left-a,i=c[0].pageY-r.top-l):(o=e.pageX-r.left-a,i=e.pageY-r.top-l),{x:o/(t.clientWidth/(t.width||t.clientWidth)*n),y:i/(t.clientHeight/(t.height||t.clientHeight)*n)}}}()},{"../core/Common":14}],20:[function(e,t,n){
var o={};t.exports=o;var i=e("./Common");!function(){o._registry={},o.register=function(e){if(o.isPlugin(e)||i.warn("Plugin.register:",o.toString(e),"does not implement all required fields."),e.name in o._registry){var t=o._registry[e.name],n=o.versionParse(e.version).number,r=o.versionParse(t.version).number;n>r?(i.warn("Plugin.register:",o.toString(t),"was upgraded to",o.toString(e)),o._registry[e.name]=e):n<r?i.warn("Plugin.register:",o.toString(t),"can not be downgraded to",o.toString(e)):e!==t&&i.warn("Plugin.register:",o.toString(e),"is already registered to different plugin object")}else o._registry[e.name]=e;return e},o.resolve=function(e){return o._registry[o.dependencyParse(e).name]},o.toString=function(e){return"string"==typeof e?e:(e.name||"anonymous")+"@"+(e.version||e.range||"0.0.0")},o.isPlugin=function(e){return e&&e.name&&e.version&&e.install},o.isUsed=function(e,t){return e.used.indexOf(t)>-1},o.isFor=function(e,t){var n=e.for&&o.dependencyParse(e.for)
;return!e.for||t.name===n.name&&o.versionSatisfies(t.version,n.range)},o.use=function(e,t){if(e.uses=(e.uses||[]).concat(t||[]),0===e.uses.length)return void i.warn("Plugin.use:",o.toString(e),"does not specify any dependencies to install.");for(var n=o.dependencies(e),r=i.topologicalSort(n),s=[],a=0;a<r.length;a+=1)if(r[a]!==e.name){var l=o.resolve(r[a]);l?o.isUsed(e,l.name)||(o.isFor(l,e)||(i.warn("Plugin.use:",o.toString(l),"is for",l.for,"but installed on",o.toString(e)+"."),l._warned=!0),l.install?l.install(e):(i.warn("Plugin.use:",o.toString(l),"does not specify an install function."),l._warned=!0),l._warned?(s.push("🔶 "+o.toString(l)),delete l._warned):s.push("✅ "+o.toString(l)),e.used.push(l.name)):s.push("❌ "+r[a])}s.length>0&&i.info(s.join(" "))},o.dependencies=function(e,t){var n=o.dependencyParse(e),r=n.name;if(t=t||{},!(r in t)){e=o.resolve(e)||e,t[r]=i.map(e.uses||[],function(t){o.isPlugin(t)&&o.register(t);var r=o.dependencyParse(t),s=o.resolve(t)
;return s&&!o.versionSatisfies(s.version,r.range)?(i.warn("Plugin.dependencies:",o.toString(s),"does not satisfy",o.toString(r),"used by",o.toString(n)+"."),s._warned=!0,e._warned=!0):s||(i.warn("Plugin.dependencies:",o.toString(t),"used by",o.toString(n),"could not be resolved."),e._warned=!0),r.name});for(var s=0;s<t[r].length;s+=1)o.dependencies(t[r][s],t);return t}},o.dependencyParse=function(e){if(i.isString(e)){return/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?))?$/.test(e)||i.warn("Plugin.dependencyParse:",e,"is not a valid dependency string."),{name:e.split("@")[0],range:e.split("@")[1]||"*"}}return{name:e.name,range:e.range||e.version}},o.versionParse=function(e){/^\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/.test(e)||i.warn("Plugin.versionParse:",e,"is not a valid version or range.");var t=e.split("-");e=t[0];var n=isNaN(Number(e[0])),o=n?e.substr(1):e,r=i.map(o.split("."),function(e){return Number(e)});return{isRange:n,version:o,range:e,operator:n?e[0]:"",parts:r,
prerelease:t[1],number:1e8*r[0]+1e4*r[1]+r[2]}},o.versionSatisfies=function(e,t){t=t||"*";var n=o.versionParse(t),i=n.parts,r=o.versionParse(e),s=r.parts;if(n.isRange){if("*"===n.operator||"*"===e)return!0;if("~"===n.operator)return s[0]===i[0]&&s[1]===i[1]&&s[2]>=i[2];if("^"===n.operator)return i[0]>0?s[0]===i[0]&&r.number>=n.number:i[1]>0?s[1]===i[1]&&s[2]>=i[2]:s[2]===i[2]}return e===t||"*"===e}}()},{"./Common":14}],21:[function(e,t,n){var o={};t.exports=o;var i=e("./Events"),r=e("./Engine"),s=e("./Common");!function(){var e,t;if("undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),!e){var n;e=function(e){n=setTimeout(function(){e(s.now())},1e3/60)},t=function(){clearTimeout(n)}}o.create=function(e){var t={fps:60,correction:1,deltaSampleSize:60,
counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,timeScalePrev:1,frameRequestId:null,isFixed:!1,enabled:!0},n=s.extend(t,e);return n.delta=n.delta||1e3/n.fps,n.deltaMin=n.deltaMin||1e3/n.fps,n.deltaMax=n.deltaMax||1e3/(.5*n.fps),n.fps=1e3/n.delta,n},o.run=function(t,n){return void 0!==t.positionIterations&&(n=t,t=o.create()),function i(r){t.frameRequestId=e(i),r&&t.enabled&&o.tick(t,n,r)}(),t},o.tick=function(e,t,n){var o,s=t.timing,a=1,l={timestamp:s.timestamp};i.trigger(e,"beforeTick",l),i.trigger(t,"beforeTick",l),e.isFixed?o=e.delta:(o=n-e.timePrev||e.delta,e.timePrev=n,e.deltaHistory.push(o),e.deltaHistory=e.deltaHistory.slice(-e.deltaSampleSize),o=Math.min.apply(null,e.deltaHistory),o=o<e.deltaMin?e.deltaMin:o,o=o>e.deltaMax?e.deltaMax:o,a=o/e.delta,e.delta=o),0!==e.timeScalePrev&&(a*=s.timeScale/e.timeScalePrev),0===s.timeScale&&(a=0),e.timeScalePrev=s.timeScale,e.correction=a,e.frameCounter+=1,
n-e.counterTimestamp>=1e3&&(e.fps=e.frameCounter*((n-e.counterTimestamp)/1e3),e.counterTimestamp=n,e.frameCounter=0),i.trigger(e,"tick",l),i.trigger(t,"tick",l),t.world.isModified&&t.render&&t.render.controller&&t.render.controller.clear&&t.render.controller.clear(t.render),i.trigger(e,"beforeUpdate",l),r.update(t,o,a),i.trigger(e,"afterUpdate",l),t.render&&t.render.controller&&(i.trigger(e,"beforeRender",l),i.trigger(t,"beforeRender",l),t.render.controller.world(t.render),i.trigger(e,"afterRender",l),i.trigger(t,"afterRender",l)),i.trigger(e,"afterTick",l),i.trigger(t,"afterTick",l)},o.stop=function(e){t(e.frameRequestId)},o.start=function(e,t){o.run(e,t)}}()},{"./Common":14,"./Engine":15,"./Events":16}],22:[function(e,t,n){var o={};t.exports=o;var i=e("./Events");!function(){o._motionWakeThreshold=.18,o._motionSleepThreshold=.08,o._minBias=.9,o.update=function(e,t){for(var n=t*t*t,i=0;i<e.length;i++){var r=e[i],s=r.speed*r.speed+r.angularSpeed*r.angularSpeed
;if(0===r.force.x&&0===r.force.y){var a=Math.min(r.motion,s),l=Math.max(r.motion,s);r.motion=o._minBias*a+(1-o._minBias)*l,r.sleepThreshold>0&&r.motion<o._motionSleepThreshold*n?(r.sleepCounter+=1,r.sleepCounter>=r.sleepThreshold&&o.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else o.set(r,!1)}},o.afterCollisions=function(e,t){for(var n=t*t*t,i=0;i<e.length;i++){var r=e[i];if(r.isActive){var s=r.collision,a=s.bodyA.parent,l=s.bodyB.parent;if(!(a.isSleeping&&l.isSleeping||a.isStatic||l.isStatic)&&(a.isSleeping||l.isSleeping)){var c=a.isSleeping&&!a.isStatic?a:l,d=c===a?l:a;!c.isStatic&&d.motion>o._motionWakeThreshold*n&&o.set(c,!1)}}}},o.set=function(e,t){var n=e.isSleeping;t?(e.isSleeping=!0,e.sleepCounter=e.sleepThreshold,e.positionImpulse.x=0,e.positionImpulse.y=0,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.anglePrev=e.angle,e.speed=0,e.angularSpeed=0,e.motion=0,n||i.trigger(e,"sleepStart")):(e.isSleeping=!1,e.sleepCounter=0,n&&i.trigger(e,"sleepEnd"))}}()},{
"./Events":16}],23:[function(e,t,n){var o={};t.exports=o;var i,r=e("../geometry/Vertices"),s=e("../core/Common"),a=e("../body/Body"),l=e("../geometry/Bounds"),c=e("../geometry/Vector");!function(){o.rectangle=function(e,t,n,o,i){i=i||{};var l={label:"Rectangle Body",position:{x:e,y:t},vertices:r.fromPath("L 0 0 L "+n+" 0 L "+n+" "+o+" L 0 "+o)};if(i.chamfer){var c=i.chamfer;l.vertices=r.chamfer(l.vertices,c.radius,c.quality,c.qualityMin,c.qualityMax),delete i.chamfer}return a.create(s.extend({},l,i))},o.trapezoid=function(e,t,n,o,i,l){l=l||{},i*=.5;var c,d=(1-2*i)*n,u=n*i,p=u+d,f=p+u;c=i<.5?"L 0 0 L "+u+" "+-o+" L "+p+" "+-o+" L "+f+" 0":"L 0 0 L "+p+" "+-o+" L "+f+" 0";var m={label:"Trapezoid Body",position:{x:e,y:t},vertices:r.fromPath(c)};if(l.chamfer){var v=l.chamfer;m.vertices=r.chamfer(m.vertices,v.radius,v.quality,v.qualityMin,v.qualityMax),delete l.chamfer}return a.create(s.extend({},m,l))},o.circle=function(e,t,n,i,r){i=i||{};var a={label:"Circle Body",circleRadius:n};r=r||25
;var l=Math.ceil(Math.max(10,Math.min(r,n)));return l%2==1&&(l+=1),o.polygon(e,t,l,n,s.extend({},a,i))},o.polygon=function(e,t,n,i,l){if(l=l||{},n<3)return o.circle(e,t,i,l);for(var c=2*Math.PI/n,d="",u=.5*c,p=0;p<n;p+=1){var f=u+p*c,m=Math.cos(f)*i,v=Math.sin(f)*i;d+="L "+m.toFixed(3)+" "+v.toFixed(3)+" "}var y={label:"Polygon Body",position:{x:e,y:t},vertices:r.fromPath(d)};if(l.chamfer){var g=l.chamfer;y.vertices=r.chamfer(y.vertices,g.radius,g.quality,g.qualityMin,g.qualityMax),delete l.chamfer}return a.create(s.extend({},y,l))},o.fromVertices=function(e,t,n,o,d,u,p){i||(i=s._requireGlobal("decomp","poly-decomp"));var f,m,v,y,g,x,h,b,w;for(o=o||{},m=[],d=void 0!==d&&d,u=void 0!==u?u:.01,p=void 0!==p?p:10,i||s.warn("Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull."),s.isArray(n[0])||(n=[n]),b=0;b<n.length;b+=1)if(y=n[b],(v=r.isConvex(y))||!i)y=v?r.clockwiseSort(y):r.hull(y),m.push({position:{x:e,y:t},vertices:y});else{
var S=y.map(function(e){return[e.x,e.y]});i.makeCCW(S),!1!==u&&i.removeCollinearPoints(S,u);var C=i.quickDecomp(S);for(g=0;g<C.length;g++){var A=C[g],P=A.map(function(e){return{x:e[0],y:e[1]}});p>0&&r.area(P)<p||m.push({position:r.centre(P),vertices:P})}}for(g=0;g<m.length;g++)m[g]=a.create(s.extend(m[g],o));if(d){for(g=0;g<m.length;g++){var B=m[g];for(x=g+1;x<m.length;x++){var M=m[x];if(l.overlaps(B.bounds,M.bounds)){var k=B.vertices,I=M.vertices;for(h=0;h<B.vertices.length;h++)for(w=0;w<M.vertices.length;w++){var _=c.magnitudeSquared(c.sub(k[(h+1)%k.length],I[w])),T=c.magnitudeSquared(c.sub(k[h],I[(w+1)%I.length]));_<5&&T<5&&(k[h].isInternal=!0,I[w].isInternal=!0)}}}}}return m.length>1?(f=a.create(s.extend({parts:m.slice(0)},o)),a.setPosition(f,{x:e,y:t}),f):m[0]}}()},{"../body/Body":1,"../core/Common":14,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],24:[function(e,t,n){var o={};t.exports=o
;var i=e("../body/Composite"),r=e("../constraint/Constraint"),s=e("../core/Common"),a=e("../body/Body"),l=e("./Bodies");!function(){o.stack=function(e,t,n,o,r,s,l){for(var c,d=i.create({label:"Stack"}),u=e,p=t,f=0,m=0;m<o;m++){for(var v=0,y=0;y<n;y++){var g=l(u,p,y,m,c,f);if(g){var x=g.bounds.max.y-g.bounds.min.y,h=g.bounds.max.x-g.bounds.min.x;x>v&&(v=x),a.translate(g,{x:.5*h,y:.5*x}),u=g.bounds.max.x+r,i.addBody(d,g),c=g,f+=1}else u+=r}p+=v+s,u=e}return d},o.chain=function(e,t,n,o,a,l){for(var c=e.bodies,d=1;d<c.length;d++){var u=c[d-1],p=c[d],f=u.bounds.max.y-u.bounds.min.y,m=u.bounds.max.x-u.bounds.min.x,v=p.bounds.max.y-p.bounds.min.y,y=p.bounds.max.x-p.bounds.min.x,g={bodyA:u,pointA:{x:m*t,y:f*n},bodyB:p,pointB:{x:y*o,y:v*a}},x=s.extend(g,l);i.addConstraint(e,r.create(x))}return e.label+=" Chain",e},o.mesh=function(e,t,n,o,a){var l,c,d,u,p,f=e.bodies;for(l=0;l<n;l++){for(c=1;c<t;c++)d=f[c-1+l*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a)))
;if(l>0)for(c=0;c<t;c++)d=f[c+(l-1)*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a))),o&&c>0&&(p=f[c-1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a)))),o&&c<t-1&&(p=f[c+1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a))))}return e.label+=" Mesh",e},o.pyramid=function(e,t,n,i,r,s,l){return o.stack(e,t,n,i,r,s,function(t,o,s,c,d,u){var p=Math.min(i,Math.ceil(n/2)),f=d?d.bounds.max.x-d.bounds.min.x:0;if(!(c>p)){c=p-c;var m=c,v=n-1-c;if(!(s<m||s>v)){1===u&&a.translate(d,{x:(s+(n%2==1?1:-1))*f,y:0});return l(e+(d?s*f:0)+s*r,o,s,c,d,u)}}})},o.newtonsCradle=function(e,t,n,o,s){for(var a=i.create({label:"Newtons Cradle"}),c=0;c<n;c++){var d=l.circle(e+c*(1.9*o),t+s,o,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),u=r.create({pointA:{x:e+c*(1.9*o),y:t},bodyB:d});i.addBody(a,d),i.addConstraint(a,u)}return a},o.car=function(e,t,n,o,s){var c=a.nextGroup(!0),d=.5*-n+20,u=.5*n-20,p=i.create({label:"Car"
}),f=l.rectangle(e,t,n,o,{collisionFilter:{group:c},chamfer:{radius:.5*o},density:2e-4}),m=l.circle(e+d,t+0,s,{collisionFilter:{group:c},friction:.8}),v=l.circle(e+u,t+0,s,{collisionFilter:{group:c},friction:.8}),y=r.create({bodyB:f,pointB:{x:d,y:0},bodyA:m,stiffness:1,length:0}),g=r.create({bodyB:f,pointB:{x:u,y:0},bodyA:v,stiffness:1,length:0});return i.addBody(p,f),i.addBody(p,m),i.addBody(p,v),i.addConstraint(p,y),i.addConstraint(p,g),p},o.softBody=function(e,t,n,i,r,a,c,d,u,p){u=s.extend({inertia:1/0},u),p=s.extend({stiffness:.2,render:{type:"line",anchors:!1}},p);var f=o.stack(e,t,n,i,r,a,function(e,t){return l.circle(e,t,d,u)});return o.mesh(f,n,i,c,p),f.label="Soft Body",f}}()},{"../body/Body":1,"../body/Composite":2,"../constraint/Constraint":12,"../core/Common":14,"./Bodies":23}],25:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){o.fromVertices=function(e){for(var t={},n=0;n<e.length;n++){
var o=(n+1)%e.length,s=i.normalise({x:e[o].y-e[n].y,y:e[n].x-e[o].x}),a=0===s.y?1/0:s.x/s.y;a=a.toFixed(3).toString(),t[a]=s}return r.values(t)},o.rotate=function(e,t){if(0!==t)for(var n=Math.cos(t),o=Math.sin(t),i=0;i<e.length;i++){var r,s=e[i];r=s.x*n-s.y*o,s.y=s.x*o+s.y*n,s.x=r}}}()},{"../core/Common":14,"../geometry/Vector":28}],26:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e){var t={min:{x:0,y:0},max:{x:0,y:0}};return e&&o.update(t,e),t},o.update=function(e,t,n){e.min.x=1/0,e.max.x=-1/0,e.min.y=1/0,e.max.y=-1/0;for(var o=0;o<t.length;o++){var i=t[o];i.x>e.max.x&&(e.max.x=i.x),i.x<e.min.x&&(e.min.x=i.x),i.y>e.max.y&&(e.max.y=i.y),i.y<e.min.y&&(e.min.y=i.y)}n&&(n.x>0?e.max.x+=n.x:e.min.x+=n.x,n.y>0?e.max.y+=n.y:e.min.y+=n.y)},o.contains=function(e,t){return t.x>=e.min.x&&t.x<=e.max.x&&t.y>=e.min.y&&t.y<=e.max.y},o.overlaps=function(e,t){return e.min.x<=t.max.x&&e.max.x>=t.min.x&&e.max.y>=t.min.y&&e.min.y<=t.max.y},o.translate=function(e,t){e.min.x+=t.x,
e.max.x+=t.x,e.min.y+=t.y,e.max.y+=t.y},o.shift=function(e,t){var n=e.max.x-e.min.x,o=e.max.y-e.min.y;e.min.x=t.x,e.max.x=t.x+n,e.min.y=t.y,e.max.y=t.y+o}}()},{}],27:[function(e,t,n){var o={};t.exports=o;var i=(e("../geometry/Bounds"),e("../core/Common"));!function(){o.pathToVertices=function(e,t){"undefined"==typeof window||"SVGPathSeg"in window||i.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var n,r,s,a,l,c,d,u,p,f,m,v,y=[],g=0,x=0,h=0;t=t||15;var b=function(e,t,n){var o=n%2==1&&n>1;if(!p||e!=p.x||t!=p.y){p&&o?(m=p.x,v=p.y):(m=0,v=0);var i={x:m+e,y:v+t};!o&&p||(p=i),y.push(i),x=m+e,h=v+t}},w=function(e){var t=e.pathSegTypeAsLetter.toUpperCase();if("Z"!==t){switch(t){case"M":case"L":case"T":case"C":case"S":case"Q":x=e.x,h=e.y;break;case"H":x=e.x;break;case"V":h=e.y}b(x,h,e.pathSegType)}};for(o._svgPathToAbsolute(e),s=e.getTotalLength(),c=[],n=0;n<e.pathSegList.numberOfItems;n+=1)c.push(e.pathSegList.getItem(n));for(d=c.concat();g<s;){
if(f=e.getPathSegAtLength(g),(l=c[f])!=u){for(;d.length&&d[0]!=l;)w(d.shift());u=l}switch(l.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":a=e.getPointAtLength(g),b(a.x,a.y,0)}g+=t}for(n=0,r=d.length;n<r;++n)w(d[n]);return y},o._svgPathToAbsolute=function(e){for(var t,n,o,i,r,s,a=e.pathSegList,l=0,c=0,d=a.numberOfItems,u=0;u<d;++u){var p=a.getItem(u),f=p.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(f))"x"in p&&(l=p.x),"y"in p&&(c=p.y);else switch("x1"in p&&(o=l+p.x1),"x2"in p&&(r=l+p.x2),"y1"in p&&(i=c+p.y1),"y2"in p&&(s=c+p.y2),"x"in p&&(l+=p.x),"y"in p&&(c+=p.y),f){case"m":a.replaceItem(e.createSVGPathSegMovetoAbs(l,c),u);break;case"l":a.replaceItem(e.createSVGPathSegLinetoAbs(l,c),u);break;case"h":a.replaceItem(e.createSVGPathSegLinetoHorizontalAbs(l),u);break;case"v":a.replaceItem(e.createSVGPathSegLinetoVerticalAbs(c),u);break;case"c":a.replaceItem(e.createSVGPathSegCurvetoCubicAbs(l,c,o,i,r,s),u);break;case"s":
a.replaceItem(e.createSVGPathSegCurvetoCubicSmoothAbs(l,c,r,s),u);break;case"q":a.replaceItem(e.createSVGPathSegCurvetoQuadraticAbs(l,c,o,i),u);break;case"t":a.replaceItem(e.createSVGPathSegCurvetoQuadraticSmoothAbs(l,c),u);break;case"a":a.replaceItem(e.createSVGPathSegArcAbs(l,c,p.r1,p.r2,p.angle,p.largeArcFlag,p.sweepFlag),u);break;case"z":case"Z":l=t,c=n}"M"!=f&&"m"!=f||(t=l,n=c)}}}()},{"../core/Common":14,"../geometry/Bounds":26}],28:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e,t){return{x:e||0,y:t||0}},o.clone=function(e){return{x:e.x,y:e.y}},o.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},o.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},o.rotate=function(e,t,n){var o=Math.cos(t),i=Math.sin(t);n||(n={});var r=e.x*o-e.y*i;return n.y=e.x*i+e.y*o,n.x=r,n},o.rotateAbout=function(e,t,n,o){var i=Math.cos(t),r=Math.sin(t);o||(o={});var s=n.x+((e.x-n.x)*i-(e.y-n.y)*r);return o.y=n.y+((e.x-n.x)*r+(e.y-n.y)*i),o.x=s,o},o.normalise=function(e){
var t=o.magnitude(e);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}},o.dot=function(e,t){return e.x*t.x+e.y*t.y},o.cross=function(e,t){return e.x*t.y-e.y*t.x},o.cross3=function(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)},o.add=function(e,t,n){return n||(n={}),n.x=e.x+t.x,n.y=e.y+t.y,n},o.sub=function(e,t,n){return n||(n={}),n.x=e.x-t.x,n.y=e.y-t.y,n},o.mult=function(e,t){return{x:e.x*t,y:e.y*t}},o.div=function(e,t){return{x:e.x/t,y:e.y/t}},o.perp=function(e,t){return t=!0===t?-1:1,{x:t*-e.y,y:t*e.x}},o.neg=function(e){return{x:-e.x,y:-e.y}},o.angle=function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)},o._temp=[o.create(),o.create(),o.create(),o.create(),o.create(),o.create()]}()},{}],29:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){o.create=function(e,t){for(var n=[],o=0;o<e.length;o++){var i=e[o],r={x:i.x,y:i.y,index:o,body:t,isInternal:!1};n.push(r)}return n},o.fromPath=function(e,t){
var n=/L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/gi,i=[];return e.replace(n,function(e,t,n){i.push({x:parseFloat(t),y:parseFloat(n)})}),o.create(i,t)},o.centre=function(e){for(var t,n,r,s=o.area(e,!0),a={x:0,y:0},l=0;l<e.length;l++)r=(l+1)%e.length,t=i.cross(e[l],e[r]),n=i.mult(i.add(e[l],e[r]),t),a=i.add(a,n);return i.div(a,6*s)},o.mean=function(e){for(var t={x:0,y:0},n=0;n<e.length;n++)t.x+=e[n].x,t.y+=e[n].y;return i.div(t,e.length)},o.area=function(e,t){for(var n=0,o=e.length-1,i=0;i<e.length;i++)n+=(e[o].x-e[i].x)*(e[o].y+e[i].y),o=i;return t?n/2:Math.abs(n)/2},o.inertia=function(e,t){for(var n,o,r=0,s=0,a=e,l=0;l<a.length;l++)o=(l+1)%a.length,n=Math.abs(i.cross(a[o],a[l])),r+=n*(i.dot(a[o],a[o])+i.dot(a[o],a[l])+i.dot(a[l],a[l])),s+=n;return t/6*(r/s)},o.translate=function(e,t,n){var o;if(n)for(o=0;o<e.length;o++)e[o].x+=t.x*n,e[o].y+=t.y*n;else for(o=0;o<e.length;o++)e[o].x+=t.x,e[o].y+=t.y;return e},o.rotate=function(e,t,n){if(0!==t){
for(var o=Math.cos(t),i=Math.sin(t),r=0;r<e.length;r++){var s=e[r],a=s.x-n.x,l=s.y-n.y;s.x=n.x+(a*o-l*i),s.y=n.y+(a*i+l*o)}return e}},o.contains=function(e,t){for(var n=0;n<e.length;n++){var o=e[n],i=e[(n+1)%e.length];if((t.x-o.x)*(i.y-o.y)+(t.y-o.y)*(o.x-i.x)>0)return!1}return!0},o.scale=function(e,t,n,r){if(1===t&&1===n)return e;r=r||o.centre(e);for(var s,a,l=0;l<e.length;l++)s=e[l],a=i.sub(s,r),e[l].x=r.x+a.x*t,e[l].y=r.y+a.y*n;return e},o.chamfer=function(e,t,n,o,s){t="number"==typeof t?[t]:t||[8],n=void 0!==n?n:-1,o=o||2,s=s||14;for(var a=[],l=0;l<e.length;l++){var c=e[l-1>=0?l-1:e.length-1],d=e[l],u=e[(l+1)%e.length],p=t[l<t.length?l:t.length-1];if(0!==p){var f=i.normalise({x:d.y-c.y,y:c.x-d.x}),m=i.normalise({x:u.y-d.y,y:d.x-u.x}),v=Math.sqrt(2*Math.pow(p,2)),y=i.mult(r.clone(f),p),g=i.normalise(i.mult(i.add(f,m),.5)),x=i.sub(d,i.mult(g,v)),h=n;-1===n&&(h=1.75*Math.pow(p,.32)),h=r.clamp(h,o,s),h%2==1&&(h+=1)
;for(var b=Math.acos(i.dot(f,m)),w=b/h,S=0;S<h;S++)a.push(i.add(i.rotate(y,w*S),x))}else a.push(d)}return a},o.clockwiseSort=function(e){var t=o.mean(e);return e.sort(function(e,n){return i.angle(t,e)-i.angle(t,n)}),e},o.isConvex=function(e){var t,n,o,i,r=0,s=e.length;if(s<3)return null;for(t=0;t<s;t++)if(n=(t+1)%s,o=(t+2)%s,i=(e[n].x-e[t].x)*(e[o].y-e[n].y),i-=(e[n].y-e[t].y)*(e[o].x-e[n].x),i<0?r|=1:i>0&&(r|=2),3===r)return!1;return 0!==r||null},o.hull=function(e){var t,n,o=[],r=[];for(e=e.slice(0),e.sort(function(e,t){var n=e.x-t.x;return 0!==n?n:e.y-t.y}),n=0;n<e.length;n+=1){for(t=e[n];r.length>=2&&i.cross3(r[r.length-2],r[r.length-1],t)<=0;)r.pop();r.push(t)}for(n=e.length-1;n>=0;n-=1){for(t=e[n];o.length>=2&&i.cross3(o[o.length-2],o[o.length-1],t)<=0;)o.pop();o.push(t)}return o.pop(),r.pop(),o.concat(r)}}()},{"../core/Common":14,"../geometry/Vector":28}],30:[function(e,t,n){var o=t.exports=e("../core/Matter");o.Body=e("../body/Body"),o.Composite=e("../body/Composite"),
o.World=e("../body/World"),o.Contact=e("../collision/Contact"),o.Detector=e("../collision/Detector"),o.Grid=e("../collision/Grid"),o.Pairs=e("../collision/Pairs"),o.Pair=e("../collision/Pair"),o.Query=e("../collision/Query"),o.Resolver=e("../collision/Resolver"),o.SAT=e("../collision/SAT"),o.Constraint=e("../constraint/Constraint"),o.MouseConstraint=e("../constraint/MouseConstraint"),o.Common=e("../core/Common"),o.Engine=e("../core/Engine"),o.Events=e("../core/Events"),o.Mouse=e("../core/Mouse"),o.Runner=e("../core/Runner"),o.Sleeping=e("../core/Sleeping"),o.Plugin=e("../core/Plugin"),o.Bodies=e("../factory/Bodies"),o.Composites=e("../factory/Composites"),o.Axes=e("../geometry/Axes"),o.Bounds=e("../geometry/Bounds"),o.Svg=e("../geometry/Svg"),o.Vector=e("../geometry/Vector"),o.Vertices=e("../geometry/Vertices"),o.Render=e("../render/Render"),o.RenderPixi=e("../render/RenderPixi"),o.World.add=o.Composite.add,o.World.remove=o.Composite.remove,
o.World.addComposite=o.Composite.addComposite,o.World.addBody=o.Composite.addBody,o.World.addConstraint=o.Composite.addConstraint,o.World.clear=o.Composite.clear,o.Engine.run=o.Runner.run},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Contact":4,"../collision/Detector":5,"../collision/Grid":6,"../collision/Pair":7,"../collision/Pairs":8,"../collision/Query":9,"../collision/Resolver":10,"../collision/SAT":11,"../constraint/Constraint":12,"../constraint/MouseConstraint":13,"../core/Common":14,"../core/Engine":15,"../core/Events":16,"../core/Matter":17,"../core/Metrics":18,"../core/Mouse":19,"../core/Plugin":20,"../core/Runner":21,"../core/Sleeping":22,"../factory/Bodies":23,"../factory/Composites":24,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Svg":27,"../geometry/Vector":28,"../geometry/Vertices":29,"../render/Render":31,"../render/RenderPixi":32}],31:[function(e,t,n){var o={};t.exports=o
;var i=e("../core/Common"),r=e("../body/Composite"),s=e("../geometry/Bounds"),a=e("../core/Events"),l=e("../collision/Grid"),c=e("../geometry/Vector"),d=e("../core/Mouse");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(i.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),o.create=function(e){var t={controller:o,engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,options:{width:800,height:600,pixelRatio:1,background:"#18181d",wireframeBackground:"#0f0f13",hasBounds:!!e.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1,
showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},r=i.extend(t,e);return r.canvas&&(r.canvas.width=r.options.width||r.canvas.width,r.canvas.height=r.options.height||r.canvas.height),r.mouse=e.mouse,r.engine=e.engine,r.canvas=r.canvas||n(r.options.width,r.options.height),r.context=r.canvas.getContext("2d"),r.textures={},r.bounds=r.bounds||{min:{x:0,y:0},max:{x:r.canvas.width,y:r.canvas.height}},1!==r.options.pixelRatio&&o.setPixelRatio(r,r.options.pixelRatio),i.isElement(r.element)?r.element.appendChild(r.canvas):r.canvas.parentNode||i.log("Render.create: options.element was undefined, render.canvas was created but not appended","warn"),r},o.run=function(t){!function n(i){t.frameRequestId=e(n),o.world(t)}()},o.stop=function(e){t(e.frameRequestId)},o.setPixelRatio=function(e,t){var n=e.options,o=e.canvas;"auto"===t&&(t=u(o)),n.pixelRatio=t,o.setAttribute("data-pixel-ratio",t),o.width=n.width*t,o.height=n.height*t,o.style.width=n.width+"px",
o.style.height=n.height+"px",e.context.scale(t,t)},o.lookAt=function(e,t,n,o){o=void 0===o||o,t=i.isArray(t)?t:[t],n=n||{x:0,y:0};for(var r={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},s=0;s<t.length;s+=1){var a=t[s],l=a.bounds?a.bounds.min:a.min||a.position||a,c=a.bounds?a.bounds.max:a.max||a.position||a;l&&c&&(l.x<r.min.x&&(r.min.x=l.x),c.x>r.max.x&&(r.max.x=c.x),l.y<r.min.y&&(r.min.y=l.y),c.y>r.max.y&&(r.max.y=c.y))}var u=r.max.x-r.min.x+2*n.x,p=r.max.y-r.min.y+2*n.y,f=e.canvas.height,m=e.canvas.width,v=m/f,y=u/p,g=1,x=1;y>v?x=y/v:g=v/y,e.options.hasBounds=!0,e.bounds.min.x=r.min.x,e.bounds.max.x=r.min.x+u*g,e.bounds.min.y=r.min.y,e.bounds.max.y=r.min.y+p*x,o&&(e.bounds.min.x+=.5*u-u*g*.5,e.bounds.max.x+=.5*u-u*g*.5,e.bounds.min.y+=.5*p-p*x*.5,e.bounds.max.y+=.5*p-p*x*.5),e.bounds.min.x-=n.x,e.bounds.max.x-=n.x,e.bounds.min.y-=n.y,e.bounds.max.y-=n.y,e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),
d.setOffset(e.mouse,e.bounds.min))},o.startViewTransform=function(e){var t=e.bounds.max.x-e.bounds.min.x,n=e.bounds.max.y-e.bounds.min.y,o=t/e.options.width,i=n/e.options.height;e.context.scale(1/o,1/i),e.context.translate(-e.bounds.min.x,-e.bounds.min.y)},o.endViewTransform=function(e){e.context.setTransform(e.options.pixelRatio,0,0,e.options.pixelRatio,0,0)},o.world=function(e){var t,n=e.engine,i=n.world,u=e.canvas,p=e.context,m=e.options,v=r.allBodies(i),y=r.allConstraints(i),g=m.wireframes?m.wireframeBackground:m.background,x=[],h=[],b={timestamp:n.timing.timestamp};if(a.trigger(e,"beforeRender",b),e.currentBackground!==g&&f(e,g),p.globalCompositeOperation="source-in",p.fillStyle="transparent",p.fillRect(0,0,u.width,u.height),p.globalCompositeOperation="source-over",m.hasBounds){for(t=0;t<v.length;t++){var w=v[t];s.overlaps(w.bounds,e.bounds)&&x.push(w)}for(t=0;t<y.length;t++){var S=y[t],C=S.bodyA,A=S.bodyB,P=S.pointA,B=S.pointB;C&&(P=c.add(C.position,S.pointA)),
A&&(B=c.add(A.position,S.pointB)),P&&B&&((s.contains(e.bounds,P)||s.contains(e.bounds,B))&&h.push(S))}o.startViewTransform(e),e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),d.setOffset(e.mouse,e.bounds.min))}else h=y,x=v;!m.wireframes||n.enableSleeping&&m.showSleeping?o.bodies(e,x,p):(m.showConvexHulls&&o.bodyConvexHulls(e,x,p),o.bodyWireframes(e,x,p)),m.showBounds&&o.bodyBounds(e,x,p),(m.showAxes||m.showAngleIndicator)&&o.bodyAxes(e,x,p),m.showPositions&&o.bodyPositions(e,x,p),m.showVelocity&&o.bodyVelocity(e,x,p),m.showIds&&o.bodyIds(e,x,p),m.showSeparations&&o.separations(e,n.pairs.list,p),m.showCollisions&&o.collisions(e,n.pairs.list,p),m.showVertexNumbers&&o.vertexNumbers(e,x,p),m.showMousePosition&&o.mousePosition(e,e.mouse,p),o.constraints(h,p),m.showBroadphase&&n.broadphase.controller===l&&o.grid(e,n.broadphase,p),m.showDebug&&o.debug(e,p),m.hasBounds&&o.endViewTransform(e),
a.trigger(e,"afterRender",b)},o.debug=function(e,t){var n=t,o=e.engine,i=o.world,s=o.metrics,a=e.options;r.allBodies(i);if(o.timing.timestamp-(e.debugTimestamp||0)>=500){var l="";s.timing&&(l+="fps: "+Math.round(s.timing.fps)+" "),e.debugString=l,e.debugTimestamp=o.timing.timestamp}if(e.debugString){n.font="12px Arial",a.wireframes?n.fillStyle="rgba(255,255,255,0.5)":n.fillStyle="rgba(0,0,0,0.5)";for(var c=e.debugString.split("\n"),d=0;d<c.length;d++)n.fillText(c[d],50,50+18*d)}},o.constraints=function(e,t){for(var n=t,o=0;o<e.length;o++){var r=e[o];if(r.render.visible&&r.pointA&&r.pointB){var s,a,l=r.bodyA,d=r.bodyB;if(s=l?c.add(l.position,r.pointA):r.pointA,"pin"===r.render.type)n.beginPath(),n.arc(s.x,s.y,3,0,2*Math.PI),n.closePath();else{if(a=d?c.add(d.position,r.pointB):r.pointB,n.beginPath(),n.moveTo(s.x,s.y),"spring"===r.render.type)for(var u,p=c.sub(a,s),f=c.perp(c.normalise(p)),m=Math.ceil(i.clamp(r.length/5,12,20)),v=1;v<m;v+=1)u=v%2==0?1:-1,
n.lineTo(s.x+p.x*(v/m)+f.x*u*4,s.y+p.y*(v/m)+f.y*u*4);n.lineTo(a.x,a.y)}r.render.lineWidth&&(n.lineWidth=r.render.lineWidth,n.strokeStyle=r.render.strokeStyle,n.stroke()),r.render.anchors&&(n.fillStyle=r.render.strokeStyle,n.beginPath(),n.arc(s.x,s.y,3,0,2*Math.PI),n.arc(a.x,a.y,3,0,2*Math.PI),n.closePath(),n.fill())}}},o.bodyShadows=function(e,t,n){for(var o=n,i=(e.engine,0);i<t.length;i++){var r=t[i];if(r.render.visible){if(r.circleRadius)o.beginPath(),o.arc(r.position.x,r.position.y,r.circleRadius,0,2*Math.PI),o.closePath();else{o.beginPath(),o.moveTo(r.vertices[0].x,r.vertices[0].y);for(var s=1;s<r.vertices.length;s++)o.lineTo(r.vertices[s].x,r.vertices[s].y);o.closePath()}var a=r.position.x-.5*e.options.width,l=r.position.y-.2*e.options.height,c=Math.abs(a)+Math.abs(l);o.shadowColor="rgba(0,0,0,0.15)",o.shadowOffsetX=.05*a,o.shadowOffsetY=.05*l,o.shadowBlur=1+12*Math.min(1,c/1e3),o.fill(),o.shadowColor=null,o.shadowOffsetX=null,o.shadowOffsetY=null,o.shadowBlur=null}}},
o.bodies=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options),c=l.showInternalEdges||!l.wireframes;for(r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(s=o.parts.length>1?1:0;s<o.parts.length;s++)if(i=o.parts[s],i.render.visible){if(l.showSleeping&&o.isSleeping?a.globalAlpha=.5*i.render.opacity:1!==i.render.opacity&&(a.globalAlpha=i.render.opacity),i.render.sprite&&i.render.sprite.texture&&!l.wireframes){var d=i.render.sprite,u=p(e,d.texture);a.translate(i.position.x,i.position.y),a.rotate(i.angle),a.drawImage(u,u.width*-d.xOffset*d.xScale,u.height*-d.yOffset*d.yScale,u.width*d.xScale,u.height*d.yScale),a.rotate(-i.angle),a.translate(-i.position.x,-i.position.y)}else{if(i.circleRadius)a.beginPath(),a.arc(i.position.x,i.position.y,i.circleRadius,0,2*Math.PI);else{a.beginPath(),a.moveTo(i.vertices[0].x,i.vertices[0].y);for(var f=1;f<i.vertices.length;f++)!i.vertices[f-1].isInternal||c?a.lineTo(i.vertices[f].x,i.vertices[f].y):a.moveTo(i.vertices[f].x,i.vertices[f].y),
i.vertices[f].isInternal&&!c&&a.moveTo(i.vertices[(f+1)%i.vertices.length].x,i.vertices[(f+1)%i.vertices.length].y);a.lineTo(i.vertices[0].x,i.vertices[0].y),a.closePath()}l.wireframes?(a.lineWidth=1,a.strokeStyle="#bbb",a.stroke()):(a.fillStyle=i.render.fillStyle,i.render.lineWidth&&(a.lineWidth=i.render.lineWidth,a.strokeStyle=i.render.strokeStyle,a.stroke()),a.fill())}a.globalAlpha=1}},o.bodyWireframes=function(e,t,n){var o,i,r,s,a,l=n,c=e.options.showInternalEdges;for(l.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(a=o.parts.length>1?1:0;a<o.parts.length;a++){for(i=o.parts[a],l.moveTo(i.vertices[0].x,i.vertices[0].y),s=1;s<i.vertices.length;s++)!i.vertices[s-1].isInternal||c?l.lineTo(i.vertices[s].x,i.vertices[s].y):l.moveTo(i.vertices[s].x,i.vertices[s].y),i.vertices[s].isInternal&&!c&&l.moveTo(i.vertices[(s+1)%i.vertices.length].x,i.vertices[(s+1)%i.vertices.length].y);l.lineTo(i.vertices[0].x,i.vertices[0].y)}l.lineWidth=1,l.strokeStyle="#bbb",l.stroke()},
o.bodyConvexHulls=function(e,t,n){var o,i,r,s=n;for(s.beginPath(),i=0;i<t.length;i++)if(o=t[i],o.render.visible&&1!==o.parts.length){for(s.moveTo(o.vertices[0].x,o.vertices[0].y),r=1;r<o.vertices.length;r++)s.lineTo(o.vertices[r].x,o.vertices[r].y);s.lineTo(o.vertices[0].x,o.vertices[0].y)}s.lineWidth=1,s.strokeStyle="rgba(255,255,255,0.2)",s.stroke()},o.vertexNumbers=function(e,t,n){var o,i,r,s=n;for(o=0;o<t.length;o++){var a=t[o].parts;for(r=a.length>1?1:0;r<a.length;r++){var l=a[r];for(i=0;i<l.vertices.length;i++)s.fillStyle="rgba(255,255,255,0.2)",s.fillText(o+"_"+i,l.position.x+.8*(l.vertices[i].x-l.position.x),l.position.y+.8*(l.vertices[i].y-l.position.y))}}},o.mousePosition=function(e,t,n){var o=n;o.fillStyle="rgba(255,255,255,0.8)",o.fillText(t.position.x+" "+t.position.y,t.position.x+5,t.position.y-5)},o.bodyBounds=function(e,t,n){var o=n,i=(e.engine,e.options);o.beginPath();for(var r=0;r<t.length;r++){
if(t[r].render.visible)for(var s=t[r].parts,a=s.length>1?1:0;a<s.length;a++){var l=s[a];o.rect(l.bounds.min.x,l.bounds.min.y,l.bounds.max.x-l.bounds.min.x,l.bounds.max.y-l.bounds.min.y)}}i.wireframes?o.strokeStyle="rgba(255,255,255,0.08)":o.strokeStyle="rgba(0,0,0,0.1)",o.lineWidth=1,o.stroke()},o.bodyAxes=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options);for(a.beginPath(),i=0;i<t.length;i++){var c=t[i],d=c.parts;if(c.render.visible)if(l.showAxes)for(r=d.length>1?1:0;r<d.length;r++)for(o=d[r],s=0;s<o.axes.length;s++){var u=o.axes[s];a.moveTo(o.position.x,o.position.y),a.lineTo(o.position.x+20*u.x,o.position.y+20*u.y)}else for(r=d.length>1?1:0;r<d.length;r++)for(o=d[r],s=0;s<o.axes.length;s++)a.moveTo(o.position.x,o.position.y),a.lineTo((o.vertices[0].x+o.vertices[o.vertices.length-1].x)/2,(o.vertices[0].y+o.vertices[o.vertices.length-1].y)/2)}l.wireframes?(a.strokeStyle="indianred",a.lineWidth=1):(a.strokeStyle="rgba(255, 255, 255, 0.4)",a.globalCompositeOperation="overlay",
a.lineWidth=2),a.stroke(),a.globalCompositeOperation="source-over"},o.bodyPositions=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options);for(a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(s=0;s<o.parts.length;s++)i=o.parts[s],a.arc(i.position.x,i.position.y,3,0,2*Math.PI,!1),a.closePath();for(l.wireframes?a.fillStyle="indianred":a.fillStyle="rgba(0,0,0,0.5)",a.fill(),a.beginPath(),r=0;r<t.length;r++)o=t[r],o.render.visible&&(a.arc(o.positionPrev.x,o.positionPrev.y,2,0,2*Math.PI,!1),a.closePath());a.fillStyle="rgba(255,165,0,0.8)",a.fill()},o.bodyVelocity=function(e,t,n){var o=n;o.beginPath();for(var i=0;i<t.length;i++){var r=t[i];r.render.visible&&(o.moveTo(r.position.x,r.position.y),o.lineTo(r.position.x+2*(r.position.x-r.positionPrev.x),r.position.y+2*(r.position.y-r.positionPrev.y)))}o.lineWidth=3,o.strokeStyle="cornflowerblue",o.stroke()},o.bodyIds=function(e,t,n){var o,i,r=n;for(o=0;o<t.length;o++)if(t[o].render.visible){var s=t[o].parts
;for(i=s.length>1?1:0;i<s.length;i++){var a=s[i];r.font="12px Arial",r.fillStyle="rgba(255,255,255,0.5)",r.fillText(a.id,a.position.x+10,a.position.y-10)}}},o.collisions=function(e,t,n){var o,i,r,s,a=n,l=e.options;for(a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.isActive)for(i=o.collision,s=0;s<o.activeContacts.length;s++){var c=o.activeContacts[s],d=c.vertex;a.rect(d.x-1.5,d.y-1.5,3.5,3.5)}for(l.wireframes?a.fillStyle="rgba(255,255,255,0.7)":a.fillStyle="orange",a.fill(),a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.isActive&&(i=o.collision,o.activeContacts.length>0)){var u=o.activeContacts[0].vertex.x,p=o.activeContacts[0].vertex.y;2===o.activeContacts.length&&(u=(o.activeContacts[0].vertex.x+o.activeContacts[1].vertex.x)/2,p=(o.activeContacts[0].vertex.y+o.activeContacts[1].vertex.y)/2),i.bodyB===i.supports[0].body||!0===i.bodyA.isStatic?a.moveTo(u-8*i.normal.x,p-8*i.normal.y):a.moveTo(u+8*i.normal.x,p+8*i.normal.y),a.lineTo(u,p)}
l.wireframes?a.strokeStyle="rgba(255,165,0,0.7)":a.strokeStyle="orange",a.lineWidth=1,a.stroke()},o.separations=function(e,t,n){var o,i,r,s,a,l=n,c=e.options;for(l.beginPath(),a=0;a<t.length;a++)if(o=t[a],o.isActive){i=o.collision,r=i.bodyA,s=i.bodyB;var d=1;s.isStatic||r.isStatic||(d=.5),s.isStatic&&(d=0),l.moveTo(s.position.x,s.position.y),l.lineTo(s.position.x-i.penetration.x*d,s.position.y-i.penetration.y*d),d=1,s.isStatic||r.isStatic||(d=.5),r.isStatic&&(d=0),l.moveTo(r.position.x,r.position.y),l.lineTo(r.position.x+i.penetration.x*d,r.position.y+i.penetration.y*d)}c.wireframes?l.strokeStyle="rgba(255,165,0,0.5)":l.strokeStyle="orange",l.stroke()},o.grid=function(e,t,n){var o=n;e.options.wireframes?o.strokeStyle="rgba(255,180,0,0.1)":o.strokeStyle="rgba(255,180,0,0.5)",o.beginPath();for(var r=i.keys(t.buckets),s=0;s<r.length;s++){var a=r[s];if(!(t.buckets[a].length<2)){var l=a.split(/C|R/)
;o.rect(.5+parseInt(l[1],10)*t.bucketWidth,.5+parseInt(l[2],10)*t.bucketHeight,t.bucketWidth,t.bucketHeight)}}o.lineWidth=1,o.stroke()},o.inspector=function(e,t){var n,o=(e.engine,e.selected),i=e.render,r=i.options;if(r.hasBounds){var s=i.bounds.max.x-i.bounds.min.x,a=i.bounds.max.y-i.bounds.min.y,l=s/i.options.width,c=a/i.options.height;t.scale(1/l,1/c),t.translate(-i.bounds.min.x,-i.bounds.min.y)}for(var d=0;d<o.length;d++){var u=o[d].data;switch(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.9)",t.setLineDash([1,2]),u.type){case"body":n=u.bounds,t.beginPath(),t.rect(Math.floor(n.min.x-3),Math.floor(n.min.y-3),Math.floor(n.max.x-n.min.x+6),Math.floor(n.max.y-n.min.y+6)),t.closePath(),t.stroke();break;case"constraint":var p=u.pointA;u.bodyA&&(p=u.pointB),t.beginPath(),t.arc(p.x,p.y,10,0,2*Math.PI),t.closePath(),t.stroke()}t.setLineDash([]),t.translate(-.5,-.5)}null!==e.selectStart&&(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.6)",
t.fillStyle="rgba(255,165,0,0.1)",n=e.selectBounds,t.beginPath(),t.rect(Math.floor(n.min.x),Math.floor(n.min.y),Math.floor(n.max.x-n.min.x),Math.floor(n.max.y-n.min.y)),t.closePath(),t.stroke(),t.fill(),t.translate(-.5,-.5)),r.hasBounds&&t.setTransform(1,0,0,1,0,0)};var n=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n.oncontextmenu=function(){return!1},n.onselectstart=function(){return!1},n},u=function(e){var t=e.getContext("2d");return(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)},p=function(e,t){var n=e.textures[t];return n||(n=e.textures[t]=new Image,n.src=t,n)},f=function(e,t){var n=t;/(jpg|gif|png)$/.test(t)&&(n="url("+t+")"),e.canvas.style.background=n,e.canvas.style.backgroundSize="contain",e.currentBackground=t}}()},{"../body/Composite":2,"../collision/Grid":6,"../core/Common":14,"../core/Events":16,
"../core/Mouse":19,"../geometry/Bounds":26,"../geometry/Vector":28}],32:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Bounds"),r=e("../body/Composite"),s=e("../core/Common"),a=e("../core/Events"),l=e("../geometry/Vector");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(s.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),o.create=function(e){s.warn("RenderPixi.create: Matter.RenderPixi is deprecated (see docs)");var t={controller:o,engine:null,element:null,frameRequestId:null,canvas:null,renderer:null,container:null,spriteContainer:null,pixiOptions:null,options:{width:800,height:600,background:"#fafafa",wireframeBackground:"#222",hasBounds:!1,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,
showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1}},n=s.extend(t,e),i=!n.options.wireframes&&"transparent"===n.options.background;return n.pixiOptions=n.pixiOptions||{view:n.canvas,transparent:i,antialias:!0,backgroundColor:e.background},n.mouse=e.mouse,n.engine=e.engine,n.renderer=n.renderer||new PIXI.WebGLRenderer(n.options.width,n.options.height,n.pixiOptions),n.container=n.container||new PIXI.Container,n.spriteContainer=n.spriteContainer||new PIXI.Container,n.canvas=n.canvas||n.renderer.view,n.bounds=n.bounds||{min:{x:0,y:0},max:{x:n.options.width,y:n.options.height}},a.on(n.engine,"beforeUpdate",function(){o.clear(n)}),n.textures={},n.sprites={},n.primitives={},n.container.addChild(n.spriteContainer),s.isElement(n.element)?n.element.appendChild(n.canvas):s.warn('No "render.element" passed, "render.canvas" was not inserted into document.'),n.canvas.oncontextmenu=function(){return!1},
n.canvas.onselectstart=function(){return!1},n},o.run=function(t){!function n(i){t.frameRequestId=e(n),o.world(t)}()},o.stop=function(e){t(e.frameRequestId)},o.clear=function(e){for(var t=e.container,n=e.spriteContainer;t.children[0];)t.removeChild(t.children[0]);for(;n.children[0];)n.removeChild(n.children[0]);var o=e.sprites["bg-0"];e.textures={},e.sprites={},e.primitives={},e.sprites["bg-0"]=o,o&&t.addChildAt(o,0),e.container.addChild(e.spriteContainer),e.currentBackground=null,t.scale.set(1,1),t.position.set(0,0)},o.setBackground=function(e,t){if(e.currentBackground!==t){var n=t.indexOf&&-1!==t.indexOf("#"),o=e.sprites["bg-0"];if(n){var i=s.colorToNumber(t);e.renderer.backgroundColor=i,o&&e.container.removeChild(o)}else if(!o){var r=d(e,t);o=e.sprites["bg-0"]=new PIXI.Sprite(r),o.position.x=0,o.position.y=0,e.container.addChildAt(o,0)}e.currentBackground=t}},o.world=function(e){
var t,n=e.engine,s=n.world,a=e.renderer,c=e.container,d=e.options,u=r.allBodies(s),p=r.allConstraints(s),f=[];d.wireframes?o.setBackground(e,d.wireframeBackground):o.setBackground(e,d.background);var m=e.bounds.max.x-e.bounds.min.x,v=e.bounds.max.y-e.bounds.min.y,y=m/e.options.width,g=v/e.options.height;if(d.hasBounds){for(t=0;t<u.length;t++){var x=u[t];x.render.sprite.visible=i.overlaps(x.bounds,e.bounds)}for(t=0;t<p.length;t++){var h=p[t],b=h.bodyA,w=h.bodyB,S=h.pointA,C=h.pointB;b&&(S=l.add(b.position,h.pointA)),w&&(C=l.add(w.position,h.pointB)),S&&C&&((i.contains(e.bounds,S)||i.contains(e.bounds,C))&&f.push(h))}c.scale.set(1/y,1/g),c.position.set(-e.bounds.min.x*(1/y),-e.bounds.min.y*(1/g))}else f=p;for(t=0;t<u.length;t++)o.body(e,u[t]);for(t=0;t<f.length;t++)o.constraint(e,f[t]);a.render(c)},o.constraint=function(e,t){var n=(e.engine,t.bodyA),o=t.bodyB,i=t.pointA,r=t.pointB,a=e.container,l=t.render,c="c-"+t.id,d=e.primitives[c];if(d||(d=e.primitives[c]=new PIXI.Graphics),
!l.visible||!t.pointA||!t.pointB)return void d.clear();-1===s.indexOf(a.children,d)&&a.addChild(d),d.clear(),d.beginFill(0,0),d.lineStyle(l.lineWidth,s.colorToNumber(l.strokeStyle),1),n?d.moveTo(n.position.x+i.x,n.position.y+i.y):d.moveTo(i.x,i.y),o?d.lineTo(o.position.x+r.x,o.position.y+r.y):d.lineTo(r.x,r.y),d.endFill()},o.body=function(e,t){var o=(e.engine,t.render);if(o.visible)if(o.sprite&&o.sprite.texture){var i="b-"+t.id,r=e.sprites[i],a=e.spriteContainer;r||(r=e.sprites[i]=n(e,t)),-1===s.indexOf(a.children,r)&&a.addChild(r),r.position.x=t.position.x,r.position.y=t.position.y,r.rotation=t.angle,r.scale.x=o.sprite.xScale||1,r.scale.y=o.sprite.yScale||1}else{var l="b-"+t.id,d=e.primitives[l],u=e.container;d||(d=e.primitives[l]=c(e,t),d.initialAngle=t.angle),-1===s.indexOf(u.children,d)&&u.addChild(d),d.position.x=t.position.x,d.position.y=t.position.y,d.rotation=t.angle-d.initialAngle}};var n=function(e,t){var n=t.render,o=n.sprite.texture,i=d(e,o),r=new PIXI.Sprite(i)
;return r.anchor.x=t.render.sprite.xOffset,r.anchor.y=t.render.sprite.yOffset,r},c=function(e,t){var n,o=t.render,i=e.options,r=new PIXI.Graphics,a=s.colorToNumber(o.fillStyle),l=s.colorToNumber(o.strokeStyle),c=s.colorToNumber(o.strokeStyle),d=s.colorToNumber("#bbb"),u=s.colorToNumber("#CD5C5C");r.clear();for(var p=t.parts.length>1?1:0;p<t.parts.length;p++){n=t.parts[p],i.wireframes?(r.beginFill(0,0),r.lineStyle(1,d,1)):(r.beginFill(a,1),r.lineStyle(o.lineWidth,l,1)),r.moveTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y);for(var f=1;f<n.vertices.length;f++)r.lineTo(n.vertices[f].x-t.position.x,n.vertices[f].y-t.position.y);r.lineTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y),r.endFill(),(i.showAngleIndicator||i.showAxes)&&(r.beginFill(0,0),i.wireframes?r.lineStyle(1,u,1):r.lineStyle(1,c),r.moveTo(n.position.x-t.position.x,n.position.y-t.position.y),
r.lineTo((n.vertices[0].x+n.vertices[n.vertices.length-1].x)/2-t.position.x,(n.vertices[0].y+n.vertices[n.vertices.length-1].y)/2-t.position.y),r.endFill())}return r},d=function(e,t){var n=e.textures[t];return n||(n=e.textures[t]=PIXI.Texture.fromImage(t)),n}}()},{"../body/Composite":2,"../core/Common":14,"../core/Events":16,"../geometry/Bounds":26,"../geometry/Vector":28}]},{},[30])(30)});
\ No newline at end of file
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.decomp=e()}}(function(){return function e(f,o,n){function d(t,l){if(!o[t]){if(!f[t]){var u="function"==typeof require&&require;if(!l&&u)return u(t,!0);if(i)return i(t,!0);throw new Error("Cannot find module '"+t+"'")}var p=o[t]={exports:{}};f[t][0].call(p.exports,function(e){var o=f[t][1][e];return d(o?o:e)},p,p.exports,e,f,o,n)}return o[t].exports}for(var i="function"==typeof require&&require,t=0;t<n.length;t++)d(n[t]);return d}({1:[function(e,f,o){function n(e,f,o){o=o||0;var n,d,i,t,l,u,p,s=[0,0];return n=e[1][1]-e[0][1],d=e[0][0]-e[1][0],i=n*e[0][0]+d*e[0][1],t=f[1][1]-f[0][1],l=f[0][0]-f[1][0],u=t*f[0][0]+l*f[0][1],p=n*l-t*d,B(p,0,o)||(s[0]=(l*i-d*u)/p,s[1]=(n*u-t*i)/p),s}function d(e,f,o,n){var d=f[0]-e[0],i=f[1]-e[1],t=n[0]-o[0],l=n[1]-o[1];if(t*i-l*d===0)return!1;var u=(d*(o[1]-e[1])+i*(e[0]-o[0]))/(t*i-l*d),p=(t*(e[1]-o[1])+l*(o[0]-e[0]))/(l*d-t*i);return u>=0&&1>=u&&p>=0&&1>=p}function i(e,f,o){return(f[0]-e[0])*(o[1]-e[1])-(o[0]-e[0])*(f[1]-e[1])}function t(e,f,o){return i(e,f,o)>0}function l(e,f,o){return i(e,f,o)>=0}function u(e,f,o){return i(e,f,o)<0}function p(e,f,o){return i(e,f,o)<=0}function s(e,f,o,n){if(n){var d=C,t=D;d[0]=f[0]-e[0],d[1]=f[1]-e[1],t[0]=o[0]-f[0],t[1]=o[1]-f[1];var l=d[0]*t[0]+d[1]*t[1],u=Math.sqrt(d[0]*d[0]+d[1]*d[1]),p=Math.sqrt(t[0]*t[0]+t[1]*t[1]),s=Math.acos(l/(u*p));return n>s}return 0===i(e,f,o)}function c(e,f){var o=f[0]-e[0],n=f[1]-e[1];return o*o+n*n}function y(e,f){var o=e.length;return e[0>f?f%o+o:f%o]}function a(e){e.length=0}function m(e,f,o,n){for(var d=o;n>d;d++)e.push(f[d])}function r(e){for(var f=0,o=e,n=1;n<e.length;++n)(o[n][1]<o[f][1]||o[n][1]===o[f][1]&&o[n][0]>o[f][0])&&(f=n);t(y(e,f-1),y(e,f),y(e,f+1))||w(e)}function w(e){for(var f=[],o=e.length,n=0;n!==o;n++)f.push(e.pop());for(var n=0;n!==o;n++)e[n]=f[n]}function b(e,f){return u(y(e,f-1),y(e,f),y(e,f+1))}function g(e,f,o){var d,i,t=E,u=F;if(l(y(e,f+1),y(e,f),y(e,o))&&p(y(e,f-1),y(e,f),y(e,o)))return!1;i=c(y(e,f),y(e,o));for(var s=0;s!==e.length;++s)if((s+1)%e.length!==f&&s!==f&&l(y(e,f),y(e,o),y(e,s+1))&&p(y(e,f),y(e,o),y(e,s))&&(t[0]=y(e,f),t[1]=y(e,o),u[0]=y(e,s),u[1]=y(e,s+1),d=n(t,u),c(y(e,f),d)<i))return!1;return!0}function x(e,f,o,n){var d=n||[];if(a(d),o>f)for(var i=f;o>=i;i++)d.push(e[i]);else{for(var i=0;o>=i;i++)d.push(e[i]);for(var i=f;i<e.length;i++)d.push(e[i])}return d}function j(e){for(var f=[],o=[],n=[],d=[],i=Number.MAX_VALUE,t=0;t<e.length;++t)if(b(e,t))for(var l=0;l<e.length;++l)if(g(e,t,l)){o=j(x(e,t,l,d)),n=j(x(e,l,t,d));for(var u=0;u<n.length;u++)o.push(n[u]);o.length<i&&(f=o,i=o.length,f.push([y(e,t),y(e,l)]))}return f}function v(e){var f=j(e);return f.length>0?h(e,f):[e]}function h(e,f){if(0===f.length)return[e];if(f instanceof Array&&f.length&&f[0]instanceof Array&&2===f[0].length&&f[0][0]instanceof Array){for(var o=[e],n=0;n<f.length;n++)for(var d=f[n],i=0;i<o.length;i++){var t=o[i],l=h(t,d);if(l){o.splice(i,1),o.push(l[0],l[1]);break}}return o}var d=f,n=e.indexOf(d[0]),i=e.indexOf(d[1]);return-1!==n&&-1!==i?[x(e,n,i),x(e,i,n)]:!1}function k(e){var f,o=e;for(f=0;f<o.length-1;f++)for(var n=0;f-1>n;n++)if(d(o[f],o[f+1],o[n],o[n+1]))return!1;for(f=1;f<o.length-2;f++)if(d(o[0],o[o.length-1],o[f],o[f+1]))return!1;return!0}function q(e,f,o,n,d){d=d||0;var i=f[1]-e[1],t=e[0]-f[0],l=i*e[0]+t*e[1],u=n[1]-o[1],p=o[0]-n[0],s=u*o[0]+p*o[1],c=i*p-u*t;return B(c,0,d)?[0,0]:[(p*l-t*s)/c,(i*s-u*l)/c]}function z(e,f,o,n,d,i,s){i=i||100,s=s||0,d=d||25,f="undefined"!=typeof f?f:[],o=o||[],n=n||[];var a=[0,0],r=[0,0],w=[0,0],g=0,x=0,j=0,v=0,h=0,k=0,A=0,B=[],C=[],D=e,E=e;if(E.length<3)return f;if(s++,s>i)return console.warn("quickDecomp: max level ("+i+") reached."),f;for(var F=0;F<e.length;++F)if(b(D,F)){o.push(D[F]),g=x=Number.MAX_VALUE;for(var G=0;G<e.length;++G)t(y(D,F-1),y(D,F),y(D,G))&&p(y(D,F-1),y(D,F),y(D,G-1))&&(w=q(y(D,F-1),y(D,F),y(D,G),y(D,G-1)),u(y(D,F+1),y(D,F),w)&&(j=c(D[F],w),x>j&&(x=j,r=w,k=G))),t(y(D,F+1),y(D,F),y(D,G+1))&&p(y(D,F+1),y(D,F),y(D,G))&&(w=q(y(D,F+1),y(D,F),y(D,G),y(D,G+1)),t(y(D,F-1),y(D,F),w)&&(j=c(D[F],w),g>j&&(g=j,a=w,h=G)));if(k===(h+1)%e.length)w[0]=(r[0]+a[0])/2,w[1]=(r[1]+a[1])/2,n.push(w),h>F?(m(B,D,F,h+1),B.push(w),C.push(w),0!==k&&m(C,D,k,D.length),m(C,D,0,F+1)):(0!==F&&m(B,D,F,D.length),m(B,D,0,h+1),B.push(w),C.push(w),m(C,D,k,F+1));else{if(k>h&&(h+=e.length),v=Number.MAX_VALUE,k>h)return f;for(var G=k;h>=G;++G)l(y(D,F-1),y(D,F),y(D,G))&&p(y(D,F+1),y(D,F),y(D,G))&&(j=c(y(D,F),y(D,G)),v>j&&(v=j,A=G%e.length));A>F?(m(B,D,F,A+1),0!==A&&m(C,D,A,E.length),m(C,D,0,F+1)):(0!==F&&m(B,D,F,E.length),m(B,D,0,A+1),m(C,D,A,F+1))}return B.length<C.length?(z(B,f,o,n,d,i,s),z(C,f,o,n,d,i,s)):(z(C,f,o,n,d,i,s),z(B,f,o,n,d,i,s)),f}return f.push(e),f}function A(e,f){for(var o=0,n=e.length-1;e.length>3&&n>=0;--n)s(y(e,n-1),y(e,n),y(e,n+1),f)&&(e.splice(n%e.length,1),o++);return o}function B(e,f,o){return o=o||0,Math.abs(e-f)<o}f.exports={decomp:v,quickDecomp:z,isSimple:k,removeCollinearPoints:A,makeCCW:r};var C=[],D=[],E=[],F=[]},{}]},{},[1])(1)});
/**
* matter-js 0.14.2 by @liabru 2018-06-11
* http://brm.io/matter-js/
* License MIT
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Matter=e()}}(function(){return function(){function e(t,n,o){function i(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[s]={exports:{}};t[s][0].call(d.exports,function(e){return i(t[s][1][e]||e)},d,d.exports,e,t,n,o)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}return e}()({1:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=(e("../render/Render"),e("../core/Common")),l=e("../geometry/Bounds"),c=e("../geometry/Axes");!function(){o._inertiaScale=4,
o._nextCollidingGroupId=1,o._nextNonCollidingGroupId=-1,o._nextCategory=1,o.create=function(t){var n={id:a.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:i.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0},lineWidth:0}},o=a.extend(n,t);return e(o,t),o},o.nextGroup=function(e){return e?o._nextNonCollidingGroupId--:o._nextCollidingGroupId++},o.nextCategory=function(){return o._nextCategory=o._nextCategory<<1,o._nextCategory};var e=function(e,t){t=t||{},o.set(e,{bounds:e.bounds||l.create(e.vertices),
positionPrev:e.positionPrev||r.clone(e.position),anglePrev:e.anglePrev||e.angle,vertices:e.vertices,parts:e.parts||[e],isStatic:e.isStatic,isSleeping:e.isSleeping,parent:e.parent||e}),i.rotate(e.vertices,e.angle,e.position),c.rotate(e.axes,e.angle),l.update(e.bounds,e.vertices,e.velocity),o.set(e,{axes:t.axes||e.axes,area:t.area||e.area,mass:t.mass||e.mass,inertia:t.inertia||e.inertia});var n=e.isStatic?"#2e2b44":a.choose(["#006BA6","#0496FF","#FFBC42","#D81159","#8F2D56"]);e.render.fillStyle=e.render.fillStyle||n,e.render.strokeStyle=e.render.strokeStyle||"#000",e.render.sprite.xOffset+=-(e.bounds.min.x-e.position.x)/(e.bounds.max.x-e.bounds.min.x),e.render.sprite.yOffset+=-(e.bounds.min.y-e.position.y)/(e.bounds.max.y-e.bounds.min.y)};o.set=function(e,t,n){var i;"string"==typeof t&&(i=t,t={},t[i]=n);for(i in t)if(n=t[i],t.hasOwnProperty(i))switch(i){case"isStatic":o.setStatic(e,n);break;case"isSleeping":s.set(e,n);break;case"mass":o.setMass(e,n);break;case"density":o.setDensity(e,n)
;break;case"inertia":o.setInertia(e,n);break;case"vertices":o.setVertices(e,n);break;case"position":o.setPosition(e,n);break;case"angle":o.setAngle(e,n);break;case"velocity":o.setVelocity(e,n);break;case"angularVelocity":o.setAngularVelocity(e,n);break;case"parts":o.setParts(e,n);break;default:e[i]=n}},o.setStatic=function(e,t){for(var n=0;n<e.parts.length;n++){var o=e.parts[n];o.isStatic=t,t?(o._original={restitution:o.restitution,friction:o.friction,mass:o.mass,inertia:o.inertia,density:o.density,inverseMass:o.inverseMass,inverseInertia:o.inverseInertia},o.restitution=0,o.friction=1,o.mass=o.inertia=o.density=1/0,o.inverseMass=o.inverseInertia=0,o.positionPrev.x=o.position.x,o.positionPrev.y=o.position.y,o.anglePrev=o.angle,o.angularVelocity=0,o.speed=0,o.angularSpeed=0,o.motion=0):o._original&&(o.restitution=o._original.restitution,o.friction=o._original.friction,o.mass=o._original.mass,o.inertia=o._original.inertia,o.density=o._original.density,
o.inverseMass=o._original.inverseMass,o.inverseInertia=o._original.inverseInertia,delete o._original)}},o.setMass=function(e,t){var n=e.inertia/(e.mass/6);e.inertia=n*(t/6),e.inverseInertia=1/e.inertia,e.mass=t,e.inverseMass=1/e.mass,e.density=e.mass/e.area},o.setDensity=function(e,t){o.setMass(e,t*e.area),e.density=t},o.setInertia=function(e,t){e.inertia=t,e.inverseInertia=1/e.inertia},o.setVertices=function(e,t){t[0].body===e?e.vertices=t:e.vertices=i.create(t,e),e.axes=c.fromVertices(e.vertices),e.area=i.area(e.vertices),o.setMass(e,e.density*e.area);var n=i.centre(e.vertices);i.translate(e.vertices,n,-1),o.setInertia(e,o._inertiaScale*i.inertia(e.vertices,e.mass)),i.translate(e.vertices,e.position),l.update(e.bounds,e.vertices,e.velocity)},o.setParts=function(e,t,n){var r;for(t=t.slice(0),e.parts.length=0,e.parts.push(e),e.parent=e,r=0;r<t.length;r++){var s=t[r];s!==e&&(s.parent=e,e.parts.push(s))}if(1!==e.parts.length){if(n=void 0===n||n){var a=[]
;for(r=0;r<t.length;r++)a=a.concat(t[r].vertices);i.clockwiseSort(a);var l=i.hull(a),c=i.centre(l);o.setVertices(e,l),i.translate(e.vertices,c)}var d=o._totalProperties(e);e.area=d.area,e.parent=e,e.position.x=d.centre.x,e.position.y=d.centre.y,e.positionPrev.x=d.centre.x,e.positionPrev.y=d.centre.y,o.setMass(e,d.mass),o.setInertia(e,d.inertia),o.setPosition(e,d.centre)}},o.setPosition=function(e,t){var n=r.sub(t,e.position);e.positionPrev.x+=n.x,e.positionPrev.y+=n.y;for(var o=0;o<e.parts.length;o++){var s=e.parts[o];s.position.x+=n.x,s.position.y+=n.y,i.translate(s.vertices,n),l.update(s.bounds,s.vertices,e.velocity)}},o.setAngle=function(e,t){var n=t-e.angle;e.anglePrev+=n;for(var o=0;o<e.parts.length;o++){var s=e.parts[o];s.angle+=n,i.rotate(s.vertices,n,e.position),c.rotate(s.axes,n),l.update(s.bounds,s.vertices,e.velocity),o>0&&r.rotateAbout(s.position,n,e.position,s.position)}},o.setVelocity=function(e,t){e.positionPrev.x=e.position.x-t.x,e.positionPrev.y=e.position.y-t.y,
e.velocity.x=t.x,e.velocity.y=t.y,e.speed=r.magnitude(e.velocity)},o.setAngularVelocity=function(e,t){e.anglePrev=e.angle-t,e.angularVelocity=t,e.angularSpeed=Math.abs(e.angularVelocity)},o.translate=function(e,t){o.setPosition(e,r.add(e.position,t))},o.rotate=function(e,t,n){if(n){var i=Math.cos(t),r=Math.sin(t),s=e.position.x-n.x,a=e.position.y-n.y;o.setPosition(e,{x:n.x+(s*i-a*r),y:n.y+(s*r+a*i)}),o.setAngle(e,e.angle+t)}else o.setAngle(e,e.angle+t)},o.scale=function(e,t,n,r){var s=0,a=0;r=r||e.position;for(var d=0;d<e.parts.length;d++){var u=e.parts[d];i.scale(u.vertices,t,n,r),u.axes=c.fromVertices(u.vertices),u.area=i.area(u.vertices),o.setMass(u,e.density*u.area),i.translate(u.vertices,{x:-u.position.x,y:-u.position.y}),o.setInertia(u,o._inertiaScale*i.inertia(u.vertices,u.mass)),i.translate(u.vertices,{x:u.position.x,y:u.position.y}),d>0&&(s+=u.area,a+=u.inertia),u.position.x=r.x+(u.position.x-r.x)*t,u.position.y=r.y+(u.position.y-r.y)*n,l.update(u.bounds,u.vertices,e.velocity)
}e.parts.length>1&&(e.area=s,e.isStatic||(o.setMass(e,e.density*s),o.setInertia(e,a))),e.circleRadius&&(t===n?e.circleRadius*=t:e.circleRadius=null)},o.update=function(e,t,n,o){var s=Math.pow(t*n*e.timeScale,2),a=1-e.frictionAir*n*e.timeScale,d=e.position.x-e.positionPrev.x,u=e.position.y-e.positionPrev.y;e.velocity.x=d*a*o+e.force.x/e.mass*s,e.velocity.y=u*a*o+e.force.y/e.mass*s,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.position.x+=e.velocity.x,e.position.y+=e.velocity.y,e.angularVelocity=(e.angle-e.anglePrev)*a*o+e.torque/e.inertia*s,e.anglePrev=e.angle,e.angle+=e.angularVelocity,e.speed=r.magnitude(e.velocity),e.angularSpeed=Math.abs(e.angularVelocity);for(var p=0;p<e.parts.length;p++){var f=e.parts[p];i.translate(f.vertices,e.velocity),p>0&&(f.position.x+=e.velocity.x,f.position.y+=e.velocity.y),0!==e.angularVelocity&&(i.rotate(f.vertices,e.angularVelocity,e.position),c.rotate(f.axes,e.angularVelocity),
p>0&&r.rotateAbout(f.position,e.angularVelocity,e.position,f.position)),l.update(f.bounds,f.vertices,e.velocity)}},o.applyForce=function(e,t,n){e.force.x+=n.x,e.force.y+=n.y;var o={x:t.x-e.position.x,y:t.y-e.position.y};e.torque+=o.x*n.y-o.y*n.x},o._totalProperties=function(e){for(var t={mass:0,area:0,inertia:0,centre:{x:0,y:0}},n=1===e.parts.length?0:1;n<e.parts.length;n++){var o=e.parts[n],i=o.mass!==1/0?o.mass:1;t.mass+=i,t.area+=o.area,t.inertia+=o.inertia,t.centre=r.add(t.centre,r.mult(o.position,i))}return t.centre=r.div(t.centre,t.mass),t}}()},{"../core/Common":14,"../core/Sleeping":22,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29,"../render/Render":31}],2:[function(e,t,n){var o={};t.exports=o;var i=e("../core/Events"),r=e("../core/Common"),s=e("../geometry/Bounds"),a=e("./Body");!function(){o.create=function(e){return r.extend({id:r.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],
label:"Composite",plugin:{}},e)},o.setModified=function(e,t,n,i){if(e.isModified=t,n&&e.parent&&o.setModified(e.parent,t,n,i),i)for(var r=0;r<e.composites.length;r++){var s=e.composites[r];o.setModified(s,t,n,i)}},o.add=function(e,t){var n=[].concat(t);i.trigger(e,"beforeAdd",{object:t});for(var s=0;s<n.length;s++){var a=n[s];switch(a.type){case"body":if(a.parent!==a){r.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}o.addBody(e,a);break;case"constraint":o.addConstraint(e,a);break;case"composite":o.addComposite(e,a);break;case"mouseConstraint":o.addConstraint(e,a.constraint)}}return i.trigger(e,"afterAdd",{object:t}),e},o.remove=function(e,t,n){var r=[].concat(t);i.trigger(e,"beforeRemove",{object:t});for(var s=0;s<r.length;s++){var a=r[s];switch(a.type){case"body":o.removeBody(e,a,n);break;case"constraint":o.removeConstraint(e,a,n);break;case"composite":o.removeComposite(e,a,n);break;case"mouseConstraint":
o.removeConstraint(e,a.constraint)}}return i.trigger(e,"afterRemove",{object:t}),e},o.addComposite=function(e,t){return e.composites.push(t),t.parent=e,o.setModified(e,!0,!0,!1),e},o.removeComposite=function(e,t,n){var i=r.indexOf(e.composites,t);if(-1!==i&&(o.removeCompositeAt(e,i),o.setModified(e,!0,!0,!1)),n)for(var s=0;s<e.composites.length;s++)o.removeComposite(e.composites[s],t,!0);return e},o.removeCompositeAt=function(e,t){return e.composites.splice(t,1),o.setModified(e,!0,!0,!1),e},o.addBody=function(e,t){return e.bodies.push(t),o.setModified(e,!0,!0,!1),e},o.removeBody=function(e,t,n){var i=r.indexOf(e.bodies,t);if(-1!==i&&(o.removeBodyAt(e,i),o.setModified(e,!0,!0,!1)),n)for(var s=0;s<e.composites.length;s++)o.removeBody(e.composites[s],t,!0);return e},o.removeBodyAt=function(e,t){return e.bodies.splice(t,1),o.setModified(e,!0,!0,!1),e},o.addConstraint=function(e,t){return e.constraints.push(t),o.setModified(e,!0,!0,!1),e},o.removeConstraint=function(e,t,n){
var i=r.indexOf(e.constraints,t);if(-1!==i&&o.removeConstraintAt(e,i),n)for(var s=0;s<e.composites.length;s++)o.removeConstraint(e.composites[s],t,!0);return e},o.removeConstraintAt=function(e,t){return e.constraints.splice(t,1),o.setModified(e,!0,!0,!1),e},o.clear=function(e,t,n){if(n)for(var i=0;i<e.composites.length;i++)o.clear(e.composites[i],t,!0);return t?e.bodies=e.bodies.filter(function(e){return e.isStatic}):e.bodies.length=0,e.constraints.length=0,e.composites.length=0,o.setModified(e,!0,!0,!1),e},o.allBodies=function(e){for(var t=[].concat(e.bodies),n=0;n<e.composites.length;n++)t=t.concat(o.allBodies(e.composites[n]));return t},o.allConstraints=function(e){for(var t=[].concat(e.constraints),n=0;n<e.composites.length;n++)t=t.concat(o.allConstraints(e.composites[n]));return t},o.allComposites=function(e){for(var t=[].concat(e.composites),n=0;n<e.composites.length;n++)t=t.concat(o.allComposites(e.composites[n]));return t},o.get=function(e,t,n){var i,r;switch(n){case"body":
i=o.allBodies(e);break;case"constraint":i=o.allConstraints(e);break;case"composite":i=o.allComposites(e).concat(e)}return i?(r=i.filter(function(e){return e.id.toString()===t.toString()}),0===r.length?null:r[0]):null},o.move=function(e,t,n){return o.remove(e,t),o.add(n,t),e},o.rebase=function(e){for(var t=o.allBodies(e).concat(o.allConstraints(e)).concat(o.allComposites(e)),n=0;n<t.length;n++)t[n].id=r.nextId();return o.setModified(e,!0,!0,!1),e},o.translate=function(e,t,n){for(var i=n?o.allBodies(e):e.bodies,r=0;r<i.length;r++)a.translate(i[r],t);return o.setModified(e,!0,!0,!1),e},o.rotate=function(e,t,n,i){for(var r=Math.cos(t),s=Math.sin(t),l=i?o.allBodies(e):e.bodies,c=0;c<l.length;c++){var d=l[c],u=d.position.x-n.x,p=d.position.y-n.y;a.setPosition(d,{x:n.x+(u*r-p*s),y:n.y+(u*s+p*r)}),a.rotate(d,t)}return o.setModified(e,!0,!0,!1),e},o.scale=function(e,t,n,i,r){for(var s=r?o.allBodies(e):e.bodies,l=0;l<s.length;l++){var c=s[l],d=c.position.x-i.x,u=c.position.y-i.y
;a.setPosition(c,{x:i.x+d*t,y:i.y+u*n}),a.scale(c,t,n)}return o.setModified(e,!0,!0,!1),e},o.bounds=function(e){for(var t=o.allBodies(e),n=[],i=0;i<t.length;i+=1){var r=t[i];n.push(r.bounds.min,r.bounds.max)}return s.create(n)}}()},{"../core/Common":14,"../core/Events":16,"../geometry/Bounds":26,"./Body":1}],3:[function(e,t,n){var o={};t.exports=o;var i=e("./Composite"),r=(e("../constraint/Constraint"),e("../core/Common"));!function(){o.create=function(e){var t=i.create(),n={label:"World",gravity:{x:0,y:1,scale:.001},bounds:{min:{x:-1/0,y:-1/0},max:{x:1/0,y:1/0}}};return r.extend(t,n,e)}}()},{"../constraint/Constraint":12,"../core/Common":14,"./Composite":2}],4:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e){return{id:o.id(e),vertex:e,normalImpulse:0,tangentImpulse:0}},o.id=function(e){return e.body.id+"_"+e.index}}()},{}],5:[function(e,t,n){var o={};t.exports=o;var i=e("./SAT"),r=e("./Pair"),s=e("../geometry/Bounds");!function(){o.collisions=function(e,t){
for(var n=[],a=t.pairs.table,l=0;l<e.length;l++){var c=e[l][0],d=e[l][1];if((!c.isStatic&&!c.isSleeping||!d.isStatic&&!d.isSleeping)&&(o.canCollide(c.collisionFilter,d.collisionFilter)&&s.overlaps(c.bounds,d.bounds)))for(var u=c.parts.length>1?1:0;u<c.parts.length;u++)for(var p=c.parts[u],f=d.parts.length>1?1:0;f<d.parts.length;f++){var m=d.parts[f];if(p===c&&m===d||s.overlaps(p.bounds,m.bounds)){var v,y=r.id(p,m),g=a[y];v=g&&g.isActive?g.collision:null;var x=i.collides(p,m,v);x.collided&&n.push(x)}}}return n},o.canCollide=function(e,t){return e.group===t.group&&0!==e.group?e.group>0:0!=(e.mask&t.category)&&0!=(t.mask&e.category)}}()},{"../geometry/Bounds":26,"./Pair":7,"./SAT":11}],6:[function(e,t,n){var o={};t.exports=o;var i=e("./Pair"),r=e("./Detector"),s=e("../core/Common");!function(){o.create=function(e){var t={controller:o,detector:r.collisions,buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return s.extend(t,e)},o.update=function(e,t,n,i){
var r,s,a,l,c,d=n.world,u=e.buckets,p=!1;for(r=0;r<t.length;r++){var f=t[r];if((!f.isSleeping||i)&&!(f.bounds.max.x<d.bounds.min.x||f.bounds.min.x>d.bounds.max.x||f.bounds.max.y<d.bounds.min.y||f.bounds.min.y>d.bounds.max.y)){var m=o._getRegion(e,f);if(!f.region||m.id!==f.region.id||i){f.region&&!i||(f.region=m);var v=o._regionUnion(m,f.region);for(s=v.startCol;s<=v.endCol;s++)for(a=v.startRow;a<=v.endRow;a++){c=o._getBucketId(s,a),l=u[c];var y=s>=m.startCol&&s<=m.endCol&&a>=m.startRow&&a<=m.endRow,g=s>=f.region.startCol&&s<=f.region.endCol&&a>=f.region.startRow&&a<=f.region.endRow;!y&&g&&g&&l&&o._bucketRemoveBody(e,l,f),(f.region===m||y&&!g||i)&&(l||(l=o._createBucket(u,c)),o._bucketAddBody(e,l,f))}f.region=m,p=!0}}}p&&(e.pairsList=o._createActivePairsList(e))},o.clear=function(e){e.buckets={},e.pairs={},e.pairsList=[]},o._regionUnion=function(e,t){var n=Math.min(e.startCol,t.startCol),i=Math.max(e.endCol,t.endCol),r=Math.min(e.startRow,t.startRow),s=Math.max(e.endRow,t.endRow)
;return o._createRegion(n,i,r,s)},o._getRegion=function(e,t){var n=t.bounds,i=Math.floor(n.min.x/e.bucketWidth),r=Math.floor(n.max.x/e.bucketWidth),s=Math.floor(n.min.y/e.bucketHeight),a=Math.floor(n.max.y/e.bucketHeight);return o._createRegion(i,r,s,a)},o._createRegion=function(e,t,n,o){return{id:e+","+t+","+n+","+o,startCol:e,endCol:t,startRow:n,endRow:o}},o._getBucketId=function(e,t){return"C"+e+"R"+t},o._createBucket=function(e,t){return e[t]=[]},o._bucketAddBody=function(e,t,n){for(var o=0;o<t.length;o++){var r=t[o];if(!(n.id===r.id||n.isStatic&&r.isStatic)){var s=i.id(n,r),a=e.pairs[s];a?a[2]+=1:e.pairs[s]=[n,r,1]}}t.push(n)},o._bucketRemoveBody=function(e,t,n){t.splice(s.indexOf(t,n),1);for(var o=0;o<t.length;o++){var r=t[o],a=i.id(n,r),l=e.pairs[a];l&&(l[2]-=1)}},o._createActivePairsList=function(e){var t,n,o=[];t=s.keys(e.pairs);for(var i=0;i<t.length;i++)n=e.pairs[t[i]],n[2]>0?o.push(n):delete e.pairs[t[i]];return o}}()},{"../core/Common":14,"./Detector":5,"./Pair":7}],
7:[function(e,t,n){var o={};t.exports=o;var i=e("./Contact");!function(){o.create=function(e,t){var n=e.bodyA,i=e.bodyB,r=e.parentA,s=e.parentB,a={id:o.id(n,i),bodyA:n,bodyB:i,contacts:{},activeContacts:[],separation:0,isActive:!0,isSensor:n.isSensor||i.isSensor,timeCreated:t,timeUpdated:t,inverseMass:r.inverseMass+s.inverseMass,friction:Math.min(r.friction,s.friction),frictionStatic:Math.max(r.frictionStatic,s.frictionStatic),restitution:Math.max(r.restitution,s.restitution),slop:Math.max(r.slop,s.slop)};return o.update(a,e,t),a},o.update=function(e,t,n){var r=e.contacts,s=t.supports,a=e.activeContacts,l=t.parentA,c=t.parentB;if(e.collision=t,e.inverseMass=l.inverseMass+c.inverseMass,e.friction=Math.min(l.friction,c.friction),e.frictionStatic=Math.max(l.frictionStatic,c.frictionStatic),e.restitution=Math.max(l.restitution,c.restitution),e.slop=Math.max(l.slop,c.slop),a.length=0,t.collided){for(var d=0;d<s.length;d++){var u=s[d],p=i.id(u),f=r[p];f?a.push(f):a.push(r[p]=i.create(u))}
e.separation=t.depth,o.setActive(e,!0,n)}else!0===e.isActive&&o.setActive(e,!1,n)},o.setActive=function(e,t,n){t?(e.isActive=!0,e.timeUpdated=n):(e.isActive=!1,e.activeContacts.length=0)},o.id=function(e,t){return e.id<t.id?"A"+e.id+"B"+t.id:"A"+t.id+"B"+e.id}}()},{"./Contact":4}],8:[function(e,t,n){var o={};t.exports=o;var i=e("./Pair"),r=e("../core/Common");!function(){o._pairMaxIdleLife=1e3,o.create=function(e){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},e)},o.update=function(e,t,n){var o,s,a,l,c=e.list,d=e.table,u=e.collisionStart,p=e.collisionEnd,f=e.collisionActive,m=[];for(u.length=0,p.length=0,f.length=0,l=0;l<t.length;l++)o=t[l],o.collided&&(s=i.id(o.bodyA,o.bodyB),m.push(s),a=d[s],a?(a.isActive?f.push(a):u.push(a),i.update(a,o,n)):(a=i.create(o,n),d[s]=a,u.push(a),c.push(a)));for(l=0;l<c.length;l++)a=c[l],a.isActive&&-1===r.indexOf(m,a.id)&&(i.setActive(a,!1,n),p.push(a))},o.removeOld=function(e,t){
var n,i,r,s,a=e.list,l=e.table,c=[];for(s=0;s<a.length;s++)n=a[s],i=n.collision,i.bodyA.isSleeping||i.bodyB.isSleeping?n.timeUpdated=t:t-n.timeUpdated>o._pairMaxIdleLife&&c.push(s);for(s=0;s<c.length;s++)r=c[s]-s,n=a[r],delete l[n.id],a.splice(r,1)},o.clear=function(e){return e.table={},e.list.length=0,e.collisionStart.length=0,e.collisionActive.length=0,e.collisionEnd.length=0,e}}()},{"../core/Common":14,"./Pair":7}],9:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("./SAT"),s=e("../geometry/Bounds"),a=e("../factory/Bodies"),l=e("../geometry/Vertices");!function(){o.collides=function(e,t){for(var n=[],o=0;o<t.length;o++){var i=t[o];if(s.overlaps(i.bounds,e.bounds))for(var a=1===i.parts.length?0:1;a<i.parts.length;a++){var l=i.parts[a];if(s.overlaps(l.bounds,e.bounds)){var c=r.collides(l,e);if(c.collided){n.push(c);break}}}}return n},o.ray=function(e,t,n,r){r=r||1e-100
;for(var s=i.angle(t,n),l=i.magnitude(i.sub(t,n)),c=.5*(n.x+t.x),d=.5*(n.y+t.y),u=a.rectangle(c,d,l,r,{angle:s}),p=o.collides(u,e),f=0;f<p.length;f+=1){var m=p[f];m.body=m.bodyB=m.bodyA}return p},o.region=function(e,t,n){for(var o=[],i=0;i<e.length;i++){var r=e[i],a=s.overlaps(r.bounds,t);(a&&!n||!a&&n)&&o.push(r)}return o},o.point=function(e,t){for(var n=[],o=0;o<e.length;o++){var i=e[o];if(s.contains(i.bounds,t))for(var r=1===i.parts.length?0:1;r<i.parts.length;r++){var a=i.parts[r];if(s.contains(a.bounds,t)&&l.contains(a.vertices,t)){n.push(i);break}}}return n}}()},{"../factory/Bodies":23,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29,"./SAT":11}],10:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Common"),a=e("../geometry/Bounds");!function(){o._restingThresh=4,o._restingThreshTangent=6,o._positionDampen=.9,o._positionWarming=.8,o._frictionNormalMultiplier=5,o.preSolvePosition=function(e){
var t,n,o;for(t=0;t<e.length;t++)n=e[t],n.isActive&&(o=n.activeContacts.length,n.collision.parentA.totalContacts+=o,n.collision.parentB.totalContacts+=o)},o.solvePosition=function(e,t){var n,i,s,a,l,c,d,u,p,f=r._temp[0],m=r._temp[1],v=r._temp[2],y=r._temp[3];for(n=0;n<e.length;n++)i=e[n],i.isActive&&!i.isSensor&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,d=r.sub(r.add(l.positionImpulse,l.position,f),r.add(a.positionImpulse,r.sub(l.position,s.penetration,m),v),y),i.separation=r.dot(c,d));for(n=0;n<e.length;n++)i=e[n],i.isActive&&!i.isSensor&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,p=(i.separation-i.slop)*t,(a.isStatic||l.isStatic)&&(p*=2),a.isStatic||a.isSleeping||(u=o._positionDampen/a.totalContacts,a.positionImpulse.x+=c.x*p*u,a.positionImpulse.y+=c.y*p*u),l.isStatic||l.isSleeping||(u=o._positionDampen/l.totalContacts,l.positionImpulse.x-=c.x*p*u,l.positionImpulse.y-=c.y*p*u))},o.postSolvePosition=function(e){for(var t=0;t<e.length;t++){var n=e[t]
;if(n.totalContacts=0,0!==n.positionImpulse.x||0!==n.positionImpulse.y){for(var s=0;s<n.parts.length;s++){var l=n.parts[s];i.translate(l.vertices,n.positionImpulse),a.update(l.bounds,l.vertices,n.velocity),l.position.x+=n.positionImpulse.x,l.position.y+=n.positionImpulse.y}n.positionPrev.x+=n.positionImpulse.x,n.positionPrev.y+=n.positionImpulse.y,r.dot(n.positionImpulse,n.velocity)<0?(n.positionImpulse.x=0,n.positionImpulse.y=0):(n.positionImpulse.x*=o._positionWarming,n.positionImpulse.y*=o._positionWarming)}}},o.preSolveVelocity=function(e){var t,n,o,i,s,a,l,c,d,u,p,f,m,v,y=r._temp[0],g=r._temp[1];for(t=0;t<e.length;t++)if(o=e[t],o.isActive&&!o.isSensor)for(i=o.activeContacts,s=o.collision,a=s.parentA,l=s.parentB,c=s.normal,d=s.tangent,n=0;n<i.length;n++)u=i[n],p=u.vertex,f=u.normalImpulse,m=u.tangentImpulse,0===f&&0===m||(y.x=c.x*f+d.x*m,y.y=c.y*f+d.y*m,a.isStatic||a.isSleeping||(v=r.sub(p,a.position,g),a.positionPrev.x+=y.x*a.inverseMass,a.positionPrev.y+=y.y*a.inverseMass,
a.anglePrev+=r.cross(v,y)*a.inverseInertia),l.isStatic||l.isSleeping||(v=r.sub(p,l.position,g),l.positionPrev.x-=y.x*l.inverseMass,l.positionPrev.y-=y.y*l.inverseMass,l.anglePrev-=r.cross(v,y)*l.inverseInertia))},o.solveVelocity=function(e,t){for(var n=t*t,i=r._temp[0],a=r._temp[1],l=r._temp[2],c=r._temp[3],d=r._temp[4],u=r._temp[5],p=0;p<e.length;p++){var f=e[p];if(f.isActive&&!f.isSensor){var m=f.collision,v=m.parentA,y=m.parentB,g=m.normal,x=m.tangent,h=f.activeContacts,b=1/h.length;v.velocity.x=v.position.x-v.positionPrev.x,v.velocity.y=v.position.y-v.positionPrev.y,y.velocity.x=y.position.x-y.positionPrev.x,y.velocity.y=y.position.y-y.positionPrev.y,v.angularVelocity=v.angle-v.anglePrev,y.angularVelocity=y.angle-y.anglePrev;for(var w=0;w<h.length;w++){
var S=h[w],C=S.vertex,A=r.sub(C,v.position,a),P=r.sub(C,y.position,l),B=r.add(v.velocity,r.mult(r.perp(A),v.angularVelocity),c),M=r.add(y.velocity,r.mult(r.perp(P),y.angularVelocity),d),k=r.sub(B,M,u),I=r.dot(g,k),_=r.dot(x,k),T=Math.abs(_),R=s.sign(_),V=(1+f.restitution)*I,E=s.clamp(f.separation+I,0,1)*o._frictionNormalMultiplier,L=_,F=1/0;T>f.friction*f.frictionStatic*E*n&&(F=T,L=s.clamp(f.friction*R*n,-F,F));var O=r.cross(A,g),q=r.cross(P,g),W=b/(v.inverseMass+y.inverseMass+v.inverseInertia*O*O+y.inverseInertia*q*q);if(V*=W,L*=W,I<0&&I*I>o._restingThresh*n)S.normalImpulse=0;else{var D=S.normalImpulse;S.normalImpulse=Math.min(S.normalImpulse+V,0),V=S.normalImpulse-D}if(_*_>o._restingThreshTangent*n)S.tangentImpulse=0;else{var N=S.tangentImpulse;S.tangentImpulse=s.clamp(S.tangentImpulse+L,-F,F),L=S.tangentImpulse-N}i.x=g.x*V+x.x*L,i.y=g.y*V+x.y*L,v.isStatic||v.isSleeping||(v.positionPrev.x+=i.x*v.inverseMass,v.positionPrev.y+=i.y*v.inverseMass,
v.anglePrev+=r.cross(A,i)*v.inverseInertia),y.isStatic||y.isSleeping||(y.positionPrev.x-=i.x*y.inverseMass,y.positionPrev.y-=i.y*y.inverseMass,y.anglePrev-=r.cross(P,i)*y.inverseInertia)}}}}}()},{"../core/Common":14,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],11:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector");!function(){o.collides=function(e,t,n){var s,a,l,c,d=!1;if(n){var u=e.parent,p=t.parent,f=u.speed*u.speed+u.angularSpeed*u.angularSpeed+p.speed*p.speed+p.angularSpeed*p.angularSpeed;d=n&&n.collided&&f<.2,c=n}else c={collided:!1,bodyA:e,bodyB:t};if(n&&d){var m=c.axisBody,v=m===e?t:e,y=[m.axes[n.axisNumber]];if(l=o._overlapAxes(m.vertices,v.vertices,y),c.reused=!0,l.overlap<=0)return c.collided=!1,c}else{if(s=o._overlapAxes(e.vertices,t.vertices,e.axes),s.overlap<=0)return c.collided=!1,c;if(a=o._overlapAxes(t.vertices,e.vertices,t.axes),a.overlap<=0)return c.collided=!1,c;s.overlap<a.overlap?(l=s,
c.axisBody=e):(l=a,c.axisBody=t),c.axisNumber=l.axisNumber}c.bodyA=e.id<t.id?e:t,c.bodyB=e.id<t.id?t:e,c.collided=!0,c.depth=l.overlap,c.parentA=c.bodyA.parent,c.parentB=c.bodyB.parent,e=c.bodyA,t=c.bodyB,r.dot(l.axis,r.sub(t.position,e.position))<0?c.normal={x:l.axis.x,y:l.axis.y}:c.normal={x:-l.axis.x,y:-l.axis.y},c.tangent=r.perp(c.normal),c.penetration=c.penetration||{},c.penetration.x=c.normal.x*c.depth,c.penetration.y=c.normal.y*c.depth;var g=o._findSupports(e,t,c.normal),x=[];if(i.contains(e.vertices,g[0])&&x.push(g[0]),i.contains(e.vertices,g[1])&&x.push(g[1]),x.length<2){var h=o._findSupports(t,e,r.neg(c.normal));i.contains(t.vertices,h[0])&&x.push(h[0]),x.length<2&&i.contains(t.vertices,h[1])&&x.push(h[1])}return x.length<1&&(x=[g[0]]),c.supports=x,c},o._overlapAxes=function(e,t,n){for(var i,s,a=r._temp[0],l=r._temp[1],c={overlap:Number.MAX_VALUE},d=0;d<n.length;d++){if(s=n[d],o._projectToAxis(a,e,s),o._projectToAxis(l,t,s),
(i=Math.min(a.max-l.min,l.max-a.min))<=0)return c.overlap=i,c;i<c.overlap&&(c.overlap=i,c.axis=s,c.axisNumber=d)}return c},o._projectToAxis=function(e,t,n){for(var o=r.dot(t[0],n),i=o,s=1;s<t.length;s+=1){var a=r.dot(t[s],n);a>i?i=a:a<o&&(o=a)}e.min=o,e.max=i},o._findSupports=function(e,t,n){for(var o,i,s,a,l=Number.MAX_VALUE,c=r._temp[0],d=t.vertices,u=e.position,p=0;p<d.length;p++)i=d[p],c.x=i.x-u.x,c.y=i.y-u.y,(o=-r.dot(n,c))<l&&(l=o,s=i);return i=d[s.index-1>=0?s.index-1:d.length-1],c.x=i.x-u.x,c.y=i.y-u.y,l=-r.dot(n,c),a=i,i=d[(s.index+1)%d.length],c.x=i.x-u.x,c.y=i.y-u.y,o=-r.dot(n,c),o<l&&(a=i),[s,a]}}()},{"../geometry/Vector":28,"../geometry/Vertices":29}],12:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=e("../geometry/Bounds"),l=e("../geometry/Axes"),c=e("../core/Common");!function(){o._warming=.4,o._torqueDampen=1,o._minLength=1e-6,o.create=function(e){var t=e;t.bodyA&&!t.pointA&&(t.pointA={x:0,y:0}),
t.bodyB&&!t.pointB&&(t.pointB={x:0,y:0});var n=t.bodyA?r.add(t.bodyA.position,t.pointA):t.pointA,o=t.bodyB?r.add(t.bodyB.position,t.pointB):t.pointB,i=r.magnitude(r.sub(n,o));t.length=void 0!==t.length?t.length:i,t.id=t.id||c.nextId(),t.label=t.label||"Constraint",t.type="constraint",t.stiffness=t.stiffness||(t.length>0?1:.7),t.damping=t.damping||0,t.angularStiffness=t.angularStiffness||0,t.angleA=t.bodyA?t.bodyA.angle:t.angleA,t.angleB=t.bodyB?t.bodyB.angle:t.angleB,t.plugin={};var s={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===t.length&&t.stiffness>.1?(s.type="pin",s.anchors=!1):t.stiffness<.9&&(s.type="spring"),t.render=c.extend(s,t.render),t},o.preSolveAll=function(e){for(var t=0;t<e.length;t+=1){var n=e[t],o=n.constraintImpulse;n.isStatic||0===o.x&&0===o.y&&0===o.angle||(n.position.x+=o.x,n.position.y+=o.y,n.angle+=o.angle)}},o.solveAll=function(e,t){for(var n=0;n<e.length;n+=1){
var i=e[n],r=!i.bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic;(r||s)&&o.solve(e[n],t)}for(n=0;n<e.length;n+=1)i=e[n],r=!i.bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic,r||s||o.solve(e[n],t)},o.solve=function(e,t){var n=e.bodyA,i=e.bodyB,s=e.pointA,a=e.pointB;if(n||i){n&&!n.isStatic&&(r.rotate(s,n.angle-e.angleA,s),e.angleA=n.angle),i&&!i.isStatic&&(r.rotate(a,i.angle-e.angleB,a),e.angleB=i.angle);var l=s,c=a;if(n&&(l=r.add(n.position,s)),i&&(c=r.add(i.position,a)),l&&c){var d=r.sub(l,c),u=r.magnitude(d);u<o._minLength&&(u=o._minLength);var p,f,m,v,y,g=(u-e.length)/u,x=e.stiffness<1?e.stiffness*t:e.stiffness,h=r.mult(d,g*x),b=(n?n.inverseMass:0)+(i?i.inverseMass:0),w=(n?n.inverseInertia:0)+(i?i.inverseInertia:0),S=b+w;if(e.damping){var C=r.create();m=r.div(d,u),y=r.sub(i&&r.sub(i.position,i.positionPrev)||C,n&&r.sub(n.position,n.positionPrev)||C),v=r.dot(m,y)}n&&!n.isStatic&&(f=n.inverseMass/b,n.constraintImpulse.x-=h.x*f,
n.constraintImpulse.y-=h.y*f,n.position.x-=h.x*f,n.position.y-=h.y*f,e.damping&&(n.positionPrev.x-=e.damping*m.x*v*f,n.positionPrev.y-=e.damping*m.y*v*f),p=r.cross(s,h)/S*o._torqueDampen*n.inverseInertia*(1-e.angularStiffness),n.constraintImpulse.angle-=p,n.angle-=p),i&&!i.isStatic&&(f=i.inverseMass/b,i.constraintImpulse.x+=h.x*f,i.constraintImpulse.y+=h.y*f,i.position.x+=h.x*f,i.position.y+=h.y*f,e.damping&&(i.positionPrev.x+=e.damping*m.x*v*f,i.positionPrev.y+=e.damping*m.y*v*f),p=r.cross(a,h)/S*o._torqueDampen*i.inverseInertia*(1-e.angularStiffness),i.constraintImpulse.angle+=p,i.angle+=p)}}},o.postSolveAll=function(e){for(var t=0;t<e.length;t++){var n=e[t],c=n.constraintImpulse;if(!(n.isStatic||0===c.x&&0===c.y&&0===c.angle)){s.set(n,!1);for(var d=0;d<n.parts.length;d++){var u=n.parts[d];i.translate(u.vertices,c),d>0&&(u.position.x+=c.x,u.position.y+=c.y),0!==c.angle&&(i.rotate(u.vertices,c.angle,n.position),l.rotate(u.axes,c.angle),
d>0&&r.rotateAbout(u.position,c.angle,n.position,u.position)),a.update(u.bounds,u.vertices,n.velocity)}c.angle*=o._warming,c.x*=o._warming,c.y*=o._warming}}}}()},{"../core/Common":14,"../core/Sleeping":22,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],13:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vertices"),r=e("../core/Sleeping"),s=e("../core/Mouse"),a=e("../core/Events"),l=e("../collision/Detector"),c=e("./Constraint"),d=e("../body/Composite"),u=e("../core/Common"),p=e("../geometry/Bounds");!function(){o.create=function(e,t){var n=(e?e.mouse:null)||(t?t.mouse:null);n||(e&&e.render&&e.render.canvas?n=s.create(e.render.canvas):t&&t.element?n=s.create(t.element):(n=s.create(),u.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var i=c.create({label:"Mouse Constraint",pointA:n.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,
render:{strokeStyle:"#90EE90",lineWidth:3}}),r={type:"mouseConstraint",mouse:n,element:null,body:null,constraint:i,collisionFilter:{category:1,mask:4294967295,group:0}},l=u.extend(r,t);return a.on(e,"beforeUpdate",function(){var t=d.allBodies(e.world);o.update(l,t),o._triggerEvents(l)}),l},o.update=function(e,t){var n=e.mouse,o=e.constraint,s=e.body;if(0===n.button){if(o.bodyB)r.set(o.bodyB,!1),o.pointA=n.position;else for(var c=0;c<t.length;c++)if(s=t[c],p.contains(s.bounds,n.position)&&l.canCollide(s.collisionFilter,e.collisionFilter))for(var d=s.parts.length>1?1:0;d<s.parts.length;d++){var u=s.parts[d];if(i.contains(u.vertices,n.position)){o.pointA=n.position,o.bodyB=e.body=s,o.pointB={x:n.position.x-s.position.x,y:n.position.y-s.position.y},o.angleB=s.angle,r.set(s,!1),a.trigger(e,"startdrag",{mouse:n,body:s});break}}}else o.bodyB=e.body=null,o.pointB=null,s&&a.trigger(e,"enddrag",{mouse:n,body:s})},o._triggerEvents=function(e){var t=e.mouse,n=t.sourceEvents
;n.mousemove&&a.trigger(e,"mousemove",{mouse:t}),n.mousedown&&a.trigger(e,"mousedown",{mouse:t}),n.mouseup&&a.trigger(e,"mouseup",{mouse:t}),s.clearSourceEvents(t)}}()},{"../body/Composite":2,"../collision/Detector":5,"../core/Common":14,"../core/Events":16,"../core/Mouse":19,"../core/Sleeping":22,"../geometry/Bounds":26,"../geometry/Vertices":29,"./Constraint":12}],14:[function(e,t,n){(function(n){var o={};t.exports=o,function(){o._nextId=0,o._seed=0,o._nowStartTime=+new Date,o.extend=function(e,t){var n,i;"boolean"==typeof t?(n=2,i=t):(n=1,i=!0);for(var r=n;r<arguments.length;r++){var s=arguments[r];if(s)for(var a in s)i&&s[a]&&s[a].constructor===Object?e[a]&&e[a].constructor!==Object?e[a]=s[a]:(e[a]=e[a]||{},o.extend(e[a],i,s[a])):e[a]=s[a]}return e},o.clone=function(e,t){return o.extend({},t,e)},o.keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var n in e)t.push(n);return t},o.values=function(e){var t=[];if(Object.keys){
for(var n=Object.keys(e),o=0;o<n.length;o++)t.push(e[n[o]]);return t}for(var i in e)t.push(e[i]);return t},o.get=function(e,t,n,o){t=t.split(".").slice(n,o);for(var i=0;i<t.length;i+=1)e=e[t[i]];return e},o.set=function(e,t,n,i,r){var s=t.split(".").slice(i,r);return o.get(e,t,0,-1)[s[s.length-1]]=n,n},o.shuffle=function(e){for(var t=e.length-1;t>0;t--){var n=Math.floor(o.random()*(t+1)),i=e[t];e[t]=e[n],e[n]=i}return e},o.choose=function(e){return e[Math.floor(o.random()*e.length)]},o.isElement=function(e){return"undefined"!=typeof HTMLElement?e instanceof HTMLElement:!!(e&&e.nodeType&&e.nodeName)},o.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},o.isFunction=function(e){return"function"==typeof e},o.isPlainObject=function(e){return"object"==typeof e&&e.constructor===Object},o.isString=function(e){return"[object String]"===toString.call(e)},o.clamp=function(e,t,n){return e<t?t:e>n?n:e},o.sign=function(e){return e<0?-1:1},o.now=function(){
if(window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return new Date-o._nowStartTime},o.random=function(e,n){return e=void 0!==e?e:0,n=void 0!==n?n:1,e+t()*(n-e)};var t=function(){return o._seed=(9301*o._seed+49297)%233280,o._seed/233280};o.colorToNumber=function(e){return e=e.replace("#",""),3==e.length&&(e=e.charAt(0)+e.charAt(0)+e.charAt(1)+e.charAt(1)+e.charAt(2)+e.charAt(2)),parseInt(e,16)},o.logLevel=1,o.log=function(){console&&o.logLevel>0&&o.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.info=function(){console&&o.logLevel>0&&o.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.warn=function(){console&&o.logLevel>0&&o.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},o.nextId=function(){return o._nextId++},
o.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},o.map=function(e,t){if(e.map)return e.map(t);for(var n=[],o=0;o<e.length;o+=1)n.push(t(e[o]));return n},o.topologicalSort=function(e){var t=[],n=[],i=[];for(var r in e)n[r]||i[r]||o._topologicalSort(r,n,i,e,t);return t},o._topologicalSort=function(e,t,n,i,r){var s=i[e]||[];n[e]=!0;for(var a=0;a<s.length;a+=1){var l=s[a];n[l]||(t[l]||o._topologicalSort(l,t,n,i,r))}n[e]=!1,t[e]=!0,r.push(e)},o.chain=function(){for(var e=[],t=0;t<arguments.length;t+=1){var n=arguments[t];n._chained?e.push.apply(e,n._chained):e.push(n)}var o=function(){for(var t,n=new Array(arguments.length),o=0,i=arguments.length;o<i;o++)n[o]=arguments[o];for(o=0;o<e.length;o+=1){var r=e[o].apply(t,n);void 0!==r&&(t=r)}return t};return o._chained=e,o},o.chainPathBefore=function(e,t,n){return o.set(e,t,o.chain(n,o.get(e,t)))},o.chainPathAfter=function(e,t,n){return o.set(e,t,o.chain(o.get(e,t),n))},
o._requireGlobal=function(t,o){return("undefined"!=typeof window?window[t]:void 0!==n?n[t]:null)||e(o)}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],15:[function(e,t,n){var o={};t.exports=o;var i=e("../body/World"),r=e("./Sleeping"),s=e("../collision/Resolver"),a=e("../render/Render"),l=e("../collision/Pairs"),c=(e("./Metrics"),e("../collision/Grid")),d=e("./Events"),u=e("../body/Composite"),p=e("../constraint/Constraint"),f=e("./Common"),m=e("../body/Body");!function(){o.create=function(e,t){t=f.isElement(e)?t:e,e=f.isElement(e)?e:null,t=t||{},(e||t.render)&&f.warn("Engine.create: engine.render is deprecated (see docs)");var n={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},timing:{timestamp:0,timeScale:1},broadphase:{controller:c}},o=f.extend(n,t);if(e||o.render){var r={element:e,controller:a};o.render=f.extend(r,o.render)}
return o.render&&o.render.controller&&(o.render=o.render.controller.create(o.render)),o.render&&(o.render.engine=o),o.world=t.world||i.create(o.world),o.pairs=l.create(),o.broadphase=o.broadphase.controller.create(o.broadphase),o.metrics=o.metrics||{extended:!1},o},o.update=function(e,t,n){t=t||1e3/60,n=n||1;var i,a=e.world,c=e.timing,f=e.broadphase,m=[];c.timestamp+=t*c.timeScale;var v={timestamp:c.timestamp};d.trigger(e,"beforeUpdate",v);var y=u.allBodies(a),g=u.allConstraints(a);for(e.enableSleeping&&r.update(y,c.timeScale),o._bodiesApplyGravity(y,a.gravity),o._bodiesUpdate(y,t,c.timeScale,n,a.bounds),p.preSolveAll(y),i=0;i<e.constraintIterations;i++)p.solveAll(g,c.timeScale);p.postSolveAll(y),f.controller?(a.isModified&&f.controller.clear(f),f.controller.update(f,y,e,a.isModified),m=f.pairsList):m=y,a.isModified&&u.setModified(a,!1,!1,!0);var x=f.detector(m,e),h=e.pairs,b=c.timestamp;for(l.update(h,x,b),l.removeOld(h,b),e.enableSleeping&&r.afterCollisions(h.list,c.timeScale),
h.collisionStart.length>0&&d.trigger(e,"collisionStart",{pairs:h.collisionStart}),s.preSolvePosition(h.list),i=0;i<e.positionIterations;i++)s.solvePosition(h.list,c.timeScale);for(s.postSolvePosition(y),p.preSolveAll(y),i=0;i<e.constraintIterations;i++)p.solveAll(g,c.timeScale);for(p.postSolveAll(y),s.preSolveVelocity(h.list),i=0;i<e.velocityIterations;i++)s.solveVelocity(h.list,c.timeScale);return h.collisionActive.length>0&&d.trigger(e,"collisionActive",{pairs:h.collisionActive}),h.collisionEnd.length>0&&d.trigger(e,"collisionEnd",{pairs:h.collisionEnd}),o._bodiesClearForces(y),d.trigger(e,"afterUpdate",v),e},o.merge=function(e,t){if(f.extend(e,t),t.world){e.world=t.world,o.clear(e);for(var n=u.allBodies(e.world),i=0;i<n.length;i++){var s=n[i];r.set(s,!1),s.id=f.nextId()}}},o.clear=function(e){var t=e.world;l.clear(e.pairs);var n=e.broadphase;if(n.controller){var o=u.allBodies(t);n.controller.clear(n),n.controller.update(n,o,e,!0)}},o._bodiesClearForces=function(e){
for(var t=0;t<e.length;t++){var n=e[t];n.force.x=0,n.force.y=0,n.torque=0}},o._bodiesApplyGravity=function(e,t){var n=void 0!==t.scale?t.scale:.001;if((0!==t.x||0!==t.y)&&0!==n)for(var o=0;o<e.length;o++){var i=e[o];i.isStatic||i.isSleeping||(i.force.y+=i.mass*t.y*n,i.force.x+=i.mass*t.x*n)}},o._bodiesUpdate=function(e,t,n,o,i){for(var r=0;r<e.length;r++){var s=e[r];s.isStatic||s.isSleeping||m.update(s,t,n,o)}}}()},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Grid":6,"../collision/Pairs":8,"../collision/Resolver":10,"../constraint/Constraint":12,"../render/Render":31,"./Common":14,"./Events":16,"./Metrics":18,"./Sleeping":22}],16:[function(e,t,n){var o={};t.exports=o;var i=e("./Common");!function(){o.on=function(e,t,n){for(var o,i=t.split(" "),r=0;r<i.length;r++)o=i[r],e.events=e.events||{},e.events[o]=e.events[o]||[],e.events[o].push(n);return n},o.off=function(e,t,n){if(!t)return void(e.events={});"function"==typeof t&&(n=t,t=i.keys(e.events).join(" "))
;for(var o=t.split(" "),r=0;r<o.length;r++){var s=e.events[o[r]],a=[];if(n&&s)for(var l=0;l<s.length;l++)s[l]!==n&&a.push(s[l]);e.events[o[r]]=a}},o.trigger=function(e,t,n){var o,r,s,a;if(e.events){n||(n={}),o=t.split(" ");for(var l=0;l<o.length;l++)if(r=o[l],s=e.events[r]){a=i.clone(n,!1),a.name=r,a.source=e;for(var c=0;c<s.length;c++)s[c].apply(e,[a])}}}}()},{"./Common":14}],17:[function(e,t,n){var o={};t.exports=o;var i=e("./Plugin"),r=e("./Common");!function(){o.name="matter-js",o.version="0.14.2",o.uses=[],o.used=[],o.use=function(){i.use(o,Array.prototype.slice.call(arguments))},o.before=function(e,t){return e=e.replace(/^Matter./,""),r.chainPathBefore(o,e,t)},o.after=function(e,t){return e=e.replace(/^Matter./,""),r.chainPathAfter(o,e,t)}}()},{"./Common":14,"./Plugin":20}],18:[function(e,t,n){},{"../body/Composite":2,"./Common":14}],19:[function(e,t,n){var o={};t.exports=o;var i=e("../core/Common");!function(){o.create=function(e){var t={}
;return e||i.log("Mouse.create: element was undefined, defaulting to document.body","warn"),t.element=e||document.body,t.absolute={x:0,y:0},t.position={x:0,y:0},t.mousedownPosition={x:0,y:0},t.mouseupPosition={x:0,y:0},t.offset={x:0,y:0},t.scale={x:1,y:1},t.wheelDelta=0,t.button=-1,t.pixelRatio=t.element.getAttribute("data-pixel-ratio")||1,t.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},t.mousemove=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&(t.button=0,e.preventDefault()),t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.sourceEvents.mousemove=e},t.mousedown=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches?(t.button=0,e.preventDefault()):t.button=e.button,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,
t.mousedownPosition.x=t.position.x,t.mousedownPosition.y=t.position.y,t.sourceEvents.mousedown=e},t.mouseup=function(e){var n=o._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&e.preventDefault(),t.button=-1,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.mouseupPosition.x=t.position.x,t.mouseupPosition.y=t.position.y,t.sourceEvents.mouseup=e},t.mousewheel=function(e){t.wheelDelta=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),e.preventDefault()},o.setElement(t,t.element),t},o.setElement=function(e,t){e.element=t,t.addEventListener("mousemove",e.mousemove),t.addEventListener("mousedown",e.mousedown),t.addEventListener("mouseup",e.mouseup),t.addEventListener("mousewheel",e.mousewheel),t.addEventListener("DOMMouseScroll",e.mousewheel),t.addEventListener("touchmove",e.mousemove),t.addEventListener("touchstart",e.mousedown),t.addEventListener("touchend",e.mouseup)},
o.clearSourceEvents=function(e){e.sourceEvents.mousemove=null,e.sourceEvents.mousedown=null,e.sourceEvents.mouseup=null,e.sourceEvents.mousewheel=null,e.wheelDelta=0},o.setOffset=function(e,t){e.offset.x=t.x,e.offset.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},o.setScale=function(e,t){e.scale.x=t.x,e.scale.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},o._getRelativeMousePosition=function(e,t,n){var o,i,r=t.getBoundingClientRect(),s=document.documentElement||document.body.parentNode||document.body,a=void 0!==window.pageXOffset?window.pageXOffset:s.scrollLeft,l=void 0!==window.pageYOffset?window.pageYOffset:s.scrollTop,c=e.changedTouches;return c?(o=c[0].pageX-r.left-a,i=c[0].pageY-r.top-l):(o=e.pageX-r.left-a,i=e.pageY-r.top-l),{x:o/(t.clientWidth/(t.width||t.clientWidth)*n),y:i/(t.clientHeight/(t.height||t.clientHeight)*n)}}}()},{"../core/Common":14}],20:[function(e,t,n){
var o={};t.exports=o;var i=e("./Common");!function(){o._registry={},o.register=function(e){if(o.isPlugin(e)||i.warn("Plugin.register:",o.toString(e),"does not implement all required fields."),e.name in o._registry){var t=o._registry[e.name],n=o.versionParse(e.version).number,r=o.versionParse(t.version).number;n>r?(i.warn("Plugin.register:",o.toString(t),"was upgraded to",o.toString(e)),o._registry[e.name]=e):n<r?i.warn("Plugin.register:",o.toString(t),"can not be downgraded to",o.toString(e)):e!==t&&i.warn("Plugin.register:",o.toString(e),"is already registered to different plugin object")}else o._registry[e.name]=e;return e},o.resolve=function(e){return o._registry[o.dependencyParse(e).name]},o.toString=function(e){return"string"==typeof e?e:(e.name||"anonymous")+"@"+(e.version||e.range||"0.0.0")},o.isPlugin=function(e){return e&&e.name&&e.version&&e.install},o.isUsed=function(e,t){return e.used.indexOf(t)>-1},o.isFor=function(e,t){var n=e.for&&o.dependencyParse(e.for)
;return!e.for||t.name===n.name&&o.versionSatisfies(t.version,n.range)},o.use=function(e,t){if(e.uses=(e.uses||[]).concat(t||[]),0===e.uses.length)return void i.warn("Plugin.use:",o.toString(e),"does not specify any dependencies to install.");for(var n=o.dependencies(e),r=i.topologicalSort(n),s=[],a=0;a<r.length;a+=1)if(r[a]!==e.name){var l=o.resolve(r[a]);l?o.isUsed(e,l.name)||(o.isFor(l,e)||(i.warn("Plugin.use:",o.toString(l),"is for",l.for,"but installed on",o.toString(e)+"."),l._warned=!0),l.install?l.install(e):(i.warn("Plugin.use:",o.toString(l),"does not specify an install function."),l._warned=!0),l._warned?(s.push("🔶 "+o.toString(l)),delete l._warned):s.push("✅ "+o.toString(l)),e.used.push(l.name)):s.push("❌ "+r[a])}s.length>0&&i.info(s.join(" "))},o.dependencies=function(e,t){var n=o.dependencyParse(e),r=n.name;if(t=t||{},!(r in t)){e=o.resolve(e)||e,t[r]=i.map(e.uses||[],function(t){o.isPlugin(t)&&o.register(t);var r=o.dependencyParse(t),s=o.resolve(t)
;return s&&!o.versionSatisfies(s.version,r.range)?(i.warn("Plugin.dependencies:",o.toString(s),"does not satisfy",o.toString(r),"used by",o.toString(n)+"."),s._warned=!0,e._warned=!0):s||(i.warn("Plugin.dependencies:",o.toString(t),"used by",o.toString(n),"could not be resolved."),e._warned=!0),r.name});for(var s=0;s<t[r].length;s+=1)o.dependencies(t[r][s],t);return t}},o.dependencyParse=function(e){if(i.isString(e)){return/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?))?$/.test(e)||i.warn("Plugin.dependencyParse:",e,"is not a valid dependency string."),{name:e.split("@")[0],range:e.split("@")[1]||"*"}}return{name:e.name,range:e.range||e.version}},o.versionParse=function(e){/^\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/.test(e)||i.warn("Plugin.versionParse:",e,"is not a valid version or range.");var t=e.split("-");e=t[0];var n=isNaN(Number(e[0])),o=n?e.substr(1):e,r=i.map(o.split("."),function(e){return Number(e)});return{isRange:n,version:o,range:e,operator:n?e[0]:"",parts:r,
prerelease:t[1],number:1e8*r[0]+1e4*r[1]+r[2]}},o.versionSatisfies=function(e,t){t=t||"*";var n=o.versionParse(t),i=n.parts,r=o.versionParse(e),s=r.parts;if(n.isRange){if("*"===n.operator||"*"===e)return!0;if("~"===n.operator)return s[0]===i[0]&&s[1]===i[1]&&s[2]>=i[2];if("^"===n.operator)return i[0]>0?s[0]===i[0]&&r.number>=n.number:i[1]>0?s[1]===i[1]&&s[2]>=i[2]:s[2]===i[2]}return e===t||"*"===e}}()},{"./Common":14}],21:[function(e,t,n){var o={};t.exports=o;var i=e("./Events"),r=e("./Engine"),s=e("./Common");!function(){var e,t;if("undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),!e){var n;e=function(e){n=setTimeout(function(){e(s.now())},1e3/60)},t=function(){clearTimeout(n)}}o.create=function(e){var t={fps:60,correction:1,deltaSampleSize:60,
counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,timeScalePrev:1,frameRequestId:null,isFixed:!1,enabled:!0},n=s.extend(t,e);return n.delta=n.delta||1e3/n.fps,n.deltaMin=n.deltaMin||1e3/n.fps,n.deltaMax=n.deltaMax||1e3/(.5*n.fps),n.fps=1e3/n.delta,n},o.run=function(t,n){return void 0!==t.positionIterations&&(n=t,t=o.create()),function i(r){t.frameRequestId=e(i),r&&t.enabled&&o.tick(t,n,r)}(),t},o.tick=function(e,t,n){var o,s=t.timing,a=1,l={timestamp:s.timestamp};i.trigger(e,"beforeTick",l),i.trigger(t,"beforeTick",l),e.isFixed?o=e.delta:(o=n-e.timePrev||e.delta,e.timePrev=n,e.deltaHistory.push(o),e.deltaHistory=e.deltaHistory.slice(-e.deltaSampleSize),o=Math.min.apply(null,e.deltaHistory),o=o<e.deltaMin?e.deltaMin:o,o=o>e.deltaMax?e.deltaMax:o,a=o/e.delta,e.delta=o),0!==e.timeScalePrev&&(a*=s.timeScale/e.timeScalePrev),0===s.timeScale&&(a=0),e.timeScalePrev=s.timeScale,e.correction=a,e.frameCounter+=1,
n-e.counterTimestamp>=1e3&&(e.fps=e.frameCounter*((n-e.counterTimestamp)/1e3),e.counterTimestamp=n,e.frameCounter=0),i.trigger(e,"tick",l),i.trigger(t,"tick",l),t.world.isModified&&t.render&&t.render.controller&&t.render.controller.clear&&t.render.controller.clear(t.render),i.trigger(e,"beforeUpdate",l),r.update(t,o,a),i.trigger(e,"afterUpdate",l),t.render&&t.render.controller&&(i.trigger(e,"beforeRender",l),i.trigger(t,"beforeRender",l),t.render.controller.world(t.render),i.trigger(e,"afterRender",l),i.trigger(t,"afterRender",l)),i.trigger(e,"afterTick",l),i.trigger(t,"afterTick",l)},o.stop=function(e){t(e.frameRequestId)},o.start=function(e,t){o.run(e,t)}}()},{"./Common":14,"./Engine":15,"./Events":16}],22:[function(e,t,n){var o={};t.exports=o;var i=e("./Events");!function(){o._motionWakeThreshold=.18,o._motionSleepThreshold=.08,o._minBias=.9,o.update=function(e,t){for(var n=t*t*t,i=0;i<e.length;i++){var r=e[i],s=r.speed*r.speed+r.angularSpeed*r.angularSpeed
;if(0===r.force.x&&0===r.force.y){var a=Math.min(r.motion,s),l=Math.max(r.motion,s);r.motion=o._minBias*a+(1-o._minBias)*l,r.sleepThreshold>0&&r.motion<o._motionSleepThreshold*n?(r.sleepCounter+=1,r.sleepCounter>=r.sleepThreshold&&o.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else o.set(r,!1)}},o.afterCollisions=function(e,t){for(var n=t*t*t,i=0;i<e.length;i++){var r=e[i];if(r.isActive){var s=r.collision,a=s.bodyA.parent,l=s.bodyB.parent;if(!(a.isSleeping&&l.isSleeping||a.isStatic||l.isStatic)&&(a.isSleeping||l.isSleeping)){var c=a.isSleeping&&!a.isStatic?a:l,d=c===a?l:a;!c.isStatic&&d.motion>o._motionWakeThreshold*n&&o.set(c,!1)}}}},o.set=function(e,t){var n=e.isSleeping;t?(e.isSleeping=!0,e.sleepCounter=e.sleepThreshold,e.positionImpulse.x=0,e.positionImpulse.y=0,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.anglePrev=e.angle,e.speed=0,e.angularSpeed=0,e.motion=0,n||i.trigger(e,"sleepStart")):(e.isSleeping=!1,e.sleepCounter=0,n&&i.trigger(e,"sleepEnd"))}}()},{
"./Events":16}],23:[function(e,t,n){var o={};t.exports=o;var i,r=e("../geometry/Vertices"),s=e("../core/Common"),a=e("../body/Body"),l=e("../geometry/Bounds"),c=e("../geometry/Vector");!function(){o.rectangle=function(e,t,n,o,i){i=i||{};var l={label:"Rectangle Body",position:{x:e,y:t},vertices:r.fromPath("L 0 0 L "+n+" 0 L "+n+" "+o+" L 0 "+o)};if(i.chamfer){var c=i.chamfer;l.vertices=r.chamfer(l.vertices,c.radius,c.quality,c.qualityMin,c.qualityMax),delete i.chamfer}return a.create(s.extend({},l,i))},o.trapezoid=function(e,t,n,o,i,l){l=l||{},i*=.5;var c,d=(1-2*i)*n,u=n*i,p=u+d,f=p+u;c=i<.5?"L 0 0 L "+u+" "+-o+" L "+p+" "+-o+" L "+f+" 0":"L 0 0 L "+p+" "+-o+" L "+f+" 0";var m={label:"Trapezoid Body",position:{x:e,y:t},vertices:r.fromPath(c)};if(l.chamfer){var v=l.chamfer;m.vertices=r.chamfer(m.vertices,v.radius,v.quality,v.qualityMin,v.qualityMax),delete l.chamfer}return a.create(s.extend({},m,l))},o.circle=function(e,t,n,i,r){i=i||{};var a={label:"Circle Body",circleRadius:n};r=r||25
;var l=Math.ceil(Math.max(10,Math.min(r,n)));return l%2==1&&(l+=1),o.polygon(e,t,l,n,s.extend({},a,i))},o.polygon=function(e,t,n,i,l){if(l=l||{},n<3)return o.circle(e,t,i,l);for(var c=2*Math.PI/n,d="",u=.5*c,p=0;p<n;p+=1){var f=u+p*c,m=Math.cos(f)*i,v=Math.sin(f)*i;d+="L "+m.toFixed(3)+" "+v.toFixed(3)+" "}var y={label:"Polygon Body",position:{x:e,y:t},vertices:r.fromPath(d)};if(l.chamfer){var g=l.chamfer;y.vertices=r.chamfer(y.vertices,g.radius,g.quality,g.qualityMin,g.qualityMax),delete l.chamfer}return a.create(s.extend({},y,l))},o.fromVertices=function(e,t,n,o,d,u,p){i||(i=s._requireGlobal("decomp","poly-decomp"));var f,m,v,y,g,x,h,b,w;for(o=o||{},m=[],d=void 0!==d&&d,u=void 0!==u?u:.01,p=void 0!==p?p:10,i||s.warn("Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull."),s.isArray(n[0])||(n=[n]),b=0;b<n.length;b+=1)if(y=n[b],(v=r.isConvex(y))||!i)y=v?r.clockwiseSort(y):r.hull(y),m.push({position:{x:e,y:t},vertices:y});else{
var S=y.map(function(e){return[e.x,e.y]});i.makeCCW(S),!1!==u&&i.removeCollinearPoints(S,u);var C=i.quickDecomp(S);for(g=0;g<C.length;g++){var A=C[g],P=A.map(function(e){return{x:e[0],y:e[1]}});p>0&&r.area(P)<p||m.push({position:r.centre(P),vertices:P})}}for(g=0;g<m.length;g++)m[g]=a.create(s.extend(m[g],o));if(d){for(g=0;g<m.length;g++){var B=m[g];for(x=g+1;x<m.length;x++){var M=m[x];if(l.overlaps(B.bounds,M.bounds)){var k=B.vertices,I=M.vertices;for(h=0;h<B.vertices.length;h++)for(w=0;w<M.vertices.length;w++){var _=c.magnitudeSquared(c.sub(k[(h+1)%k.length],I[w])),T=c.magnitudeSquared(c.sub(k[h],I[(w+1)%I.length]));_<5&&T<5&&(k[h].isInternal=!0,I[w].isInternal=!0)}}}}}return m.length>1?(f=a.create(s.extend({parts:m.slice(0)},o)),a.setPosition(f,{x:e,y:t}),f):m[0]}}()},{"../body/Body":1,"../core/Common":14,"../geometry/Bounds":26,"../geometry/Vector":28,"../geometry/Vertices":29}],24:[function(e,t,n){var o={};t.exports=o
;var i=e("../body/Composite"),r=e("../constraint/Constraint"),s=e("../core/Common"),a=e("../body/Body"),l=e("./Bodies");!function(){o.stack=function(e,t,n,o,r,s,l){for(var c,d=i.create({label:"Stack"}),u=e,p=t,f=0,m=0;m<o;m++){for(var v=0,y=0;y<n;y++){var g=l(u,p,y,m,c,f);if(g){var x=g.bounds.max.y-g.bounds.min.y,h=g.bounds.max.x-g.bounds.min.x;x>v&&(v=x),a.translate(g,{x:.5*h,y:.5*x}),u=g.bounds.max.x+r,i.addBody(d,g),c=g,f+=1}else u+=r}p+=v+s,u=e}return d},o.chain=function(e,t,n,o,a,l){for(var c=e.bodies,d=1;d<c.length;d++){var u=c[d-1],p=c[d],f=u.bounds.max.y-u.bounds.min.y,m=u.bounds.max.x-u.bounds.min.x,v=p.bounds.max.y-p.bounds.min.y,y=p.bounds.max.x-p.bounds.min.x,g={bodyA:u,pointA:{x:m*t,y:f*n},bodyB:p,pointB:{x:y*o,y:v*a}},x=s.extend(g,l);i.addConstraint(e,r.create(x))}return e.label+=" Chain",e},o.mesh=function(e,t,n,o,a){var l,c,d,u,p,f=e.bodies;for(l=0;l<n;l++){for(c=1;c<t;c++)d=f[c-1+l*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a)))
;if(l>0)for(c=0;c<t;c++)d=f[c+(l-1)*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a))),o&&c>0&&(p=f[c-1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a)))),o&&c<t-1&&(p=f[c+1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a))))}return e.label+=" Mesh",e},o.pyramid=function(e,t,n,i,r,s,l){return o.stack(e,t,n,i,r,s,function(t,o,s,c,d,u){var p=Math.min(i,Math.ceil(n/2)),f=d?d.bounds.max.x-d.bounds.min.x:0;if(!(c>p)){c=p-c;var m=c,v=n-1-c;if(!(s<m||s>v)){1===u&&a.translate(d,{x:(s+(n%2==1?1:-1))*f,y:0});return l(e+(d?s*f:0)+s*r,o,s,c,d,u)}}})},o.newtonsCradle=function(e,t,n,o,s){for(var a=i.create({label:"Newtons Cradle"}),c=0;c<n;c++){var d=l.circle(e+c*(1.9*o),t+s,o,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),u=r.create({pointA:{x:e+c*(1.9*o),y:t},bodyB:d});i.addBody(a,d),i.addConstraint(a,u)}return a},o.car=function(e,t,n,o,s){var c=a.nextGroup(!0),d=.5*-n+20,u=.5*n-20,p=i.create({label:"Car"
}),f=l.rectangle(e,t,n,o,{collisionFilter:{group:c},chamfer:{radius:.5*o},density:2e-4}),m=l.circle(e+d,t+0,s,{collisionFilter:{group:c},friction:.8}),v=l.circle(e+u,t+0,s,{collisionFilter:{group:c},friction:.8}),y=r.create({bodyB:f,pointB:{x:d,y:0},bodyA:m,stiffness:1,length:0}),g=r.create({bodyB:f,pointB:{x:u,y:0},bodyA:v,stiffness:1,length:0});return i.addBody(p,f),i.addBody(p,m),i.addBody(p,v),i.addConstraint(p,y),i.addConstraint(p,g),p},o.softBody=function(e,t,n,i,r,a,c,d,u,p){u=s.extend({inertia:1/0},u),p=s.extend({stiffness:.2,render:{type:"line",anchors:!1}},p);var f=o.stack(e,t,n,i,r,a,function(e,t){return l.circle(e,t,d,u)});return o.mesh(f,n,i,c,p),f.label="Soft Body",f}}()},{"../body/Body":1,"../body/Composite":2,"../constraint/Constraint":12,"../core/Common":14,"./Bodies":23}],25:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){o.fromVertices=function(e){for(var t={},n=0;n<e.length;n++){
var o=(n+1)%e.length,s=i.normalise({x:e[o].y-e[n].y,y:e[n].x-e[o].x}),a=0===s.y?1/0:s.x/s.y;a=a.toFixed(3).toString(),t[a]=s}return r.values(t)},o.rotate=function(e,t){if(0!==t)for(var n=Math.cos(t),o=Math.sin(t),i=0;i<e.length;i++){var r,s=e[i];r=s.x*n-s.y*o,s.y=s.x*o+s.y*n,s.x=r}}}()},{"../core/Common":14,"../geometry/Vector":28}],26:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e){var t={min:{x:0,y:0},max:{x:0,y:0}};return e&&o.update(t,e),t},o.update=function(e,t,n){e.min.x=1/0,e.max.x=-1/0,e.min.y=1/0,e.max.y=-1/0;for(var o=0;o<t.length;o++){var i=t[o];i.x>e.max.x&&(e.max.x=i.x),i.x<e.min.x&&(e.min.x=i.x),i.y>e.max.y&&(e.max.y=i.y),i.y<e.min.y&&(e.min.y=i.y)}n&&(n.x>0?e.max.x+=n.x:e.min.x+=n.x,n.y>0?e.max.y+=n.y:e.min.y+=n.y)},o.contains=function(e,t){return t.x>=e.min.x&&t.x<=e.max.x&&t.y>=e.min.y&&t.y<=e.max.y},o.overlaps=function(e,t){return e.min.x<=t.max.x&&e.max.x>=t.min.x&&e.max.y>=t.min.y&&e.min.y<=t.max.y},o.translate=function(e,t){e.min.x+=t.x,
e.max.x+=t.x,e.min.y+=t.y,e.max.y+=t.y},o.shift=function(e,t){var n=e.max.x-e.min.x,o=e.max.y-e.min.y;e.min.x=t.x,e.max.x=t.x+n,e.min.y=t.y,e.max.y=t.y+o}}()},{}],27:[function(e,t,n){var o={};t.exports=o;var i=(e("../geometry/Bounds"),e("../core/Common"));!function(){o.pathToVertices=function(e,t){"undefined"==typeof window||"SVGPathSeg"in window||i.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var n,r,s,a,l,c,d,u,p,f,m,v,y=[],g=0,x=0,h=0;t=t||15;var b=function(e,t,n){var o=n%2==1&&n>1;if(!p||e!=p.x||t!=p.y){p&&o?(m=p.x,v=p.y):(m=0,v=0);var i={x:m+e,y:v+t};!o&&p||(p=i),y.push(i),x=m+e,h=v+t}},w=function(e){var t=e.pathSegTypeAsLetter.toUpperCase();if("Z"!==t){switch(t){case"M":case"L":case"T":case"C":case"S":case"Q":x=e.x,h=e.y;break;case"H":x=e.x;break;case"V":h=e.y}b(x,h,e.pathSegType)}};for(o._svgPathToAbsolute(e),s=e.getTotalLength(),c=[],n=0;n<e.pathSegList.numberOfItems;n+=1)c.push(e.pathSegList.getItem(n));for(d=c.concat();g<s;){
if(f=e.getPathSegAtLength(g),(l=c[f])!=u){for(;d.length&&d[0]!=l;)w(d.shift());u=l}switch(l.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":a=e.getPointAtLength(g),b(a.x,a.y,0)}g+=t}for(n=0,r=d.length;n<r;++n)w(d[n]);return y},o._svgPathToAbsolute=function(e){for(var t,n,o,i,r,s,a=e.pathSegList,l=0,c=0,d=a.numberOfItems,u=0;u<d;++u){var p=a.getItem(u),f=p.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(f))"x"in p&&(l=p.x),"y"in p&&(c=p.y);else switch("x1"in p&&(o=l+p.x1),"x2"in p&&(r=l+p.x2),"y1"in p&&(i=c+p.y1),"y2"in p&&(s=c+p.y2),"x"in p&&(l+=p.x),"y"in p&&(c+=p.y),f){case"m":a.replaceItem(e.createSVGPathSegMovetoAbs(l,c),u);break;case"l":a.replaceItem(e.createSVGPathSegLinetoAbs(l,c),u);break;case"h":a.replaceItem(e.createSVGPathSegLinetoHorizontalAbs(l),u);break;case"v":a.replaceItem(e.createSVGPathSegLinetoVerticalAbs(c),u);break;case"c":a.replaceItem(e.createSVGPathSegCurvetoCubicAbs(l,c,o,i,r,s),u);break;case"s":
a.replaceItem(e.createSVGPathSegCurvetoCubicSmoothAbs(l,c,r,s),u);break;case"q":a.replaceItem(e.createSVGPathSegCurvetoQuadraticAbs(l,c,o,i),u);break;case"t":a.replaceItem(e.createSVGPathSegCurvetoQuadraticSmoothAbs(l,c),u);break;case"a":a.replaceItem(e.createSVGPathSegArcAbs(l,c,p.r1,p.r2,p.angle,p.largeArcFlag,p.sweepFlag),u);break;case"z":case"Z":l=t,c=n}"M"!=f&&"m"!=f||(t=l,n=c)}}}()},{"../core/Common":14,"../geometry/Bounds":26}],28:[function(e,t,n){var o={};t.exports=o,function(){o.create=function(e,t){return{x:e||0,y:t||0}},o.clone=function(e){return{x:e.x,y:e.y}},o.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},o.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},o.rotate=function(e,t,n){var o=Math.cos(t),i=Math.sin(t);n||(n={});var r=e.x*o-e.y*i;return n.y=e.x*i+e.y*o,n.x=r,n},o.rotateAbout=function(e,t,n,o){var i=Math.cos(t),r=Math.sin(t);o||(o={});var s=n.x+((e.x-n.x)*i-(e.y-n.y)*r);return o.y=n.y+((e.x-n.x)*r+(e.y-n.y)*i),o.x=s,o},o.normalise=function(e){
var t=o.magnitude(e);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}},o.dot=function(e,t){return e.x*t.x+e.y*t.y},o.cross=function(e,t){return e.x*t.y-e.y*t.x},o.cross3=function(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)},o.add=function(e,t,n){return n||(n={}),n.x=e.x+t.x,n.y=e.y+t.y,n},o.sub=function(e,t,n){return n||(n={}),n.x=e.x-t.x,n.y=e.y-t.y,n},o.mult=function(e,t){return{x:e.x*t,y:e.y*t}},o.div=function(e,t){return{x:e.x/t,y:e.y/t}},o.perp=function(e,t){return t=!0===t?-1:1,{x:t*-e.y,y:t*e.x}},o.neg=function(e){return{x:-e.x,y:-e.y}},o.angle=function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)},o._temp=[o.create(),o.create(),o.create(),o.create(),o.create(),o.create()]}()},{}],29:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){o.create=function(e,t){for(var n=[],o=0;o<e.length;o++){var i=e[o],r={x:i.x,y:i.y,index:o,body:t,isInternal:!1};n.push(r)}return n},o.fromPath=function(e,t){
var n=/L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/gi,i=[];return e.replace(n,function(e,t,n){i.push({x:parseFloat(t),y:parseFloat(n)})}),o.create(i,t)},o.centre=function(e){for(var t,n,r,s=o.area(e,!0),a={x:0,y:0},l=0;l<e.length;l++)r=(l+1)%e.length,t=i.cross(e[l],e[r]),n=i.mult(i.add(e[l],e[r]),t),a=i.add(a,n);return i.div(a,6*s)},o.mean=function(e){for(var t={x:0,y:0},n=0;n<e.length;n++)t.x+=e[n].x,t.y+=e[n].y;return i.div(t,e.length)},o.area=function(e,t){for(var n=0,o=e.length-1,i=0;i<e.length;i++)n+=(e[o].x-e[i].x)*(e[o].y+e[i].y),o=i;return t?n/2:Math.abs(n)/2},o.inertia=function(e,t){for(var n,o,r=0,s=0,a=e,l=0;l<a.length;l++)o=(l+1)%a.length,n=Math.abs(i.cross(a[o],a[l])),r+=n*(i.dot(a[o],a[o])+i.dot(a[o],a[l])+i.dot(a[l],a[l])),s+=n;return t/6*(r/s)},o.translate=function(e,t,n){var o;if(n)for(o=0;o<e.length;o++)e[o].x+=t.x*n,e[o].y+=t.y*n;else for(o=0;o<e.length;o++)e[o].x+=t.x,e[o].y+=t.y;return e},o.rotate=function(e,t,n){if(0!==t){
for(var o=Math.cos(t),i=Math.sin(t),r=0;r<e.length;r++){var s=e[r],a=s.x-n.x,l=s.y-n.y;s.x=n.x+(a*o-l*i),s.y=n.y+(a*i+l*o)}return e}},o.contains=function(e,t){for(var n=0;n<e.length;n++){var o=e[n],i=e[(n+1)%e.length];if((t.x-o.x)*(i.y-o.y)+(t.y-o.y)*(o.x-i.x)>0)return!1}return!0},o.scale=function(e,t,n,r){if(1===t&&1===n)return e;r=r||o.centre(e);for(var s,a,l=0;l<e.length;l++)s=e[l],a=i.sub(s,r),e[l].x=r.x+a.x*t,e[l].y=r.y+a.y*n;return e},o.chamfer=function(e,t,n,o,s){t="number"==typeof t?[t]:t||[8],n=void 0!==n?n:-1,o=o||2,s=s||14;for(var a=[],l=0;l<e.length;l++){var c=e[l-1>=0?l-1:e.length-1],d=e[l],u=e[(l+1)%e.length],p=t[l<t.length?l:t.length-1];if(0!==p){var f=i.normalise({x:d.y-c.y,y:c.x-d.x}),m=i.normalise({x:u.y-d.y,y:d.x-u.x}),v=Math.sqrt(2*Math.pow(p,2)),y=i.mult(r.clone(f),p),g=i.normalise(i.mult(i.add(f,m),.5)),x=i.sub(d,i.mult(g,v)),h=n;-1===n&&(h=1.75*Math.pow(p,.32)),h=r.clamp(h,o,s),h%2==1&&(h+=1)
;for(var b=Math.acos(i.dot(f,m)),w=b/h,S=0;S<h;S++)a.push(i.add(i.rotate(y,w*S),x))}else a.push(d)}return a},o.clockwiseSort=function(e){var t=o.mean(e);return e.sort(function(e,n){return i.angle(t,e)-i.angle(t,n)}),e},o.isConvex=function(e){var t,n,o,i,r=0,s=e.length;if(s<3)return null;for(t=0;t<s;t++)if(n=(t+1)%s,o=(t+2)%s,i=(e[n].x-e[t].x)*(e[o].y-e[n].y),i-=(e[n].y-e[t].y)*(e[o].x-e[n].x),i<0?r|=1:i>0&&(r|=2),3===r)return!1;return 0!==r||null},o.hull=function(e){var t,n,o=[],r=[];for(e=e.slice(0),e.sort(function(e,t){var n=e.x-t.x;return 0!==n?n:e.y-t.y}),n=0;n<e.length;n+=1){for(t=e[n];r.length>=2&&i.cross3(r[r.length-2],r[r.length-1],t)<=0;)r.pop();r.push(t)}for(n=e.length-1;n>=0;n-=1){for(t=e[n];o.length>=2&&i.cross3(o[o.length-2],o[o.length-1],t)<=0;)o.pop();o.push(t)}return o.pop(),r.pop(),o.concat(r)}}()},{"../core/Common":14,"../geometry/Vector":28}],30:[function(e,t,n){var o=t.exports=e("../core/Matter");o.Body=e("../body/Body"),o.Composite=e("../body/Composite"),
o.World=e("../body/World"),o.Contact=e("../collision/Contact"),o.Detector=e("../collision/Detector"),o.Grid=e("../collision/Grid"),o.Pairs=e("../collision/Pairs"),o.Pair=e("../collision/Pair"),o.Query=e("../collision/Query"),o.Resolver=e("../collision/Resolver"),o.SAT=e("../collision/SAT"),o.Constraint=e("../constraint/Constraint"),o.MouseConstraint=e("../constraint/MouseConstraint"),o.Common=e("../core/Common"),o.Engine=e("../core/Engine"),o.Events=e("../core/Events"),o.Mouse=e("../core/Mouse"),o.Runner=e("../core/Runner"),o.Sleeping=e("../core/Sleeping"),o.Plugin=e("../core/Plugin"),o.Bodies=e("../factory/Bodies"),o.Composites=e("../factory/Composites"),o.Axes=e("../geometry/Axes"),o.Bounds=e("../geometry/Bounds"),o.Svg=e("../geometry/Svg"),o.Vector=e("../geometry/Vector"),o.Vertices=e("../geometry/Vertices"),o.Render=e("../render/Render"),o.RenderPixi=e("../render/RenderPixi"),o.World.add=o.Composite.add,o.World.remove=o.Composite.remove,
o.World.addComposite=o.Composite.addComposite,o.World.addBody=o.Composite.addBody,o.World.addConstraint=o.Composite.addConstraint,o.World.clear=o.Composite.clear,o.Engine.run=o.Runner.run},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Contact":4,"../collision/Detector":5,"../collision/Grid":6,"../collision/Pair":7,"../collision/Pairs":8,"../collision/Query":9,"../collision/Resolver":10,"../collision/SAT":11,"../constraint/Constraint":12,"../constraint/MouseConstraint":13,"../core/Common":14,"../core/Engine":15,"../core/Events":16,"../core/Matter":17,"../core/Metrics":18,"../core/Mouse":19,"../core/Plugin":20,"../core/Runner":21,"../core/Sleeping":22,"../factory/Bodies":23,"../factory/Composites":24,"../geometry/Axes":25,"../geometry/Bounds":26,"../geometry/Svg":27,"../geometry/Vector":28,"../geometry/Vertices":29,"../render/Render":31,"../render/RenderPixi":32}],31:[function(e,t,n){var o={};t.exports=o
;var i=e("../core/Common"),r=e("../body/Composite"),s=e("../geometry/Bounds"),a=e("../core/Events"),l=e("../collision/Grid"),c=e("../geometry/Vector"),d=e("../core/Mouse");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(i.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),o.create=function(e){var t={controller:o,engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,options:{width:800,height:600,pixelRatio:1,background:"#18181d",wireframeBackground:"#0f0f13",hasBounds:!!e.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1,
showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},r=i.extend(t,e);return r.canvas&&(r.canvas.width=r.options.width||r.canvas.width,r.canvas.height=r.options.height||r.canvas.height),r.mouse=e.mouse,r.engine=e.engine,r.canvas=r.canvas||n(r.options.width,r.options.height),r.context=r.canvas.getContext("2d"),r.textures={},r.bounds=r.bounds||{min:{x:0,y:0},max:{x:r.canvas.width,y:r.canvas.height}},1!==r.options.pixelRatio&&o.setPixelRatio(r,r.options.pixelRatio),i.isElement(r.element)?r.element.appendChild(r.canvas):r.canvas.parentNode||i.log("Render.create: options.element was undefined, render.canvas was created but not appended","warn"),r},o.run=function(t){!function n(i){t.frameRequestId=e(n),o.world(t)}()},o.stop=function(e){t(e.frameRequestId)},o.setPixelRatio=function(e,t){var n=e.options,o=e.canvas;"auto"===t&&(t=u(o)),n.pixelRatio=t,o.setAttribute("data-pixel-ratio",t),o.width=n.width*t,o.height=n.height*t,o.style.width=n.width+"px",
o.style.height=n.height+"px",e.context.scale(t,t)},o.lookAt=function(e,t,n,o){o=void 0===o||o,t=i.isArray(t)?t:[t],n=n||{x:0,y:0};for(var r={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},s=0;s<t.length;s+=1){var a=t[s],l=a.bounds?a.bounds.min:a.min||a.position||a,c=a.bounds?a.bounds.max:a.max||a.position||a;l&&c&&(l.x<r.min.x&&(r.min.x=l.x),c.x>r.max.x&&(r.max.x=c.x),l.y<r.min.y&&(r.min.y=l.y),c.y>r.max.y&&(r.max.y=c.y))}var u=r.max.x-r.min.x+2*n.x,p=r.max.y-r.min.y+2*n.y,f=e.canvas.height,m=e.canvas.width,v=m/f,y=u/p,g=1,x=1;y>v?x=y/v:g=v/y,e.options.hasBounds=!0,e.bounds.min.x=r.min.x,e.bounds.max.x=r.min.x+u*g,e.bounds.min.y=r.min.y,e.bounds.max.y=r.min.y+p*x,o&&(e.bounds.min.x+=.5*u-u*g*.5,e.bounds.max.x+=.5*u-u*g*.5,e.bounds.min.y+=.5*p-p*x*.5,e.bounds.max.y+=.5*p-p*x*.5),e.bounds.min.x-=n.x,e.bounds.max.x-=n.x,e.bounds.min.y-=n.y,e.bounds.max.y-=n.y,e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),
d.setOffset(e.mouse,e.bounds.min))},o.startViewTransform=function(e){var t=e.bounds.max.x-e.bounds.min.x,n=e.bounds.max.y-e.bounds.min.y,o=t/e.options.width,i=n/e.options.height;e.context.scale(1/o,1/i),e.context.translate(-e.bounds.min.x,-e.bounds.min.y)},o.endViewTransform=function(e){e.context.setTransform(e.options.pixelRatio,0,0,e.options.pixelRatio,0,0)},o.world=function(e){var t,n=e.engine,i=n.world,u=e.canvas,p=e.context,m=e.options,v=r.allBodies(i),y=r.allConstraints(i),g=m.wireframes?m.wireframeBackground:m.background,x=[],h=[],b={timestamp:n.timing.timestamp};if(a.trigger(e,"beforeRender",b),e.currentBackground!==g&&f(e,g),p.globalCompositeOperation="source-in",p.fillStyle="transparent",p.fillRect(0,0,u.width,u.height),p.globalCompositeOperation="source-over",m.hasBounds){for(t=0;t<v.length;t++){var w=v[t];s.overlaps(w.bounds,e.bounds)&&x.push(w)}for(t=0;t<y.length;t++){var S=y[t],C=S.bodyA,A=S.bodyB,P=S.pointA,B=S.pointB;C&&(P=c.add(C.position,S.pointA)),
A&&(B=c.add(A.position,S.pointB)),P&&B&&((s.contains(e.bounds,P)||s.contains(e.bounds,B))&&h.push(S))}o.startViewTransform(e),e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),d.setOffset(e.mouse,e.bounds.min))}else h=y,x=v;!m.wireframes||n.enableSleeping&&m.showSleeping?o.bodies(e,x,p):(m.showConvexHulls&&o.bodyConvexHulls(e,x,p),o.bodyWireframes(e,x,p)),m.showBounds&&o.bodyBounds(e,x,p),(m.showAxes||m.showAngleIndicator)&&o.bodyAxes(e,x,p),m.showPositions&&o.bodyPositions(e,x,p),m.showVelocity&&o.bodyVelocity(e,x,p),m.showIds&&o.bodyIds(e,x,p),m.showSeparations&&o.separations(e,n.pairs.list,p),m.showCollisions&&o.collisions(e,n.pairs.list,p),m.showVertexNumbers&&o.vertexNumbers(e,x,p),m.showMousePosition&&o.mousePosition(e,e.mouse,p),o.constraints(h,p),m.showBroadphase&&n.broadphase.controller===l&&o.grid(e,n.broadphase,p),m.showDebug&&o.debug(e,p),m.hasBounds&&o.endViewTransform(e),
a.trigger(e,"afterRender",b)},o.debug=function(e,t){var n=t,o=e.engine,i=o.world,s=o.metrics,a=e.options;r.allBodies(i);if(o.timing.timestamp-(e.debugTimestamp||0)>=500){var l="";s.timing&&(l+="fps: "+Math.round(s.timing.fps)+" "),e.debugString=l,e.debugTimestamp=o.timing.timestamp}if(e.debugString){n.font="12px Arial",a.wireframes?n.fillStyle="rgba(255,255,255,0.5)":n.fillStyle="rgba(0,0,0,0.5)";for(var c=e.debugString.split("\n"),d=0;d<c.length;d++)n.fillText(c[d],50,50+18*d)}},o.constraints=function(e,t){for(var n=t,o=0;o<e.length;o++){var r=e[o];if(r.render.visible&&r.pointA&&r.pointB){var s,a,l=r.bodyA,d=r.bodyB;if(s=l?c.add(l.position,r.pointA):r.pointA,"pin"===r.render.type)n.beginPath(),n.arc(s.x,s.y,3,0,2*Math.PI),n.closePath();else{if(a=d?c.add(d.position,r.pointB):r.pointB,n.beginPath(),n.moveTo(s.x,s.y),"spring"===r.render.type)for(var u,p=c.sub(a,s),f=c.perp(c.normalise(p)),m=Math.ceil(i.clamp(r.length/5,12,20)),v=1;v<m;v+=1)u=v%2==0?1:-1,
n.lineTo(s.x+p.x*(v/m)+f.x*u*4,s.y+p.y*(v/m)+f.y*u*4);n.lineTo(a.x,a.y)}r.render.lineWidth&&(n.lineWidth=r.render.lineWidth,n.strokeStyle=r.render.strokeStyle,n.stroke()),r.render.anchors&&(n.fillStyle=r.render.strokeStyle,n.beginPath(),n.arc(s.x,s.y,3,0,2*Math.PI),n.arc(a.x,a.y,3,0,2*Math.PI),n.closePath(),n.fill())}}},o.bodyShadows=function(e,t,n){for(var o=n,i=(e.engine,0);i<t.length;i++){var r=t[i];if(r.render.visible){if(r.circleRadius)o.beginPath(),o.arc(r.position.x,r.position.y,r.circleRadius,0,2*Math.PI),o.closePath();else{o.beginPath(),o.moveTo(r.vertices[0].x,r.vertices[0].y);for(var s=1;s<r.vertices.length;s++)o.lineTo(r.vertices[s].x,r.vertices[s].y);o.closePath()}var a=r.position.x-.5*e.options.width,l=r.position.y-.2*e.options.height,c=Math.abs(a)+Math.abs(l);o.shadowColor="rgba(0,0,0,0.15)",o.shadowOffsetX=.05*a,o.shadowOffsetY=.05*l,o.shadowBlur=1+12*Math.min(1,c/1e3),o.fill(),o.shadowColor=null,o.shadowOffsetX=null,o.shadowOffsetY=null,o.shadowBlur=null}}},
o.bodies=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options),c=l.showInternalEdges||!l.wireframes;for(r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(s=o.parts.length>1?1:0;s<o.parts.length;s++)if(i=o.parts[s],i.render.visible){if(l.showSleeping&&o.isSleeping?a.globalAlpha=.5*i.render.opacity:1!==i.render.opacity&&(a.globalAlpha=i.render.opacity),i.render.sprite&&i.render.sprite.texture&&!l.wireframes){var d=i.render.sprite,u=p(e,d.texture);a.translate(i.position.x,i.position.y),a.rotate(i.angle),a.drawImage(u,u.width*-d.xOffset*d.xScale,u.height*-d.yOffset*d.yScale,u.width*d.xScale,u.height*d.yScale),a.rotate(-i.angle),a.translate(-i.position.x,-i.position.y)}else{if(i.circleRadius)a.beginPath(),a.arc(i.position.x,i.position.y,i.circleRadius,0,2*Math.PI);else{a.beginPath(),a.moveTo(i.vertices[0].x,i.vertices[0].y);for(var f=1;f<i.vertices.length;f++)!i.vertices[f-1].isInternal||c?a.lineTo(i.vertices[f].x,i.vertices[f].y):a.moveTo(i.vertices[f].x,i.vertices[f].y),
i.vertices[f].isInternal&&!c&&a.moveTo(i.vertices[(f+1)%i.vertices.length].x,i.vertices[(f+1)%i.vertices.length].y);a.lineTo(i.vertices[0].x,i.vertices[0].y),a.closePath()}l.wireframes?(a.lineWidth=1,a.strokeStyle="#bbb",a.stroke()):(a.fillStyle=i.render.fillStyle,i.render.lineWidth&&(a.lineWidth=i.render.lineWidth,a.strokeStyle=i.render.strokeStyle,a.stroke()),a.fill())}a.globalAlpha=1}},o.bodyWireframes=function(e,t,n){var o,i,r,s,a,l=n,c=e.options.showInternalEdges;for(l.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(a=o.parts.length>1?1:0;a<o.parts.length;a++){for(i=o.parts[a],l.moveTo(i.vertices[0].x,i.vertices[0].y),s=1;s<i.vertices.length;s++)!i.vertices[s-1].isInternal||c?l.lineTo(i.vertices[s].x,i.vertices[s].y):l.moveTo(i.vertices[s].x,i.vertices[s].y),i.vertices[s].isInternal&&!c&&l.moveTo(i.vertices[(s+1)%i.vertices.length].x,i.vertices[(s+1)%i.vertices.length].y);l.lineTo(i.vertices[0].x,i.vertices[0].y)}l.lineWidth=1,l.strokeStyle="#bbb",l.stroke()},
o.bodyConvexHulls=function(e,t,n){var o,i,r,s=n;for(s.beginPath(),i=0;i<t.length;i++)if(o=t[i],o.render.visible&&1!==o.parts.length){for(s.moveTo(o.vertices[0].x,o.vertices[0].y),r=1;r<o.vertices.length;r++)s.lineTo(o.vertices[r].x,o.vertices[r].y);s.lineTo(o.vertices[0].x,o.vertices[0].y)}s.lineWidth=1,s.strokeStyle="rgba(255,255,255,0.2)",s.stroke()},o.vertexNumbers=function(e,t,n){var o,i,r,s=n;for(o=0;o<t.length;o++){var a=t[o].parts;for(r=a.length>1?1:0;r<a.length;r++){var l=a[r];for(i=0;i<l.vertices.length;i++)s.fillStyle="rgba(255,255,255,0.2)",s.fillText(o+"_"+i,l.position.x+.8*(l.vertices[i].x-l.position.x),l.position.y+.8*(l.vertices[i].y-l.position.y))}}},o.mousePosition=function(e,t,n){var o=n;o.fillStyle="rgba(255,255,255,0.8)",o.fillText(t.position.x+" "+t.position.y,t.position.x+5,t.position.y-5)},o.bodyBounds=function(e,t,n){var o=n,i=(e.engine,e.options);o.beginPath();for(var r=0;r<t.length;r++){
if(t[r].render.visible)for(var s=t[r].parts,a=s.length>1?1:0;a<s.length;a++){var l=s[a];o.rect(l.bounds.min.x,l.bounds.min.y,l.bounds.max.x-l.bounds.min.x,l.bounds.max.y-l.bounds.min.y)}}i.wireframes?o.strokeStyle="rgba(255,255,255,0.08)":o.strokeStyle="rgba(0,0,0,0.1)",o.lineWidth=1,o.stroke()},o.bodyAxes=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options);for(a.beginPath(),i=0;i<t.length;i++){var c=t[i],d=c.parts;if(c.render.visible)if(l.showAxes)for(r=d.length>1?1:0;r<d.length;r++)for(o=d[r],s=0;s<o.axes.length;s++){var u=o.axes[s];a.moveTo(o.position.x,o.position.y),a.lineTo(o.position.x+20*u.x,o.position.y+20*u.y)}else for(r=d.length>1?1:0;r<d.length;r++)for(o=d[r],s=0;s<o.axes.length;s++)a.moveTo(o.position.x,o.position.y),a.lineTo((o.vertices[0].x+o.vertices[o.vertices.length-1].x)/2,(o.vertices[0].y+o.vertices[o.vertices.length-1].y)/2)}l.wireframes?(a.strokeStyle="indianred",a.lineWidth=1):(a.strokeStyle="rgba(255, 255, 255, 0.4)",a.globalCompositeOperation="overlay",
a.lineWidth=2),a.stroke(),a.globalCompositeOperation="source-over"},o.bodyPositions=function(e,t,n){var o,i,r,s,a=n,l=(e.engine,e.options);for(a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.render.visible)for(s=0;s<o.parts.length;s++)i=o.parts[s],a.arc(i.position.x,i.position.y,3,0,2*Math.PI,!1),a.closePath();for(l.wireframes?a.fillStyle="indianred":a.fillStyle="rgba(0,0,0,0.5)",a.fill(),a.beginPath(),r=0;r<t.length;r++)o=t[r],o.render.visible&&(a.arc(o.positionPrev.x,o.positionPrev.y,2,0,2*Math.PI,!1),a.closePath());a.fillStyle="rgba(255,165,0,0.8)",a.fill()},o.bodyVelocity=function(e,t,n){var o=n;o.beginPath();for(var i=0;i<t.length;i++){var r=t[i];r.render.visible&&(o.moveTo(r.position.x,r.position.y),o.lineTo(r.position.x+2*(r.position.x-r.positionPrev.x),r.position.y+2*(r.position.y-r.positionPrev.y)))}o.lineWidth=3,o.strokeStyle="cornflowerblue",o.stroke()},o.bodyIds=function(e,t,n){var o,i,r=n;for(o=0;o<t.length;o++)if(t[o].render.visible){var s=t[o].parts
;for(i=s.length>1?1:0;i<s.length;i++){var a=s[i];r.font="12px Arial",r.fillStyle="rgba(255,255,255,0.5)",r.fillText(a.id,a.position.x+10,a.position.y-10)}}},o.collisions=function(e,t,n){var o,i,r,s,a=n,l=e.options;for(a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.isActive)for(i=o.collision,s=0;s<o.activeContacts.length;s++){var c=o.activeContacts[s],d=c.vertex;a.rect(d.x-1.5,d.y-1.5,3.5,3.5)}for(l.wireframes?a.fillStyle="rgba(255,255,255,0.7)":a.fillStyle="orange",a.fill(),a.beginPath(),r=0;r<t.length;r++)if(o=t[r],o.isActive&&(i=o.collision,o.activeContacts.length>0)){var u=o.activeContacts[0].vertex.x,p=o.activeContacts[0].vertex.y;2===o.activeContacts.length&&(u=(o.activeContacts[0].vertex.x+o.activeContacts[1].vertex.x)/2,p=(o.activeContacts[0].vertex.y+o.activeContacts[1].vertex.y)/2),i.bodyB===i.supports[0].body||!0===i.bodyA.isStatic?a.moveTo(u-8*i.normal.x,p-8*i.normal.y):a.moveTo(u+8*i.normal.x,p+8*i.normal.y),a.lineTo(u,p)}
l.wireframes?a.strokeStyle="rgba(255,165,0,0.7)":a.strokeStyle="orange",a.lineWidth=1,a.stroke()},o.separations=function(e,t,n){var o,i,r,s,a,l=n,c=e.options;for(l.beginPath(),a=0;a<t.length;a++)if(o=t[a],o.isActive){i=o.collision,r=i.bodyA,s=i.bodyB;var d=1;s.isStatic||r.isStatic||(d=.5),s.isStatic&&(d=0),l.moveTo(s.position.x,s.position.y),l.lineTo(s.position.x-i.penetration.x*d,s.position.y-i.penetration.y*d),d=1,s.isStatic||r.isStatic||(d=.5),r.isStatic&&(d=0),l.moveTo(r.position.x,r.position.y),l.lineTo(r.position.x+i.penetration.x*d,r.position.y+i.penetration.y*d)}c.wireframes?l.strokeStyle="rgba(255,165,0,0.5)":l.strokeStyle="orange",l.stroke()},o.grid=function(e,t,n){var o=n;e.options.wireframes?o.strokeStyle="rgba(255,180,0,0.1)":o.strokeStyle="rgba(255,180,0,0.5)",o.beginPath();for(var r=i.keys(t.buckets),s=0;s<r.length;s++){var a=r[s];if(!(t.buckets[a].length<2)){var l=a.split(/C|R/)
;o.rect(.5+parseInt(l[1],10)*t.bucketWidth,.5+parseInt(l[2],10)*t.bucketHeight,t.bucketWidth,t.bucketHeight)}}o.lineWidth=1,o.stroke()},o.inspector=function(e,t){var n,o=(e.engine,e.selected),i=e.render,r=i.options;if(r.hasBounds){var s=i.bounds.max.x-i.bounds.min.x,a=i.bounds.max.y-i.bounds.min.y,l=s/i.options.width,c=a/i.options.height;t.scale(1/l,1/c),t.translate(-i.bounds.min.x,-i.bounds.min.y)}for(var d=0;d<o.length;d++){var u=o[d].data;switch(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.9)",t.setLineDash([1,2]),u.type){case"body":n=u.bounds,t.beginPath(),t.rect(Math.floor(n.min.x-3),Math.floor(n.min.y-3),Math.floor(n.max.x-n.min.x+6),Math.floor(n.max.y-n.min.y+6)),t.closePath(),t.stroke();break;case"constraint":var p=u.pointA;u.bodyA&&(p=u.pointB),t.beginPath(),t.arc(p.x,p.y,10,0,2*Math.PI),t.closePath(),t.stroke()}t.setLineDash([]),t.translate(-.5,-.5)}null!==e.selectStart&&(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.6)",
t.fillStyle="rgba(255,165,0,0.1)",n=e.selectBounds,t.beginPath(),t.rect(Math.floor(n.min.x),Math.floor(n.min.y),Math.floor(n.max.x-n.min.x),Math.floor(n.max.y-n.min.y)),t.closePath(),t.stroke(),t.fill(),t.translate(-.5,-.5)),r.hasBounds&&t.setTransform(1,0,0,1,0,0)};var n=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n.oncontextmenu=function(){return!1},n.onselectstart=function(){return!1},n},u=function(e){var t=e.getContext("2d");return(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)},p=function(e,t){var n=e.textures[t];return n||(n=e.textures[t]=new Image,n.src=t,n)},f=function(e,t){var n=t;/(jpg|gif|png)$/.test(t)&&(n="url("+t+")"),e.canvas.style.background=n,e.canvas.style.backgroundSize="contain",e.currentBackground=t}}()},{"../body/Composite":2,"../collision/Grid":6,"../core/Common":14,"../core/Events":16,
"../core/Mouse":19,"../geometry/Bounds":26,"../geometry/Vector":28}],32:[function(e,t,n){var o={};t.exports=o;var i=e("../geometry/Bounds"),r=e("../body/Composite"),s=e("../core/Common"),a=e("../core/Events"),l=e("../geometry/Vector");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(s.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),o.create=function(e){s.warn("RenderPixi.create: Matter.RenderPixi is deprecated (see docs)");var t={controller:o,engine:null,element:null,frameRequestId:null,canvas:null,renderer:null,container:null,spriteContainer:null,pixiOptions:null,options:{width:800,height:600,background:"#fafafa",wireframeBackground:"#222",hasBounds:!1,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,
showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1}},n=s.extend(t,e),i=!n.options.wireframes&&"transparent"===n.options.background;return n.pixiOptions=n.pixiOptions||{view:n.canvas,transparent:i,antialias:!0,backgroundColor:e.background},n.mouse=e.mouse,n.engine=e.engine,n.renderer=n.renderer||new PIXI.WebGLRenderer(n.options.width,n.options.height,n.pixiOptions),n.container=n.container||new PIXI.Container,n.spriteContainer=n.spriteContainer||new PIXI.Container,n.canvas=n.canvas||n.renderer.view,n.bounds=n.bounds||{min:{x:0,y:0},max:{x:n.options.width,y:n.options.height}},a.on(n.engine,"beforeUpdate",function(){o.clear(n)}),n.textures={},n.sprites={},n.primitives={},n.container.addChild(n.spriteContainer),s.isElement(n.element)?n.element.appendChild(n.canvas):s.warn('No "render.element" passed, "render.canvas" was not inserted into document.'),n.canvas.oncontextmenu=function(){return!1},
n.canvas.onselectstart=function(){return!1},n},o.run=function(t){!function n(i){t.frameRequestId=e(n),o.world(t)}()},o.stop=function(e){t(e.frameRequestId)},o.clear=function(e){for(var t=e.container,n=e.spriteContainer;t.children[0];)t.removeChild(t.children[0]);for(;n.children[0];)n.removeChild(n.children[0]);var o=e.sprites["bg-0"];e.textures={},e.sprites={},e.primitives={},e.sprites["bg-0"]=o,o&&t.addChildAt(o,0),e.container.addChild(e.spriteContainer),e.currentBackground=null,t.scale.set(1,1),t.position.set(0,0)},o.setBackground=function(e,t){if(e.currentBackground!==t){var n=t.indexOf&&-1!==t.indexOf("#"),o=e.sprites["bg-0"];if(n){var i=s.colorToNumber(t);e.renderer.backgroundColor=i,o&&e.container.removeChild(o)}else if(!o){var r=d(e,t);o=e.sprites["bg-0"]=new PIXI.Sprite(r),o.position.x=0,o.position.y=0,e.container.addChildAt(o,0)}e.currentBackground=t}},o.world=function(e){
var t,n=e.engine,s=n.world,a=e.renderer,c=e.container,d=e.options,u=r.allBodies(s),p=r.allConstraints(s),f=[];d.wireframes?o.setBackground(e,d.wireframeBackground):o.setBackground(e,d.background);var m=e.bounds.max.x-e.bounds.min.x,v=e.bounds.max.y-e.bounds.min.y,y=m/e.options.width,g=v/e.options.height;if(d.hasBounds){for(t=0;t<u.length;t++){var x=u[t];x.render.sprite.visible=i.overlaps(x.bounds,e.bounds)}for(t=0;t<p.length;t++){var h=p[t],b=h.bodyA,w=h.bodyB,S=h.pointA,C=h.pointB;b&&(S=l.add(b.position,h.pointA)),w&&(C=l.add(w.position,h.pointB)),S&&C&&((i.contains(e.bounds,S)||i.contains(e.bounds,C))&&f.push(h))}c.scale.set(1/y,1/g),c.position.set(-e.bounds.min.x*(1/y),-e.bounds.min.y*(1/g))}else f=p;for(t=0;t<u.length;t++)o.body(e,u[t]);for(t=0;t<f.length;t++)o.constraint(e,f[t]);a.render(c)},o.constraint=function(e,t){var n=(e.engine,t.bodyA),o=t.bodyB,i=t.pointA,r=t.pointB,a=e.container,l=t.render,c="c-"+t.id,d=e.primitives[c];if(d||(d=e.primitives[c]=new PIXI.Graphics),
!l.visible||!t.pointA||!t.pointB)return void d.clear();-1===s.indexOf(a.children,d)&&a.addChild(d),d.clear(),d.beginFill(0,0),d.lineStyle(l.lineWidth,s.colorToNumber(l.strokeStyle),1),n?d.moveTo(n.position.x+i.x,n.position.y+i.y):d.moveTo(i.x,i.y),o?d.lineTo(o.position.x+r.x,o.position.y+r.y):d.lineTo(r.x,r.y),d.endFill()},o.body=function(e,t){var o=(e.engine,t.render);if(o.visible)if(o.sprite&&o.sprite.texture){var i="b-"+t.id,r=e.sprites[i],a=e.spriteContainer;r||(r=e.sprites[i]=n(e,t)),-1===s.indexOf(a.children,r)&&a.addChild(r),r.position.x=t.position.x,r.position.y=t.position.y,r.rotation=t.angle,r.scale.x=o.sprite.xScale||1,r.scale.y=o.sprite.yScale||1}else{var l="b-"+t.id,d=e.primitives[l],u=e.container;d||(d=e.primitives[l]=c(e,t),d.initialAngle=t.angle),-1===s.indexOf(u.children,d)&&u.addChild(d),d.position.x=t.position.x,d.position.y=t.position.y,d.rotation=t.angle-d.initialAngle}};var n=function(e,t){var n=t.render,o=n.sprite.texture,i=d(e,o),r=new PIXI.Sprite(i)
;return r.anchor.x=t.render.sprite.xOffset,r.anchor.y=t.render.sprite.yOffset,r},c=function(e,t){var n,o=t.render,i=e.options,r=new PIXI.Graphics,a=s.colorToNumber(o.fillStyle),l=s.colorToNumber(o.strokeStyle),c=s.colorToNumber(o.strokeStyle),d=s.colorToNumber("#bbb"),u=s.colorToNumber("#CD5C5C");r.clear();for(var p=t.parts.length>1?1:0;p<t.parts.length;p++){n=t.parts[p],i.wireframes?(r.beginFill(0,0),r.lineStyle(1,d,1)):(r.beginFill(a,1),r.lineStyle(o.lineWidth,l,1)),r.moveTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y);for(var f=1;f<n.vertices.length;f++)r.lineTo(n.vertices[f].x-t.position.x,n.vertices[f].y-t.position.y);r.lineTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y),r.endFill(),(i.showAngleIndicator||i.showAxes)&&(r.beginFill(0,0),i.wireframes?r.lineStyle(1,u,1):r.lineStyle(1,c),r.moveTo(n.position.x-t.position.x,n.position.y-t.position.y),
r.lineTo((n.vertices[0].x+n.vertices[n.vertices.length-1].x)/2-t.position.x,(n.vertices[0].y+n.vertices[n.vertices.length-1].y)/2-t.position.y),r.endFill())}return r},d=function(e,t){var n=e.textures[t];return n||(n=e.textures[t]=PIXI.Texture.fromImage(t)),n}}()},{"../body/Composite":2,"../core/Common":14,"../core/Events":16,"../geometry/Bounds":26,"../geometry/Vector":28}]},{},[30])(30)});
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "海底",
"desc": "海底模块",
"props": {
"level_1": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "5,1,9,60"
},
"level_2": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "10,2,14,80"
},
"level_3": {
"alias": "第一关数据(第一个是当前关卡通过所需积分,第二个是炸弹个数,第三个是道具个数,第四个是关卡时间)",
"type": "array<number>",
"default": "15,3,19,110"
}
},
"assets": [
{
"name": "灯",
"url": "//yun.duiba.com.cn/aurora/assets/c0f7c4b4d650da31d9b23a9006bd0e58aaca95ad.png",
"uuid": "55a9e50c-c7bc-4bb1-8624-fdd7edb66f93",
"ext": ".png"
},
{
"name": "机子",
"url": "//yun.duiba.com.cn/aurora/assets/e07baecf71ed8ecd9429fbbebb064b3cd50658df.png",
"uuid": "dee8564f-e17a-4a78-87f7-bebeb83fd235",
"ext": ".png"
},
{
"name": "篮筐",
"url": "//yun.duiba.com.cn/aurora/assets/b6977968fa3cdefbe181adbe2a381df9e8402af5.png",
"uuid": "8b49fe91-f6b7-414c-81d1-a9689e473b29",
"ext": ".png"
},
{
"name": "右按钮",
"url": "//yun.duiba.com.cn/aurora/assets/e3b4d4c0e557529b8c383639acce3d2ac01bf9b3.png",
"uuid": "1b1acf4a-a1fb-427e-a8cd-48214f89ac46",
"ext": ".png"
},
{
"name": "左按钮",
"url": "//yun.duiba.com.cn/aurora/assets/4bc49a4477adbfcda25d348473504d4384ad3dd2.png",
"uuid": "d828d269-68e7-4801-a3b2-e4bb1c38592b",
"ext": ".png"
},
{
"name": "basket_bottom",
"url": "//yun.duiba.com.cn/aurora/assets/8003d15eda09a24c38fdf32d2b774fe9a16fcd81.png",
"uuid": "1bccf897-d37e-4dc7-814f-6b8caf27a03b",
"ext": ".png"
},
{
"name": "basket_top",
"url": "//yun.duiba.com.cn/aurora/assets/55596516d4d44685fe07be1fef2105c8186edcd7.png",
"uuid": "826c7811-2767-469f-bf6b-908f3d404a1d",
"ext": ".png"
},
{
"name": "coin_json",
"url": "//yun.duiba.com.cn/aurora/assets/4170985efa5fea693a27734d14250e3b5a49962b.json",
"uuid": "9a0265ec-d9e7-4d47-83c7-d775115df38e",
"ext": ".json"
},
{
"name": "coin",
"url": "//yun.duiba.com.cn/aurora/assets/d6a361f27ebb81dd444ac40e428dffd06a0aa4e3.png",
"uuid": "abe242de-cf82-46ec-8a40-fcd51b0ca13d",
"ext": ".png"
},
{
"name": "boom_json",
"url": "//yun.duiba.com.cn/aurora/assets/4da36db75239d5c4f7b89d5805429ad64f7a05d5.json",
"uuid": "b0f0ae6d-b7c7-4a35-8c5a-7c4249f011db",
"ext": ".json"
},
{
"name": "boom",
"url": "//yun.duiba.com.cn/aurora/assets/b4579f262046e16245df9982ef31c57e433b0ba7.png",
"uuid": "129aa5f7-e308-40ce-ba9b-3fdc733d4ecb",
"ext": ".png"
},
{
"name": "candy_json",
"url": "//yun.duiba.com.cn/aurora/assets/2512911b42641f570be929e686a17fa91582f411.json",
"uuid": "0f21fae8-08cb-4c41-bab5-993d98fd7070",
"ext": ".json"
},
{
"name": "candy",
"url": "//yun.duiba.com.cn/aurora/assets/a91c39b45b0aa042b112ac477bc5ab80f00e8816.png",
"uuid": "67c0717c-9b89-4b56-a61a-91c8c7a99e4c",
"ext": ".png"
},
{
"name": "egg_json",
"url": "//yun.duiba.com.cn/aurora/assets/d789e4167a136e889729dd97d4f8728517226c8a.json",
"uuid": "75ac3c28-f8a8-4609-b908-bb386a6ace2c",
"ext": ".json"
},
{
"name": "egg",
"url": "//yun.duiba.com.cn/aurora/assets/a9156427b733d959c473dc0e37c929f103f77174.png",
"uuid": "e2f61593-e082-405a-bf19-79c78e2c067a",
"ext": ".png"
},
{
"name": "fail_json",
"url": "//yun.duiba.com.cn/aurora/assets/be22c261821766b019138176658ea3857f7dc5c8.json",
"uuid": "96f6c48f-f01e-4d13-a058-0c082edc38fa",
"ext": ".json"
},
{
"name": "fail",
"url": "//yun.duiba.com.cn/aurora/assets/d5fff67caae5a86bc29969d1676b76b253eda701.png",
"uuid": "9473b143-bd58-4450-b7b9-cb18911f3ba3",
"ext": ".png"
},
{
"name": "gift_json",
"url": "//yun.duiba.com.cn/aurora/assets/9165343ca17a457133d227956c217e0a821a0cf3.json",
"uuid": "48347b92-7c99-4bf5-a67a-d535b4785b20",
"ext": ".json"
},
{
"name": "gift",
"url": "//yun.duiba.com.cn/aurora/assets/e47e2ebdbb9cc8fe1f9f0e941af3cbe92b08162b.png",
"uuid": "a3667116-4218-4b5f-a6ec-c1529ddb71cf",
"ext": ".png"
},
{
"name": "success_json",
"url": "//yun.duiba.com.cn/aurora/assets/a010032b62ec260b6ad0844b1eff530847954e10.json",
"uuid": "3a70f25d-03c0-483c-847b-88b6e4ed5dcf",
"ext": ".json"
},
{
"name": "success",
"url": "//yun.duiba.com.cn/aurora/assets/e6c6b8fff68fcbb2e30cbb50f5690d52be4d8c99.png",
"uuid": "0ec792be-6fcc-4c5b-bf8a-0e8406a5c34b",
"ext": ".png"
},
{
"name": "玻璃",
"url": "//yun.duiba.com.cn/aurora/assets/90edb55a1c5fb4b7baf689144b7c1f3508ecb7ff.png",
"uuid": "92d1a3d4-256b-467b-a9a2-4820c2c2c718",
"ext": ".png"
},
{
"name": "contPng",
"url": "//yun.duiba.com.cn/aurora/assets/a19ba2de0b7f11830700ed8122585a95ebef1757.png",
"uuid": "84e4f5dc-149d-4ace-a02c-8b2aaf6819b1",
"ext": ".png"
},
{
"name": "bubble",
"url": "//yun.duiba.com.cn/aurora/assets/f30c3b92eac79cdae679c48436eb4ef92b97ff6c.png",
"uuid": "28c4a8e4-9ff8-4962-842a-dd90d04a958c",
"ext": ".png"
},
{
"name": "倒计时",
"url": "//yun.duiba.com.cn/aurora/assets/a9b9490cd7ef4974c6ca5c34b3b4e4a2fdd1f8ca.png",
"uuid": "893a1116-1ddb-49e5-89bd-8f523ad56f81",
"ext": ".png"
},
{
"name": "awesome",
"url": "//yun.duiba.com.cn/aurora/assets/89de7d7785bb70a95b139fe444b90fbe5e802c80.png",
"uuid": "b7f19c22-22ea-419e-99d0-3b6959b59f88",
"ext": ".png"
},
{
"name": "cool",
"url": "//yun.duiba.com.cn/aurora/assets/5e1ce8651de0f67cf98220238db00ef6d46b1aeb.png",
"uuid": "585b11a0-8d5d-4265-8871-96d98c0a65cf",
"ext": ".png"
},
{
"name": "good",
"url": "//yun.duiba.com.cn/aurora/assets/49a5633dc8429fac1d59c7a55ba15f3386cdddc7.png",
"uuid": "bdbc7ff6-5b64-4878-bcb2-9b83a498206b",
"ext": ".png"
},
{
"name": "great",
"url": "//yun.duiba.com.cn/aurora/assets/ad47ea03239e36e09806a74cb4bd475a42edb00a.png",
"uuid": "bd1da4bb-1dbf-4b80-a6ea-eb4e50cf65aa",
"ext": ".png"
},
{
"name": "perfect",
"url": "//yun.duiba.com.cn/aurora/assets/b560b07e694a95ef6b40b6702cdfc8853eb73ec3.png",
"uuid": "63ce23dc-be8b-4222-a0a6-0fd5a27c0af6",
"ext": ".png"
},
{
"name": "unbelievable",
"url": "//yun.duiba.com.cn/aurora/assets/a436eb46836e45d8043721107e5f49a58367ac3f.png",
"uuid": "6f352da0-0522-4530-b064-9132b591b341",
"ext": ".png"
},
{
"name": "进度",
"url": "//yun.duiba.com.cn/aurora/assets/0a7f33bba28a882ea1ec436b73ecafbaed4542d5.png",
"uuid": "647dc81b-443d-446b-bcf6-8b95b8511470",
"ext": ".png"
},
{
"name": "点亮",
"url": "//yun.duiba.com.cn/aurora/assets/3e8ca3a3f044df467c76a7a0d5ebbd75520bda8e.png",
"uuid": "9808f74f-a474-4c10-a8c6-bb51663d1a8e",
"ext": ".png"
},
{
"name": "lv1",
"url": "//yun.duiba.com.cn/aurora/assets/76db0c80d7b8051d7de44e87cac763ce607d2c7a.png",
"uuid": "a9a91d6c-06b0-4fdf-bcb8-77abe9bc7d83",
"ext": ".png"
},
{
"name": "lv2",
"url": "//yun.duiba.com.cn/aurora/assets/c5f1c83c683c5703432cc615b2c206aee1c675e0.png",
"uuid": "de8b2a81-fb38-4128-b536-9ef03eb013df",
"ext": ".png"
},
{
"name": "lv3",
"url": "//yun.duiba.com.cn/aurora/assets/beed55701a29bfa9b49dca1d5a059b34d7702496.png",
"uuid": "710eed46-f371-4d85-9858-ad048c86fc74",
"ext": ".png"
},
{
"name": "lv_common",
"url": "//yun.duiba.com.cn/aurora/assets/0afe14fc04beb3c66ce9080502c7c381f4b658ea.png",
"uuid": "e53e80fd-80a6-4385-b296-a3f097eeb51a",
"ext": ".png"
},
{
"name": "dot",
"url": "//yun.duiba.com.cn/aurora/assets/b39a88200f27f65e9d8d3f2a98a671de979f3027.png",
"uuid": "b8acc117-7d3c-4bcb-aff9-b5f42b901edf",
"ext": ".png"
}
],
"events": {
"in": {
"seabed-game-start": {
"alias": "开始",
"data": {
}
},
"seabed-game-startNextLevel": {
"alias": "开始下一关",
"data": {
"level":"关卡"
}
},
"seabed-game-revive": {
"alias": "复活",
"data": {
}
},
"seabed-game-themeChange": {
"alias": "更换主题",
"data": {
"gameCountdownImage": "游戏页倒计时",
"leftButtonImage": "左按钮",
"rightButtonImage": "右按钮"
}
}
},
"out": {
"seabed-game-fail": {
"alias": "游戏结束",
"data": {
"score":"当前分数",
"level": "当前关卡"
}
},
"seabed-game-success": {
"alias": "游戏成功",
"data": {
"score":"当前分数",
"level": "当前关卡"
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import { getIndexFromRC, getRandomArray, getTexture, getTextureByName } from "./utils";
import ObjectPool = engine.ObjectPool;
import { Tool } from "./Tools";
import { getScore, getCurLevel, getlevelMax } from "./goldData";
export default class GameData extends engine.Container {
private _scoreCount:engine.Label;
private _scorelabel:engine.Label;
private _levelLabel:engine.Label;
private _parentNode;
private starList = [];
private _progressMask;
private _color;
constructor(parentNode,color) {
super();
this._parentNode = parentNode;
this._color = color;
this.init();
}
init(){
//分数
let scoreCount = this._scoreCount = Tool.getLabel('',36,"#ffffff",true)
scoreCount.y = 48;
this.addChild(scoreCount);
let scorelabel = this._scorelabel = Tool.getLabel('分',22,"#ffffff")
scorelabel.y = 56;
this.addChild(scorelabel);
let progress = new engine.Sprite(getTextureByName('进度'));
progress.x = 212;
progress.y = 8;
this.addChild(progress);
let progressMask = this._progressMask = new engine.Rect()
progressMask.fillColor = 0x000000
progressMask.width = 245;
progressMask.height = 100;
progressMask.x = 213;
progressMask.y = 5;
//0.35 0.75 1
progressMask.scaleX = 0;
this.addChild(progressMask);
progress.mask = progressMask;
let star1 = new engine.Sprite(getTextureByName('点亮'));
star1.x = 270;
star1.y = 6;
star1.visible = false;
this.addChild(star1);
this.starList.push(star1);
let star2 = new engine.Sprite(getTextureByName('点亮'));
star2.x = 365;
star2.y = 6;
star2.visible = false;
this.addChild(star2);
this.starList.push(star2);
let star3 = new engine.Sprite(getTextureByName('点亮'));
star3.x = 435;
star3.y = 50;
star3.visible = false;
this.addChild(star3);
this.starList.push(star3);
this.scorePosUpdate();
//当前关卡数
let levelLabel = this._levelLabel = Tool.getLabel('',28,this._color||"#28c1ec",false)
levelLabel.y = 98;
this.addChild(levelLabel);
this.levelUpdate();
this.updateProgressMask();
}
scorePosUpdate(){
this._scoreCount.text = getScore()
this._scoreCount.x = (this._parentNode.width - this._scoreCount.width - this._scorelabel.width - 5)/2
this._scorelabel.x = this._scoreCount.x + this._scoreCount.width + 5;
this.updateProgressMask();
}
levelUpdate(color?){
this._levelLabel.text = `第${getCurLevel()}/3关`
this._levelLabel.x = (this._parentNode.width-this._levelLabel.width)/2;
}
updateProgressMask(){
let ratio = getScore()/getlevelMax()
this._progressMask.scaleX = ratio;
//0.35 0.75 1
if(ratio >= 0.35){
this.starList[0].visible = true;
}
if(ratio >= 0.75){
this.starList[1].visible = true;
}
if(ratio >= 1){
this.starList[2].visible = true;
}
}
resetMask(){
this.starList.forEach(element => {
element.visible = false;
});
}
}
\ No newline at end of file
import { setTouchEnabled, getTouchEnabled } from './GoldData';
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import { getIndexFromRC, getRandomArray, getTexture, getTextureByName } from "./utils";
import ObjectPool = engine.ObjectPool;
import GameData from "./gameData";
import EgretRender from "../physics/EgretRender";
import check from "./check";
import { addScore, getlevelTime, getCurLevel, getScore, getlevelMax } from "./goldData";
import createBox from "./createBox";
import createItems from "./createItems";
import { stopStandbyBubblesLeft, startStandbyBubblesLeft, stopStandbyBubblesRight, startStandbyBubblesRight } from "./standbyBubbles";
import createBtns from "./createBtns";
import createBubblePic from "./createBubblePic";
import { bubbleGroup, bubble, bubbleMask, award } from "./collisionConfig";
import { Tool } from './Tools';
import { playBoom } from "./playMovieClip";
export default class GameView extends engine.Container {
private _bg;
private _gameNode;
public _leftBtn;
public _rightBtn;
private _light;
private _basket_top;
private _basket_bottom;
private _gameData:GameData;
public _engine: Matter.Engine;
public egretRenderContainer: engine.Sprite;
public _egretRender: EgretRender;
private _countDown:engine.Sprite;
private _countDownLabel:engine.Label;
public _startStandbyBubblesLeft;
public _startStandbyBubblesRight;
private _curLevelTime;
public gameHint:{[name: string]: any} = {};
private toastRect;
private toastLabel:engine.Label;
constructor() {
super();
}
async start(color) {
let a = new engine.Shape()
this.addChild(a)
engine.globalLoader.loadImage('//yun.duiba.com.cn/aurora/assets/66ab48ff49a741f0c93335d4eb0c9e50b7ab6e1e.png', 'bg_dot')
.then((img)=>{
a.beginBitmapFill(img,null)
a.drawRect(0,0,750,1624)
a.endFill()
});
let gameNode = this._gameNode = new engine.Sprite(getTextureByName('机子'));
gameNode.y = 260;
this.addChild(gameNode);
let contPng = new engine.Image(getTextureByName('contPng'));
contPng.x = (750-contPng.width)/2
contPng.y = 215;
this.addChild(contPng);
let leftBtn = this._leftBtn = new engine.Sprite(getTextureByName('左按钮'));
leftBtn.anchorY = leftBtn.height-50
leftBtn.x = 83;
leftBtn.y = 920;
gameNode.addChild(leftBtn);
let rightBtn = this._rightBtn = new engine.Sprite(getTextureByName('右按钮'));
rightBtn.anchorY = rightBtn.height-50
rightBtn.x = 400;
rightBtn.y = 920;
gameNode.addChild(rightBtn);
let light = this._light = new engine.Sprite(getTextureByName('灯'));
light.x = 12;
light.y = 44;
gameNode.addChild(light);
let basket_bottom = this._basket_bottom = new engine.Sprite(getTextureByName('basket_bottom'));
basket_bottom.x = (contPng.width - basket_bottom.width)/2;
basket_bottom.y = 85;
contPng.addChild(basket_bottom);
let tmpRect = new engine.Rect();
tmpRect.x = 230
tmpRect.y = 372
tmpRect.width = 300;
tmpRect.height = 300;
this.addChild(tmpRect);
basket_bottom.mask = tmpRect;
let basket_top = this._basket_top = new engine.Sprite(getTextureByName('basket_top'));
basket_top.x = 287;
basket_top.y = 485;
this.addChild(basket_top);
let glass = this._basket_top = new engine.Sprite(getTextureByName('玻璃'));
glass.x = (750-glass.width)/2;
glass.y = 340;
this.addChild(glass);
let gameData = this._gameData = new GameData(contPng,color);
contPng.addChild(gameData);
//倒计时
let countDown = this._countDown = new engine.Sprite(getTextureByName('倒计时'));
countDown.x = 5;
countDown.y = 180;
this.addChild(countDown);
this._curLevelTime = getlevelTime()
let countDownLabel = this._countDownLabel = Tool.getLabel(this._curLevelTime,48,"#ffffff")
countDownLabel.x = (countDown.width-countDownLabel.width)/2
countDownLabel.y = (countDown.height-countDownLabel.height)/2 - 5
countDown.addChild(countDownLabel);
this.initGameHint();
// let rect = this.toastRect = new engine.Rect();
// rect.fillColor = 0x000000;
// rect.width = 400;
// rect.height = 80;
// rect.x = (750-400) / 2;
// rect.y = 500;
// rect.alpha = 0;
// this.addChild(rect);
// let toast = this.toastLabel = Tool.getLabel(``,28,"#28c1ec",false)
// toast.x = (rect.width - toast.width) / 2;
// toast.y = (rect.height - toast.height) / 2;
// toast.fillColor = 0xffffff;
// rect.addChild(toast);
this.startHandle();
this.levelHint();
}
private _lvbg;
private _lv:engine.Sprite;
private _lv_common;
private _lv_label:engine.Label;
levelHint(){
let lvBg = this._lvbg = new engine.Rect();
lvBg.fillColor = 0x000000;
lvBg.alpha = 0.7;
lvBg.width = 750;
lvBg.height = 1624;
lvBg.x = lvBg.y = 0;
lvBg.visible = false;
this.addChild(lvBg);
let lv_common = this._lv_common = new engine.Sprite(getTextureByName('lv_common'));
lv_common.x = (750-lv_common.width)/2;
lv_common.y = 500;
lv_common.visible = false;
this.addChild(lv_common);
let lv1 = this._lv = new engine.Sprite(getTextureByName('lv1'));
lv1.anchorTexture.set(0.5,0.5)
lv1.x = lv_common.width/2;
lv1.y = 80;
lv_common.addChild(lv1);
let lv1_label = this._lv_label = Tool.getLabel(`5`,38,"#28c1ec",true,engine.TEXT_ALIGN.CENTER)
lv1_label.width = 100;
lv1_label.x = 205;
lv1_label.y = 205;
lv1_label.fillColor = 0xffffff;
lv_common.addChild(lv1_label);
//this.lvArray.push(lv_common);
}
initGameHint(){
//['great', 'cool', 'perfect', 'awesome', 'unbelievable']
let awesome = new engine.Sprite(getTextureByName('awesome'));
awesome.anchorTexture.set(0.5,0.5);
awesome.x = 520;
awesome.y = 490;
awesome.alpha = 0;
this.addChild(awesome);
this.gameHint['awesome'] = awesome;
let cool = new engine.Sprite(getTextureByName('cool'));
cool.anchorTexture.set(0.5,0.5);
cool.x = 520;
cool.y = 490;
cool.alpha = 0;
this.addChild(cool);
this.gameHint['cool'] = cool;
let good = new engine.Sprite(getTextureByName('good'));
good.anchorTexture.set(0.5,0.5);
good.x = 520;
good.y = 490;
good.alpha = 0;
this.addChild(good);
this.gameHint['good'] = good;
let great = new engine.Sprite(getTextureByName('great'));
great.anchorTexture.set(0.5,0.5);
great.x = 520;
great.y = 490;
great.alpha = 0;
this.addChild(great);
this.gameHint['great'] = great;
let perfect = new engine.Sprite(getTextureByName('perfect'));
perfect.anchorTexture.set(0.5,0.5);
perfect.x = 530;
perfect.y = 490;
perfect.alpha = 0;
this.addChild(perfect);
this.gameHint['perfect'] = perfect;
let unbelievable = new engine.Sprite(getTextureByName('unbelievable'));
unbelievable.anchorTexture.set(0.5,0.5);
unbelievable.x = 480;
unbelievable.y = 460;
unbelievable.alpha = 0;
this.addChild(unbelievable);
this.gameHint['unbelievable'] = unbelievable;
}
startNextLevel(){
this.clearAwardBody()
this.playLevelAni()
setTouchEnabled(true);
createItems(this);
this._gameData.scorePosUpdate();
this._gameData.resetMask();
this._gameData.levelUpdate();
this._curLevelTime = getlevelTime()
this._countDownLabel.text = this._curLevelTime;
this._countDownLabel.x = (this._countDown.width-this._countDownLabel.width)/2
this.runEngine();
}
themeChange(data){
this._countDown.texture = engine.Texture.fromImage(data.gameCountdownImage);
this._leftBtn.texture = engine.Texture.fromImage(data.leftButtonImage);
this._leftBtn.anchorY = this._leftBtn.height-50
this._leftBtn.x = 83;
this._leftBtn.y = 920;
this._rightBtn.texture = engine.Texture.fromImage(data.rightButtonImage);
this._rightBtn.anchorY = this._rightBtn.height-50
this._rightBtn.x = 400;
this._rightBtn.y = 920;
}
revive(){
setTouchEnabled(true);
this.runEngine();
}
startHandle(){
//创建引擎
const engineMatter = Matter.Engine.create();
this._engine = engineMatter;
this._engine.world.gravity.y = 0.2;
//创建egret渲染
this.egretRenderContainer = new engine.Sprite();
this.addChild(this.egretRenderContainer);
this._egretRender = new EgretRender(this.egretRenderContainer, this._engine);
const options: any = {
width: 750,
height: 1624,
wireframes: !1,
};
const render = Matter.Render.create({
element: document.getElementById('debugCanvas'),
engine: engineMatter,
options: options
});
Matter.Render.run(render);
this.runGame();
}
addForce = false;
stageX = 0;
stageY = 0;
runGame(){
createBox(this);
Matter.Events.on(this._engine, 'beforeUpdate', () => {
if (!this.addForce) return
this.addForce = false;
const isleft = this.stageX < 375;
const start = isleft ? { x: 180, y: 1050 } : { x: 560, y: 1050 };
const scale = 2.2;
for (let i = 0; i < 15; i++) {
setTimeout(() => {
const r = this.random(10, 14);
let bubblePic;
bubblePic = createBubblePic(r);//默认球的尺寸100
const basex = 0.02;
const xoffset = 0.007;
const fx = isleft ? this.random(-basex, basex) : this.random(-basex, basex);
const padding = 50;
const startx = this.random(start.x - padding, start.x + padding);
if (fx < -xoffset || fx > xoffset) bubblePic = null;
const body = this._egretRender.circle(startx, start.y, r, bubblePic,
{
density: 0.001 * 3,
restitution: 1,
force: { x: fx * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }
}
);
setTimeout(() => {
this._egretRender.remove(body);
}, 1000);
}, Math.random() * 200);
}
for (let j = 0; j < 1; j++) {
const start = isleft ? { x: 180 + 50, y: 1050 + 30 } : { x: 560 - 50, y: 1050 + 30 };
const r = this.random(10, 14);
const body = this._egretRender.circle(start.x, start.y, r, null,
{
density: 0.001 * 3,
restitution: 1,
force: { x: (isleft ? 1 : -1) * 0.02 * 1.7, y: 0 },
collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }
}
);
setTimeout(() => {
this._egretRender.remove(body);
}, 1000);
}
});
this._leftBtn.addEventListener(engine.MouseEvent.CLICK, (e: engine.MouseEvent) => {
if(!getTouchEnabled())return;
this.addForce = true;
this.stageX = e.stageX;
stopStandbyBubblesLeft();
clearTimeout(this._startStandbyBubblesLeft);
this._startStandbyBubblesLeft = setTimeout(() => {
startStandbyBubblesLeft(this._egretRender);
}, 1000);
}, this);
this._rightBtn.addEventListener(engine.MouseEvent.CLICK, (e: engine.MouseEvent) => {
if(!getTouchEnabled())return;
this.addForce = true;
this.stageX = e.stageX;
stopStandbyBubblesRight();
clearTimeout(this._startStandbyBubblesRight);
this._startStandbyBubblesRight = setTimeout(() => {
startStandbyBubblesRight(this._egretRender);
}, 1000);
}, this);
createBtns(this)
startStandbyBubblesLeft(this._egretRender);
startStandbyBubblesRight(this._egretRender);
}
//帧处理
private lastTime;
private _frameCount = 0;
enterFrame(){
var now = Date.now();
var deltaTime = this.lastTime ? now - this.lastTime : 16.7;
this.lastTime = now;
this._frameCount += deltaTime;
if(this._frameCount>=1000){
this._frameCount = 0;
this.updateCountDown();
}
if(deltaTime > 20)
deltaTime = 20
Matter.Engine.update(this._engine, deltaTime);
this._egretRender.run();
check(this);
return false;
}
random(start, end){
const n = end - start;
return Math.random() * n + start;
}
runEngine(){
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this)
}
updateCountDown(){
this._curLevelTime --
this._countDownLabel.text = this._curLevelTime;
this._countDownLabel.x = (this._countDown.width-this._countDownLabel.width)/2
if(this._curLevelTime <= 0)
{
this.end();
console.log('时间结束');
}
}
onBoom(){
this.end();
}
addScore(): any {
addScore(1)
if(getScore() >= getlevelMax()){
setTouchEnabled(false);
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this)
engine.globalEvent.dispatchEvent('seabed-game-success',{level:getCurLevel(),score:getScore()})
}
this._gameData.scorePosUpdate();
}
playLevelAni(){
const lv = getCurLevel();
this._lv.texture = getTextureByName(`lv${lv}`)
this._lv_label.text = getlevelMax()+'';
this._lvbg.visible = true;
this._lv_common.visible = true;
engine.Tween.get(this._lv_common).set({ y: 500 - 1624 }).to({ y: 500 }, 700, engine.Ease.backOut)
.wait(1000).to({ y: 1624 + 500 }, 500, engine.Ease.backIn)
.call(()=>{
this._lvbg.visible = false;
});
//engine.Tween.get(this['lvbg']).wait(700 + 1000).to({ alpha: 0 }, 500);
}
clearAwardBody() {
const bodies = Matter.Composite.allBodies(this._engine.world);
const isAward = (i: Matter.Body) => { return i.collisionFilter.group == award }
bodies.forEach(i => {
if (isAward(i)) this._egretRender.remove(i);
})
}
end(){
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this)
engine.globalEvent.dispatchEvent('seabed-game-fail',{level:getCurLevel(),score:getScore(),time:this._curLevelTime})
setTouchEnabled(false);
}
}
\ No newline at end of file
import { setTouchEnabled, setlevelData } from './GoldData';
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import { injectProps } from "../props";
import { setScore, setCurLevel } from "./goldData";
import { getJsonAsset } from "./JsonTools";
export class GameWrapper extends engine.Container {
// private _status;
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('seabed-game-start', this.start, this);
engine.globalEvent.addEventListener('seabed-game-revive', this.revive, this);
engine.globalEvent.addEventListener('seabed-game-startNextLevel', this.startNextLevel, this);
engine.globalEvent.addEventListener('seabed-game-themeChange', this.themeChange, this);
//创建实例
let gameView = this._gameView = new GameView();
this.addChild(gameView);
//this.start(null);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('seabed-game-startNextLevel',{level:2});
// }, 300);
}
start(event: engine.Event) {
setlevelData();
this.initData();
this._gameView.start(event.data.color);
['coin','boom','fail','success'].forEach(element => {
getJsonAsset(element);
});
}
startNextLevel(event: engine.Event){
setScore(0);
setCurLevel(parseInt(event.data.level));
this._gameView.startNextLevel();
}
initData(){
setScore(0);
setCurLevel(1);
}
//复活
revive(){
this._gameView.revive();
}
themeChange(event: engine.Event){
this._gameView.themeChange(event.data.resData);
}
}
import LabelType from "./LabelType";
import { props } from "../props";
let curScore;
export function getScore(){
return curScore;
}
export function addScore(addCount:number){
curScore += addCount;
return curScore;
}
export function setScore(scoreCount:number){
curScore = scoreCount;
}
let curLevel;
export function getCurLevel(){
return curLevel;
}
export function setCurLevel(level){
curLevel = level
return curLevel;
}
//time-当前关卡时长
let levels;
export const setlevelData = () => {
levels = {
'1': { max: props.level_1[0], items: [[LabelType.boom, props.level_1[1]],[LabelType.coin, props.level_1[2]]],time:props.level_1[3]},
'2': { max: props.level_2[0], items: [[LabelType.boom, props.level_2[1]], [LabelType.coin, props.level_2[2]]] ,time:props.level_2[3]},
'3': { max: props.level_3[0], items: [[LabelType.boom, props.level_3[1]], [LabelType.coin, props.level_3[2]]] ,time:props.level_3[3]},
}
}
export const getLevelData = () => {
if(!levels){
setlevelData();
}
return levels[getCurLevel()]
}
export const getCurrentItems = () => {
if(!levels){
setlevelData();
}
return getLevelData().items
}
export const getlevelTime = () => {
if(!levels){
setlevelData();
}
return getLevelData().time
}
//当前关卡需要的最大通关数
export const getlevelMax = () => {
if(!levels){
setlevelData();
}
return getLevelData().max
}
let touchEnabled = false;
export const getTouchEnabled = () => {
return touchEnabled
}
export const setTouchEnabled = (b) => {
touchEnabled = b
}
\ No newline at end of file
let josnData: {
[name: string]: any
} = {};
export function getJsonAsset(name: string) {
let config = engine.getAssetByName(name+'_json');
let tmpJosnData = engine.globalLoader.get(config.uuid);
if(tmpJosnData){
josnData[name] = convert(tmpJosnData);
}
}
export function convert(data){
let frames = data.frames;
let jsonName = data.file.split('.')[0]
var obj = {};
for (var key in frames) {
let f = frames[key];
obj[jsonName + key + ".png"] = {
"x": f.x,
"y": f.y,
"w": f.w,
"h": f.h,
"ox": f.offX,
"oy": f.offY,
"sw": f.sourceW,
"sh": f.sourceH,
"ro": false,
}
}
return obj||null;
}
export function getJosnData(jsonName:string) {
return josnData[jsonName] || null;
}
\ No newline at end of file
enum LabelType {
boom='boom',candy='candy',coin='coin',gift='gift',egg='egg'
}
export default LabelType
\ No newline at end of file
export class Tool{
/**
*
* @param txt
* @param size
* @param color
* @param textWidth
* @param align
* @param x
* @param y
*/
public static getLabel(
txt: string,
size: number,
color: string = "#ffffff",
bold:boolean = false,
align: engine.TEXT_ALIGN = engine.TEXT_ALIGN.LEFT,
x: number = 0,
y: number = 0
):engine.Label{
var label = new engine.Label();
label.fillColor = color;
label.bold = bold;
label.size = size;
label.textAlign = align;
label.x = x;
label.y = y;
label.text = txt;
return label;
}
}
\ No newline at end of file
import GameView from "./GameView";
import LabelType from "./LabelType";
import { award } from "./collisionConfig";
import vibrate from "./vibrate";
import { playBoom, playSuccess } from "./playMovieClip";
import { getScore, getLevelData } from "./goldData";
import { createNewBubble } from "./createItems";
import { playTextAni } from "./playTextAni";
export function check (_this:GameView) {
const egretRenderContainer = _this.egretRenderContainer;
const center = 375;
const paddingX = 50;
const ypos = 570;
const h = 40;
// _this._egretRender._root.graphics.beginFill(0xff0000, 1);
// _this._egretRender._root.graphics.drawRect(center - paddingX, ypos, paddingX * 2, h);
// _this._egretRender._root.graphics.endFill();
const bodies = Matter.Composite.allBodies(_this._engine.world);
const isAward = (i: Matter.Body) => { return i.collisionFilter.group == award }
bodies.forEach(i => {
if (!isAward(i)) return;
if (i['timer']) {
const t0 = Date.now() - i['timer'];
if (t0 > 3000)//3s之内不可再用
{
delete i['timer'];
// console.log('重新可用', Date.now() / 1000)
}
}
const { x, y } = i.position;
const xResult = x > (center - paddingX) && x < (center + paddingX);
const yResult = y > ypos && y < (ypos + h);
if (xResult && yResult && i.velocity.y > 0 && !i['timer']) {
i['timer'] = Date.now();
if (i.label == LabelType.boom) {
_this._egretRender.remove(i);
vibrate(_this, 2);
playBoom(egretRenderContainer);
_this.onBoom();
}
else if (i.label == LabelType.egg) {
_this._egretRender.remove(i);
//PanelCtrl.instance.show(ModuleTypes.SLOT_PANEL);
}
else if (i.label == LabelType.candy) {
_this._egretRender.remove(i);
//PanelCtrl.instance.show(ModuleTypes.ROTATE_PANEL);
}
else if (i.label == LabelType.gift) {
_this._egretRender.remove(i);
//PanelCtrl.instance.show(ModuleTypes.TREASURE_PANEL);
}
else {
// console.log('不是boom,重用', Date.now() / 1000);
// playScoreAni(_this.egretRenderContainer, 1)
playSuccess(_this.egretRenderContainer);
_this._egretRender.remove(i);
_this.addScore();
//checkAdd(_this);
playTextAni(_this)
}
}
})
}
const checkAdd = (that: GameView) => {
const oldscore = getScore();
const awards = getLevelData().awards;
for (const award of awards) {
if (award[0] == oldscore) {
const type = award[1];
createNewBubble(that, type);
break;
}
}
}
export default check
\ No newline at end of file
export const wall = 1;
export const basket = 2;
export const award = 4;
export const bubble = 8;
export const bubbleStandby = 16;
export const bubbleGroup = -1;
export const bubbleStandbyGroup = -2;
export const wallMask = award + bubble + bubbleStandby;
export const basketMask = award + bubble + bubbleStandby;
export const awardMask = wall + basket + bubble;
export const bubbleMask = wall + basket + award;
export const bubbleStandbyMask = wall + basket;
import { wall, wallMask, basket, basketMask } from "./collisionConfig";
import GameView from "./GameView";
const createBox = (_this:GameView) => {
//202
//385 168 640 201 695 528 644 866 392 907 109 868 57 546 118 206 0 206 0 1624 750 1624 750 0
//385 370 630 380 670 728 620 1080 370 1100 109 1090 57 728 108 370 0 370 0 1624 750 1624 750 0
const path1 = Matter.Vertices.fromPath('385 370 630 380 670 728 620 1080 370 1100 109 1090 57 728 108 370 0 370 0 1624 750 1624 750 0', null);
//430, 717
//430,920
const body = Matter.Bodies.fromVertices(400, 880, [path1], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);
Matter.World.add(_this._engine.world, body);
//118 206 385 168 385 100
//108 370 385 370 385 300
const path2 = Matter.Vertices.fromPath('108 370 385 370 385 300', null);
//425 - 10 - 100 - 10 - 10 + 1, 30 + 100 + 10 + 10 + 6
//296, 365
const body2 = Matter.Bodies.fromVertices(296, 365, [path2], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);
Matter.World.add(_this._engine.world, body2);
//290 432 324 476 326 476 313 432
//290 560 324 600 326 600 313 565
const basketpath1 = Matter.Vertices.fromPath('290 560 324 600 326 600 313 565', null);
//311 - 3 - 8 + 2+3, 452 - 5
//305, 575
const basketbody1 = Matter.Bodies.fromVertices(305, 575, [basketpath1], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);
Matter.World.add(_this._engine.world, basketbody1);
//479 435 443 481 441 481 456 435
//465 563 443 605 441 605 456 560
const basketpath2 = Matter.Vertices.fromPath('465 563 443 605 441 605 456 560', null);
//449 + 3 + 8 - 2 - 2-3, 452 - 5
//453, 570
const basketbody2 = Matter.Bodies.fromVertices(453, 570, [basketpath2], { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);
Matter.World.add(_this._engine.world, basketbody2);
//311 - 3 - 8 + 2 - 5, 427
//285, 560
const basketLeft = Matter.Bodies.circle(285, 560 , 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } })
Matter.World.add(_this._engine.world, basketLeft);
//456 + 5, 427
//461, 560
const basketRight = Matter.Bodies.circle(461, 560, 12, { isStatic: true, friction: 0, collisionFilter: { group: basket, category: basket, mask: basketMask } })
Matter.World.add(_this._engine.world, basketRight);
const w = 100;
const h = 50;
//153 + w / 2, 833 + h / 2
//180 1080
const rect = _this._egretRender.rectangle(180, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
//553 - 10 - 30 - 5 + w / 2, 833 + h / 2
//560 1080
const rect2 = _this._egretRender.rectangle(560, 1080, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
const w2 = 300;
const h2 = 10;
//375, 873 + h2 / 2
//375 1100
const rect3 = _this._egretRender.rectangle(375, 1100, w2, h2, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
}
export default createBox
\ No newline at end of file
import GameView from "./GameView";
export default (that: GameView) => {
const createShape = () => {
const shape = new engine.Shape();
shape.beginFill(0, .6);
shape.drawCircle(0, 0, that._leftBtn.width / 2);
shape.endFill();
return shape
}
[that._leftBtn, that._rightBtn].forEach(btn => {
btn.addEventListener(engine.MouseEvent.MOUSE_DOWN, (e: engine.MouseEvent) => {
const btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({scaleY:0.9},200)
}, that);
});
[that._leftBtn, that._rightBtn].forEach(btn => {
btn.addEventListener(engine.MouseEvent.MOUSE_UP, (e: engine.MouseEvent) => {
const btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({scaleX:1,scaleY:1},200)
}, that);
});
[that._leftBtn, that._rightBtn].forEach(btn => {
btn.addEventListener(engine.MouseEvent.MOUSE_OUT, (e: engine.MouseEvent) => {
const btn = e.target;
engine.Tween.removeTweens(btn);
engine.Tween.get(btn)
.to({scaleX:1,scaleY:1},200)
}, that);
});
// this['rightBtn'];
const shapeLeft = createShape();
shapeLeft.x = that._leftBtn.width/2
shapeLeft.y = that._leftBtn.height/2
that._leftBtn.addChild(shapeLeft);
//shapeLeft.x = that._leftBtn.x;
//shapeLeft.y = that._leftBtn.y;
//that._leftBtn.mask = shapeLeft;
const shapeR = createShape();
shapeR.x = that._rightBtn.width/2
shapeR.y = that._rightBtn.height/2
that._rightBtn.addChild(shapeR);
// shapeR.x = that._rightBtn.x;
// shapeR.y = that._rightBtn.y;
// that._rightBtn.mask = shapeR;
shapeLeft.alpha = shapeR.alpha = 0;
}
import { getTextureByName } from "./utils";
const createBubblePic = (r: number) => {
const bubbleTexture: engine.Texture = getTextureByName('bubble');
const bubblePic = new engine.Sprite(bubbleTexture);
//bubblePic.anchorX = 76;
//bubblePic.anchorY = 78;
//bubblePic.anchorTexture.set(0.5,0.5)
//bubblePic.x = bubblePic.x-76
//bubblePic.y = bubblePic.y-78
bubblePic.scaleX = bubblePic.scaleY = r * 2 / 100; //默认球的尺寸100
return bubblePic;
}
export default createBubblePic
\ No newline at end of file
import LabelType from "./LabelType";
import createCoin from "./item/createCoin";
import createBoom from "./item/createBoom";
import createGift from "./item/createGift";
import createCandy from "./item/createCandy";
import createEgg from "./item/createEgg";
const createItem = (scale, type: LabelType) => {
const funcs = {
'boom': createBoom,
'gift': createGift,
'candy': createCandy,
'egg': createEgg,
'coin': createCoin
};
const func = funcs[type];
return func(scale);
}
export default createItem
\ No newline at end of file
import GameView from "./GameView";
import LabelType from "./LabelType";
import createItem from "./createItem";
import { award, awardMask } from "./collisionConfig";
import { getCurrentItems, getScore } from "./goldData";
export const createNewBubble = (_this: GameView, type: LabelType) => {
createBubble(_this, type, 750 / 2, 450, { x: 0, y: 0 },0.001*10);
}
const createBubble = (_this: GameView, type: LabelType, x: number, y: number, force = { x: 0, y: 0 }, density = 0.001) => {
let scale;
const size = random(85, 100);
const maxsize = 100;
scale = size / maxsize;
const baseItem = createItem(scale, type);
let angle;
angle = 0;
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
//刚体和贴图尺寸比为1:1.12
_this._egretRender.circle(x, y, (size - 17) / 2, baseItem,
{
frictionAir: 0,
collisionFilter: { group: award, category: award, mask: awardMask },
angle: angle,
label: baseItem.type,
friction: 0,
force: force,
density: density
});
}
const random = (start, end) => {
const n = end - start;
return Math.random() * n + start;
}
export const rollbackIcon = (nums: number, _this:GameView) => {
const startY = 370;
const startX = Math.random() > .5 ? 150 : 750 - 150;
createBubble(_this, LabelType.boom, startX, startY);
let count = 0;
const coinsFall = setInterval(() => {
if (count <= nums - 1) {
const startX = Math.random() > .5 ? 150 : 750 - 150;
createBubble(_this, LabelType.coin, startX, startY)
count++;
} else {
//结束
}
}, 100);
}
export default (_this: GameView) => {
const score = getScore();
const items = getCurrentItems();//[[LabelType.boom, 1], [LabelType.coin, 5]]
const list = [];
for (const item of items) {
const type = item[0];
let nums = item[1];
if (type == LabelType.coin)
nums = nums - score;
for (let i = 0; i < nums; i++) {
list.push(type);
}
}
let count = 0;
const countMax = 1;
const coinsFall = setInterval(() => {
if (count <= list.length - 1) {
const type = list[count];
createBubble(_this, type,375 + Math.random() * 200-100 , 400 + 200 +200)
count++;
} else {
//结束
}
}, 100);
}
\ No newline at end of file
interface dataTm {
x: number, //x,y,w,h为图集上的切图位置数据
y: number,
w: number,
h: number,
ox: number, //ox,oy为偏移数据,trim裁剪的数据,在orig上的偏移{x:0,y:0,width:200,height:200}
oy: number,
sw: number, //sw,sh为原始宽高
sh: number,
ro: boolean, //是否旋转
}
//简化后的格式
var expData = {
"actOverTitle.png": { "x": 1, "y": 1, "w": 474, "h": 172, "ox": 0, "oy": 0, "sw": 474, "sh": 172, "ro": false },
"hasActOverLotBtn.png": { "x": 1, "y": 175, "w": 259, "h": 85, "ox": 0, "oy": 0, "sw": 259, "sh": 85, "ro": false }
}
/**
*
* @param baseTexture
* @param altaData
* @return 返回贴图集。不常用
*/
export function createTextureSheet(baseTexture:engine.BaseTexture, altaData) {
var frames = altaData;
var frameKeys = Object.keys(frames);
let frameIndex = 0;
//要返回的贴图集合
var textures = {};
while (frameIndex < frameKeys.length) {
//名字
const i = frameKeys[frameIndex];
//数据
const data: dataTm = frames[i];
//切图上的数据
let frame: engine.Rectangle = null;
//裁切的数据
let trim: engine.Rectangle = null;
//贴图原始尺寸
const orig = new engine.Rectangle(
0,
0,
Math.floor(data.sw),
Math.floor(data.sh)
);
//如果旋转过
if (data.ro) {
frame = new engine.Rectangle(
Math.floor(data.x),
Math.floor(data.y),
Math.floor(data.h),
Math.floor(data.w)
);
} else {
frame = new engine.Rectangle(
Math.floor(data.x),
Math.floor(data.y),
Math.floor(data.w),
Math.floor(data.h)
);
}
//如果是被截掉过透明边界的
if (data.ox || data.oy) {
//其实就是在orig上切图,偏移
trim = new engine.Rectangle(
Math.floor(data.ox),
Math.floor(data.oy),
Math.floor(data.w),
Math.floor(data.h)
);
}
var texture = new engine.Texture(
baseTexture,
frame,
orig,
trim,
data.ro ? 2 : 0,
// data.anchor
);
//缓存下
engine.Texture.addToCache(texture, i);
textures[i] = texture;
frameIndex++;
}
return textures;
}
\ No newline at end of file
import BaseItem from "../../physics/BaseItem";
import { getJosnData, getJsonAsset } from "../JsonTools";
import { createTextureSheet } from "../createTextureSheet";
import { getTextureByName } from "../utils";
import LabelType from "../LabelType";
import MovieClip from "../../physics/MovieClip";
const createBoom = (scale) => {
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
let josnData = getJosnData('boom');
if(!josnData){
getJsonAsset('boom');
josnData = getJosnData('boom');
}
const boomTexture = createTextureSheet(getTextureByName('boom').baseTexture,josnData);
//炸弹纹理种炸弹的尺寸默认58,不进行缩放
//气泡和炸弹的比例为100/58
const animation = createMovieClip(boomTexture);
const baseItem = new BaseItem(animation, LabelType.boom);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem
}
const createMovieClip = (spritesheet, scale = 1) => {
const list = ['boom1.png', 'boom2.png', 'boom3.png', 'boom4.png', 'boom5.png', 'boom6.png', 'boom7.png', 'boom8.png', 'boom9.png', 'boom10.png'];
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip
}
export default createBoom
\ No newline at end of file
import BaseItem from "../../physics/BaseItem";
import { getJosnData, getJsonAsset } from "../JsonTools";
import { createTextureSheet } from "../createTextureSheet";
import { getTextureByName } from "../utils";
import LabelType from "../LabelType";
import MovieClip from "../../physics/MovieClip";
const createCandy = (scale) => {
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
let josnData = getJosnData('candy');
if(!josnData){
getJsonAsset('candy');
josnData = getJosnData('candy');
}
const boomTexture = createTextureSheet(getTextureByName('candy').baseTexture,josnData);
//炸弹纹理种炸弹的尺寸默认58,不进行缩放
//气泡和炸弹的比例为100/58
const animation = createMovieClip(boomTexture);
const baseItem = new BaseItem(animation, LabelType.candy);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem
}
const createMovieClip = (spritesheet, scale = 1) => {
const list = ['candy1.png', 'candy2.png', 'candy3.png', 'candy4.png', 'candy5.png', 'candy6.png', 'candy7.png', 'candy8.png'];
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 6,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip
}
export default createCandy
\ No newline at end of file
import BaseItem from "../../physics/BaseItem";
import LabelType from "../LabelType";
import MovieClip from "../../physics/MovieClip";
import { getTextureByName } from "../utils";
import { getJosnData, getJsonAsset } from "../JsonTools";
import { createTextureSheet } from "../createTextureSheet";
const createCoin = (scale) => {
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
let josnData = getJosnData('coin');
if(!josnData){
getJsonAsset('coin');
josnData = getJosnData('coin');
}
const texture = createTextureSheet(getTextureByName('coin').baseTexture,josnData);
const animation = createMovieClip(texture, 0.6);
const baseItem = new BaseItem(animation,LabelType.coin);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem
}
const createMovieClip = (spritesheet, scale = 1) => {
const list = ['coin1.png', 'coin2.png', 'coin3.png', 'coin4.png', 'coin5.png', 'coin6.png', 'coin7.png', 'coin8.png'];
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 6,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip
}
export default createCoin
\ No newline at end of file
import BaseItem from "../../physics/BaseItem";
import LabelType from "../LabelType";
import MovieClip from "../../physics/MovieClip";
import { getTextureByName } from "../utils";
import { getJosnData, getJsonAsset } from "../JsonTools";
import { createTextureSheet } from "../createTextureSheet";
const createEgg = (scale) => {
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
let josnData = getJosnData('egg');
if(!josnData){
getJsonAsset('gift');
josnData = getJosnData('egg');
}
const texture = createTextureSheet(getTextureByName('egg').baseTexture,josnData);
const animation = createMovieClip(texture, 0.6);
const baseItem = new BaseItem(animation,LabelType.egg);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem
}
const createMovieClip = (spritesheet, scale = 1) => {
const list = ['egg1.png', 'egg2.png', 'egg3.png', 'egg4.png', 'egg5.png', 'egg6.png', 'egg7.png', 'egg8.png', 'egg9.png'];
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip
}
export default createEgg
\ No newline at end of file
import BaseItem from "../../physics/BaseItem";
import LabelType from "../LabelType";
import MovieClip from "../../physics/MovieClip";
import { getTextureByName } from "../utils";
import { getJosnData, getJsonAsset } from "../JsonTools";
import { createTextureSheet } from "../createTextureSheet";
const createGift = (scale) => {
//气泡纹理种气泡的尺寸默认100(总体还包含气泡周围的阴影效果)
let josnData = getJosnData('gift');
if(!josnData){
getJsonAsset('gift');
josnData = getJosnData('gift');
}
const texture = createTextureSheet(getTextureByName('gift').baseTexture,josnData);
const animation = createMovieClip(texture, 0.6);
const baseItem = new BaseItem(animation,LabelType.gift);
baseItem.scaleX = baseItem.scaleY = scale;
return baseItem
}
const createMovieClip = (spritesheet, scale = 1) => {
const list = ['gift1.png', 'gift2.png', 'gift3.png', 'gift4.png', 'gift5.png', 'gift6.png', 'gift7.png', 'gift8.png', 'gift9.png', 'gift10.png'];
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: 5,
frames: list,
position: [0, 0],
scale: scale,
anchor: [.5, .5]
});
return movieclip
}
export default createGift
\ No newline at end of file
/**
* Created by rockyl on 2020-02-03.
*/
// import ObjectPool = engine.ObjectPool;
// export const PoolName: string = 'goods';
// ObjectPool.registerPool(PoolName, function () {
// return new Goods();
// }, function (item: Goods, data) {
// item.reset();
// });
import MovieClip from "../physics/MovieClip";
import wait from "./wait";
import { getJosnData, getJsonAsset } from "./JsonTools";
import { createTextureSheet } from "./createTextureSheet";
import { getTextureByName } from "./utils";
export async function playMovieClip (parent: engine.Container, key, frames, frameInterval = 5){
return new Promise(async (r) => {
let josnData = getJosnData(key);
if(!josnData){
getJsonAsset(key);
josnData = getJosnData(key);
}
let texture = createTextureSheet(getTextureByName(key).baseTexture,josnData);
if (texture) {
await createMc(parent, texture, frames, frameInterval);
r(1);
}
else {
//RES.getResAsync(key);
wait(300).then(async () => {
let josnData = getJosnData(key);
if(!josnData){
getJsonAsset(key);
josnData = getJosnData(key);
}
texture = createTextureSheet(getTextureByName(key).baseTexture,josnData);
if (texture) {
await createMc(parent, texture, frames, frameInterval);
r(1);
} else
r(0);
})
}
});
}
export function createMc(parent: engine.Container, spritesheet, frames: any[], frameInterval = 5) {
return new Promise((r) => {
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: frameInterval,
frames: frames,
position: [0, 150],
scale: 1,
anchor: [0, 0],
loop: false,
callBack:()=>{
setTimeout(() => {
parent.removeChild(movieclip);
r(1)
}, 100);
}
});
parent.addChild(movieclip);
// setTimeout(() => {
// parent.removeChild(movieclip);
// r(1)
// }, 1000);
// movieclip.once('boomOver', () => {
// parent.removeChild(movieclip);
// r(1)
// }, this,true)
})
}
export const playBoom = (parent) => {
return playMovieClip(parent, 'fail', ['fail1.png', 'fail2.png', 'fail3.png', 'fail4.png', 'fail5.png', 'fail6.png', 'fail7.png', 'fail8.png'], 5);
}
export const playSuccess = (parent) => {
return playMovieClip(parent, 'success', ['success1.png', 'success2.png', 'success3.png', 'success4.png', 'success5.png', 'success6.png', 'success7.png', 'success8.png', 'success9.png'], 5);
}
\ No newline at end of file
const clear = (that) => {
TextList.forEach(i => {
engine.Tween.removeTweens(that.gameHint[i]);
that.gameHint[i].alpha = 0;
})
}
const playgood = (image: engine.Image) => {
engine.Tween.get(image).set({ x: 750, alpha: 1 }).to({ x: 530.5 }, 100).wait(500).to({ alpha: 0 }, 200)
}
const playgreat = (image: engine.Image) => {
engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 20 }).to({ x: 540.5, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(2)).wait(500).to({ alpha: 0 }, 200)
}
const playcool = (image: engine.Image) => {
engine.Tween.get(image).set({ x: 750, alpha: 1, scaleX: .9, scaleY: .9, rotation: 60 }).to({ x: 526.09, scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(7)).wait(500).to({ alpha: 0 }, 200)
}
const playperfect = (image: engine.Image) => {
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, }).to({ scaleX: 1, scaleY: 1 }, 200, engine.Ease.getBackOut(10)).wait(500).to({ alpha: 0 }, 200)
// egret.Tween.get(image).set({ x: 750, alpha: 1 }).to({ x: 530.5 }, 100).wait(500).to({ alpha: 0 }, 200)
}
const playawesome = (image: engine.Image) => {
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -20 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(20)).wait(500).to({ alpha: 0 }, 200)
// egret.Tween.get(image).set({ x: 750, alpha: 1 }).to({ x: 527 }, 100).wait(500).to({ alpha: 0 }, 200)
}
const playunbelievable = (image: engine.Image) => {
// egret.Tween.get(image).set({ x: 750, alpha: 1 }).to({ x: 482.5 }, 100).wait(500).to({ alpha: 0 }, 200)
engine.Tween.get(image).set({ scaleX: 0, scaleY: 0, alpha: 1, rotation: -60 }).to({ scaleX: 1, scaleY: 1, rotation: 0 }, 200, engine.Ease.getBackOut(40)).wait(500).to({ alpha: 0 }, 200)
}
const funcs = [playgreat, playcool, playperfect, playawesome, playunbelievable];
// const funcs = [playgood, playgreat, playcool, playperfect, playawesome, playunbelievable];
let cdtimer;
// let timer = 0;
let count = 0;
export const playTextAni = async (that) => {
clear(that);
count++;
if (count >= TextList.length) count = TextList.length;
console.log(count);
const image = that.gameHint[TextList[count - 1]];
image.visible = true;
funcs[count - 1](image);
if (cdtimer > 0) clearTimeout(cdtimer);
cdtimer = setTimeout(() => {
count = 0;
console.log('clear')
}, 5000);
}
export const TextList = ['great', 'cool', 'perfect', 'awesome', 'unbelievable']
// export const TextList = ['good', 'great', 'cool', 'perfect', 'awesome', 'unbelievable']
\ No newline at end of file
import { bubbleStandbyGroup, bubbleStandby, bubbleStandbyMask } from "./collisionConfig";
import createBubblePic from "./createBubblePic";
import EgretRender from "../physics/EgretRender";
let timerLeft;
let timerRight;
export const startStandbyBubblesLeft = (egretRender: EgretRender) => {
timerLeft = setInterval(() => {
const scale = 0.2;
const p1 = { x: 180, y: 1050 };
const r = random(8, 10);
const bubblePic = createBubblePic(r);
const body = egretRender.circle(p1.x, p1.y, r, bubblePic, {
restitution: 0,
frictionAir: 0,
force: { x: random(-0.005, 0.005) * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }
});
setTimeout(() => {
egretRender.remove(body);
}, 1000);
}, 700);
}
export const startStandbyBubblesRight = (egretRender: EgretRender) => {
timerRight = setInterval(() => {
const scale = 0.2;
const p2 = { x: 560, y: 1050 };
const r2 = random(8, 10);
const bubblePic2 = createBubblePic(r2);
const body2 = egretRender.circle(p2.x, p2.y, r2, bubblePic2, {
restitution: 0,
frictionAir: 0,
force: { x: random(-0.005, 0.005) * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }
});
setTimeout(() => {
egretRender.remove(body2);
}, 1000);
}, 700);
}
export const stopStandbyBubblesLeft = () => {
clearInterval(timerLeft)
}
export const stopStandbyBubblesRight = () => {
clearInterval(timerRight)
}
const random = (start, end) => {
const n = end - start;
return Math.random() * n + start;
}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
import {props} from '../props'
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = "asset://" + engine.getAssetByName(name).uuid;
return inst;
}
export function getIndexFromRC(row, col, maxCol) {
let index;
index = row * maxCol + col;
return index;
}
export function getRandomArray(array) {
array.sort(function () {
return 0.5 - Math.random();
});
}
export default (view: engine.DisplayObject,count=2,strength=10) => {
return new Promise((r) => {
const pos = [
{ x: strength, y: 0 },
{ x: 0, y: -strength },
{ x: -strength, y: 0 },
{ x: 0, y: strength },
{ x: 0, y: 0 },
];
let list = [];
for (let i = 0; i < count; i++) {
list = list.concat(pos);
}
const x0 = view.x;
const y0 = view.y;
let counter = list.length;
for (let i = 0; i < list.length; i++) {
const element = list[i];
setTimeout(() => {
view.x = element.x + x0;
view.y = element.y + y0;
counter--;
if (counter == 0) {
view.x = x0;
view.y = y0;
r();
};
}, 1000 / 60 * i);
}
});
}
const wait = async (duration: number) =>
new Promise(
resolve => setTimeout(resolve, duration)
);
export default wait
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
{
"coin1.png": {
"x": 111,
"y": 113,
"w": 109,
"h": 110,
"ox": 3,
"oy": 2,
"sw": 115,
"sh": 115,
"ro": false
},
"coin2.png": {
"x": 111,
"y": 0,
"w": 109,
"h": 111,
"ox": 3,
"oy": 2,
"sw": 115,
"sh": 115,
"ro": false
},
"coin3.png": {
"x": 96,
"y": 225,
"w": 94,
"h": 113,
"ox": 10,
"oy": 1,
"sw": 115,
"sh": 115,
"ro": false
},
"coin4.png": {
"x": 67,
"y": 340,
"w": 65,
"h": 113,
"ox": 25,
"oy": 1,
"sw": 115,
"sh": 115,
"ro": false
},
"coin5.png": {
"x": 222,
"y": 0,
"w": 24,
"h": 108,
"ox": 45,
"oy": 3,
"sw": 115,
"sh": 115,
"ro": false
},
"coin6.png": {
"x": 0,
"y": 229,
"w": 65,
"h": 114,
"ox": 25,
"oy": 0,
"sw": 115,
"sh": 115,
"ro": false
},
"coin7.png": {
"x": 0,
"y": 114,
"w": 94,
"h": 113,
"ox": 10,
"oy": 1,
"sw": 115,
"sh": 115,
"ro": false
},
"coin8.png": {
"x": 0,
"y": 0,
"w": 109,
"h": 112,
"ox": 3,
"oy": 1,
"sw": 115,
"sh": 115,
"ro": false
}
}
\ No newline at end of file
import { getTextureByName } from "../game/utils";
import LabelType from "../game/LabelType";
import MovieClip from "./MovieClip";
export default class BaseItem extends engine.Sprite {
_mc: MovieClip;
type: LabelType;
constructor(mc: MovieClip, type?: LabelType) {
super();
this.type = type;
this._mc = mc;
const bubble: engine.Texture = getTextureByName('bubble');
const bubblePic = new engine.Sprite(bubble);
bubblePic.anchorTexture.set(0.5,0.5);
//bubblePic.anchorX = 76;
//bubblePic.anchorY = 78;
//bubblePic.x = bubblePic.x-76
//bubblePic.y = bubblePic.y-78
this._mc.anchorTexture.set(0.5,0.5)
this._mc.x = bubblePic.x/4;
this._mc.y = bubblePic.y/4;
this.addChild(bubblePic);
this.addChild(this._mc);
}
get mc() { return this._mc; }
}
\ No newline at end of file
import BaseItem from "./BaseItem";
export default class EgretRender {
_root: engine.Sprite;
private _engine: Matter.Engine;
constructor(root: engine.Sprite, engine: Matter.Engine) {
this._root = root;
this._engine = engine;
}
addBody(body: Matter.Body, display: engine.DisplayObject, x, y) {
if (display) {
body['display'] = display;
this._root.addChildAt(display, 0);
display.x = x;
display.y = y;
}
return body;
}
remove(body: Matter.Body): any {
this.removeBody(body);
this.removeDisplay(body);
}
removeBody(body: Matter.Body): any {
Matter.World.remove(this._engine.world, body);
}
removeDisplay(body: Matter.Body): any {
const display: engine.DisplayObject = body['display'];
if (display && display.parent)
display.parent.removeChild(display);
}
run() {
const bodies = Matter.Composite.allBodies(this._engine.world);
// tslint:disable-next-line:prefer-for-of
for (let i = 0; i < bodies.length; i++) {
const body = bodies[i];
const display = body['display'] as engine.DisplayObject;
if (!display) continue;
// 贴图与刚体位置的小数点后几位有点不一样,需要降低精度
const x1 = Math.round(display.x)
const x2 = Math.round(body.position.x)
const y1 = Math.round(display.y)
const y2 = Math.round(body.position.y)
const distanceX = Math.abs(x1 - x2);
const distanceY = Math.abs(y1 - y2);
const precision = 1;//精度
if (distanceX > precision || distanceY > precision) {
if (display instanceof BaseItem) display.mc.resume();
} else {
if (display instanceof BaseItem) display.mc.pause();
}
display.x = body.position.x;
display.y = body.position.y;
display.rotation = this.getRotation(body.angle);
}
}
//快速方法
rectangle(x: number, y: number, width: number, height: number, display: engine.DisplayObject, options?: Matter.IChamferableBodyDefinition) {
const body = this.rectangleToRender(x, y, width, height, display, options);
this.addBodyToWorld(body);
return body;
}
circle(x: number, y: number, radius: number, display: engine.DisplayObject, options?: Matter.IChamferableBodyDefinition) {
const body = this.circleToRender(x, y, radius, display, options);
this.addBodyToWorld(body);
return body;
}
//工具方法
private addBodyToWorld(body: Matter.Body) {
Matter.World.add(this._engine.world, body);
return body;
}
private rectangleToRender(x: number, y: number, width: number, height: number, display: engine.DisplayObject, options?: Matter.IChamferableBodyDefinition) {
const body = Matter.Bodies.rectangle(x, y, width, height, options);
this.addBody(body, display, x, y);
return body;
}
private circleToRender(x: number, y: number, radius: number, display: engine.DisplayObject, options?: Matter.IChamferableBodyDefinition) {
const body = Matter.Bodies.circle(x, y, radius, options);
this.addBody(body, display, x, y);
return body;
}
private getRotation(angle: number) {
return angle / Math.PI / 2 * 360;
}
}
\ No newline at end of file
export default class MovieClip extends engine.Image {
textures: engine.Texture[];
frames: string[];
keys: string[];
autoplay: boolean;
loop: boolean;
anchorXtmp: number;
anchorYtmp: number;
currentFrame: number;
frameInterval: number;
counter: number;
scale: number;
_callBack:any;
constructor({ spritesheet, frames, scale, position, keys = null, autoplay = true, loop = true, anchor, frameInterval = 1 ,callBack=null}) {
super();
this.frames = frames;
this.frameInterval = frameInterval;
this.keys = keys;
this.autoplay = autoplay;
this.loop = loop;
this.anchorXtmp = anchor;
this.anchorYtmp = anchor;
this._callBack = callBack;
if (Array.isArray(anchor)) {
this.anchorXtmp = anchor[0];
this.anchorYtmp = anchor[1];
}
this.x = position[0];
this.y = position[1];
this.spritesheet = spritesheet;
if (this.autoplay) {
this.play();
}
this.scaleX = this.scaleY = scale;
}
pause() {
//egret.stopTick(this.onTick, this);
this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this)
}
resume() {
//egret.startTick(this.onTick, this);
this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this)
}
play(start = 0) {
this.goto(start);
this.currentFrame = 0;
this.counter = 0;
//egret.startTick(this.onTick, this);
this.addEventListener(engine.Event.ENTER_FRAME, this.onTick, this)
}
goto(frame: number) {
this.texture = this.textures[frame];
}
onTick() {
this.counter++;
if (this.counter == this.frameInterval) {
this.counter = 0;
this.currentFrame++;
this.goto(this.currentFrame);
if (this.currentFrame == this.frames.length - 1) {
if (this.loop) {
this.currentFrame = 0;
} else {
this.stop();
//true
if(this._callBack){
this._callBack();
this._callBack = null
}
//this.dispatchEvent('boomOver',null,true)
}
}
}
return false;
}
stop() {
this.currentFrame = 0;
this.removeEventListener(engine.Event.ENTER_FRAME, this.onTick, this)
//egret.stopTick(this.onTick, this);
}
set spritesheet(value) {
//this.frames.map(frame => value.getTexture(frame));
this.textures = this.frames.map(frame => value[frame]);
this.anchorTexture.set(this.anchorXtmp,this.anchorYtmp)
}
private get textureItemWidth() { return this.textures[0].width }
private get textureItemHeight() { return this.textures[0].height }
}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
var fs = require("fs");
var readPath = "./src/json/";
var writePath = "./src/json/"
//取指令后的参数
let arg = process.argv.splice(2);
//json名字
var jsonName = arg[0];
var data = fs.readFileSync(readPath + jsonName + ".json");
//反序列化
data = JSON.parse(data);
let frames = data.frames;
var obj = {};
for (var key in frames) {
let f = frames[key];
obj[jsonName + key + ".png"] = {
"x": f.x,
"y": f.y,
"w": f.w,
"h": f.h,
"ox": f.offX,
"oy": f.offY,
"sw": f.sourceW,
"sh": f.sourceH,
"ro": false,
}
}
//写入
fs.writeFileSync(writePath + jsonName + ".json", JSON.stringify(obj, "", "\t"));
\ No newline at end of file
......@@ -15,7 +15,7 @@
},
"include": [
"libs",
"src"
"src", "src/custom/seabed-game/debug/matter.min.js"
],
"exclude": [
"node_modules"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment