diff --git a/CNAME b/CNAME deleted file mode 100644 index c4e5e3b..0000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -cat.davidmiller.top \ No newline at end of file diff --git a/catch-the-cat.js b/catch-the-cat.js index 849a7b6..d0a762f 100644 --- a/catch-the-cat.js +++ b/catch-the-cat.js @@ -1,4 +1,4 @@ -!function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var o,r=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i,s=n(1),a=n(20),l=n(22),d=n(23),h=n(24),u=n(25),f=n(2),p=n(26),c=n(27);!function(t){t.PLAYING="playing",t.WIN="win",t.LOSE="lose"}(i||(i={}));var k=function(t){function e(e,n,o){var r=t.call(this,{key:"MainScene"})||this;return r.w=e,r.h=n,r.r=o,r.dx=2*r.r,r.dy=r.r*Math.sqrt(3),r}return r(e,t),Object.defineProperty(e.prototype,"blocks",{get:function(){return this.data.get("blocks")},set:function(t){this.data.set("blocks",t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blocksData",{get:function(){var t=[];return this.blocks.forEach(function(e,n){t[n]=[],e.forEach(function(e,o){t[n][o]=e.isWall})}),t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cat",{get:function(){return this.data.get("cat")},set:function(t){this.data.set("cat",t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"statusBar",{get:function(){return this.data.get("status_bar")},set:function(t){this.data.set("status_bar",t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"creditText",{get:function(){return this.data.get("credit_text")},set:function(t){this.data.set("credit_text",t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this.data.get("state")},set:function(t){switch(t){case i.PLAYING:break;case i.LOSE:this.setStatusText(f.default("猫已经跑到地图边缘了,你输了"));break;case i.WIN:this.setStatusText(f.default("猫已经无路可走,你赢了"));break;default:return}this.data.set("state",t)},enumerable:!0,configurable:!0}),e.getNeighbours=function(t,e){var n,o,r,i,s={i:t-1,j:e},a={i:t+1,j:e};0==(1&e)?(n={i:t-1,j:e-1},o={i:t,j:e-1},r={i:t-1,j:e+1},i={i:t,j:e+1}):(n={i:t,j:e-1},o={i:t+1,j:e-1},r={i:t,j:e+1},i={i:t+1,j:e+1});var l=[];return l[0]=s,l[1]=n,l[2]=o,l[3]=a,l[4]=i,l[5]=r,l},e.prototype.preload=function(){var t=this.r/s.default.catStepLength;for(var e in s.default.textures)this.load.addFile(new c.default(this.load,e,s.default.textures[e],{scale:t}))},e.prototype.create=function(){this.createAnimations(),this.createBlocks(),this.createCat(),this.createStatusText(),this.createResetButton(),this.createCreditText(),this.reset(),this.game.solver&&(this.cat.solver=this.game.solver)},e.prototype.getPosition=function(t,e){return{x:3*this.r+(0==(1&e)?this.r:this.dx)+t*this.dx,y:3*this.r+this.r+e*this.dy}},e.prototype.getBlock=function(t,e){return t>=0&&t=0&&e=0&&t=0&&e\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e){t.exports='\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'},function(t,e,n){"use strict";var o,r=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),s=n(1),a=n(21),l=function(t){function e(e){var n=t.call(this,e,0,0,"__DEFAULT")||this;return n.on("animationrepeat",function(){n.moveForward()}),n.solver=a.default,n.direction=s.default.catDefaultDirection,n.reset(),n}return r(e,t),Object.defineProperty(e.prototype,"i",{get:function(){return this.getData("i")},set:function(t){this.setData("i",t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"j",{get:function(){return this.getData("j")},set:function(t){this.setData("j",t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"direction",{get:function(){return this.getData("direction")},set:function(t){this.setData("direction",t),this.resetTextureToStop(),this.resetOriginAndScale()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"solver",{get:function(){return this.getData("solver")},set:function(t){this.setData("solver",t)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.anims.stop(),this.direction=s.default.catDefaultDirection,this.resetIJ()},e.prototype.step=function(){var t=this.solver.call(this,this.scene.blocksData,this.i,this.j);return t<0||t>6?(this.caught(),!1):!!this.stepDirection(t)||(this.caught(),!1)},e.prototype.isCaught=function(){var t=this;return!this.getCurrentNeighbours().some(function(e,n){var o=t.scene.getBlock(e.i,e.j);return null!==o&&!o.isWall})},e.prototype.caught=function(){this.setTexture(s.default.cannotEscapeTextures[s.default.directions[this.direction].name])},e.prototype.escape=function(){0===this.j||this.j===this.scene.h-1?this.runForward():0===this.i?this.runDirection(0):this.i===this.scene.w-1&&this.runDirection(3)},e.prototype.setIJ=function(t,e){this.i=t,this.j=e;var n=this.scene.getPosition(t,e);return this.setPosition(n.x,n.y)},e.prototype.resetIJ=function(){this.setIJ(Math.floor(this.scene.w/2),Math.floor(this.scene.h/2))},e.prototype.isEscaped=function(){return this.i<=0||this.i>=this.scene.w-1||this.j<=0||this.j>=this.scene.h-1},e.prototype.checkState=function(){this.isEscaped()?(this.escape(),this.emit("escaped")):this.isCaught()&&(this.caught(),this.emit("win"))},e.prototype.getCurrentNeighbours=function(){return i.default.getNeighbours(this.i,this.j)},e.prototype.resetTextureToStop=function(){this.setTexture(s.default.stopTextures[s.default.directions[this.direction].name])},e.prototype.resetOriginAndScale=function(){var t=s.default.directions[this.direction],e=s.default.origins[t.name];this.setOrigin(e.x,e.y),this.scaleX=t.scaleX},e.prototype.moveForward=function(){var t=this.getCurrentNeighbours()[this.direction];this.setIJ(t.i,t.j),this.checkState()},e.prototype.stepForward=function(){var t=this,e=this.getCurrentNeighbours()[this.direction],n=this.scene.getBlock(e.i,e.j);return null!==n&&(!n.isWall&&(this.play(s.default.directions[this.direction].name+"_step"),this.once("animationcomplete",function(){t.moveForward(),t.resetTextureToStop()}),!0))},e.prototype.stepDirection=function(t){return this.direction=t,this.stepForward()},e.prototype.runForward=function(){this.play(s.default.directions[this.direction].name+"_run")},e.prototype.runDirection=function(t){this.direction=t,this.runForward()},e}(Phaser.GameObjects.Sprite);e.default=l},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(0);e.default=function(t,e,n){var r=-1;return o.default.getNeighbours(e,n).forEach(function(e,n){-1===r&&(void 0===t[e.i]||void 0===t[e.i][e.j]||t[e.i][e.j]||(r=n))}),r}},function(t,e,n){"use strict";var o,r=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=function(t){function e(e,n,o,r){var i=this,s=e.getPosition(n,o);(i=t.call(this,e,s.x,s.y,r,0,360,!1,0,1)||this).i=n,i.j=o,i.r=r,i.isWall=!1;var a=new Phaser.Geom.Circle(i.r/2,i.r/2,i.r);return i.setInteractive(a,Phaser.Geom.Circle.Contains),i.on("pointerdown",function(){i.emit("player_click",i.i,i.j)}),i}return r(e,t),Object.defineProperty(e.prototype,"isWall",{get:function(){return this._isWall},set:function(t){this._isWall=t,this.fillColor=t?13158:11786751},enumerable:!0,configurable:!0}),e}(Phaser.GameObjects.Arc);e.default=i},function(t,e,n){"use strict";var o,r=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=n(2),s=function(t){function e(e){var n=t.call(this,e,0,0,i.default("重置"),{})||this;n.setColor("#000000");var o=e.r;n.setFontSize(o),n.setPadding(o,o,o,o),n.setPosition(0,e.game.canvas.height),n.setOrigin(0,1);var r=new Phaser.Geom.Rectangle(0,0,n.width,n.height);return n.setInteractive(r,Phaser.Geom.Rectangle.Contains),n}return r(e,t),e}(Phaser.GameObjects.Text);e.default=s},function(t,e,n){"use strict";var o,r=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=function(t){function e(e){var n=t.call(this,e,0,0,"",{})||this;n.setColor("#000000");var o=e.r;return n.setFontSize(o),"center"===e.game.myConfig.statusBarAlign&&(n.setX(e.game.canvas.width/2),n.setOrigin(.5,0)),n.setPadding(o,o,o,o),n}return r(e,t),e}(Phaser.GameObjects.Text);e.default=i},function(t,e,n){"use strict";var o,r=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=function(t){function e(e){var n=t.call(this,e,0,0,"",{})||this;n.setColor("#000000"),n.setPosition(e.game.canvas.width,e.game.canvas.height),n.setOrigin(1,1);var o=e.r;return n.setFontSize(.8*o),n.setPadding(o,o,o,o),n.setText(e.game.myConfig.credit),n}return r(e,t),e}(Phaser.GameObjects.Text);e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),r=function(){function t(t,e,n,o){this.i=e,this.j=n,this.isWall=o,this.distance=1/0,this.parent=t,this.isEdge=this.i<=0||this.i>=this.parent.w-1||this.j<=0||this.j>=this.parent.h-1}return Object.defineProperty(t.prototype,"routesCount",{get:function(){var t=this;if(void 0===this._routesCount)if(this.isEdge)this._routesCount=1;else{var e=0;this.neighbours.forEach(function(n){null===n||n.isWall||n.distancee&&(e=r.routesCount,n=o)}),n},enumerable:!0,configurable:!0}),t}(),i=function(){function t(t){var e=this;if(this.w=t.length,this.w<=0)throw new Error("empty blocks");this.h=t[0].length,this.blocks=t.map(function(n,o){return n.map(function(n,i){return new r(e,o,i,t[o][i])})})}return t.prototype.getBlock=function(t,e){return t>=0&&t=0&&ee.distance+1&&(n.distance=e.distance+1,t.indexOf(n)<0&&t.push(n))})};t.length>0;)e()},t.prototype.toString=function(){for(var t=[],e=0;e0?r[0]:-1},e.default=function(t,e,n){var o=new i(t);return o.calcAllDistances(),o.getBlock(e,n).direction}},function(t,e,n){"use strict";var o,r=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=n(28),s=function(t){function e(e,n,o,r){var i=t.call(this,e,n,void 0,r)||this;return i.rawData=o,i}return r(e,t),e.prototype.load=function(){this.state===Phaser.Loader.FILE_POPULATED?this.loader.nextFile(this,!0):this.xhrLoader=i.default(this,this.loader.xhr)},e}(Phaser.Loader.FileTypes.SVGFile);e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(29);e.default=function(t,e){var n=new o.default;return n.open("GET",t.src,e.async,e.user,e.password),n.responseType=t.xhrSettings.responseType,n.timeout=e.timeout,e.header&&e.headerValue&&n.setRequestHeader(e.header,e.headerValue),e.requestedWith&&n.setRequestHeader("X-Requested-With",e.requestedWith),e.overrideMimeType&&n.overrideMimeType(e.overrideMimeType),n.onload=t.onLoad.bind(t,n),n.onerror=t.onError.bind(t),n.onprogress=t.onProgress.bind(t),n.send(),setTimeout(function(){n.respond(200,{"Content-Type":"application/octet-stream"},t.rawData)},1),n}},function(t,e,n){"use strict";n.r(e); diff --git a/index.html b/index.html index 23901db..14cc02c 100644 --- a/index.html +++ b/index.html @@ -21,6 +21,7 @@ +