forked from mtmckenna/convoirl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1 lines (1 loc) · 43.6 KB
/
index.html
1
<!doctype html><title>Convo IRL</title><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"><style>*{width:100%;height:100%;margin:0;padding:0;image-rendering:pixelated;image-rendering:optimizeSpeed;overflow:hidden}</style><canvas id="game"></canvas><script>(function () {var b={};Object.defineProperty(b,"__esModule",{value:!0});var kb=8;b.TS=kb;var rd=1/60;b.MS=rd;var qd=8;b.LS=qd;var pd=120;b.TT=pd;var md=5;b.LH=md;var kd="*LISTEN*";b.LT=kd;var gd={h:3*b.LH+2*b.LS,w:12*b.LH};b.BS=gd;var q={};function bb(e,$,r){return(1-r)*e+r*$}Object.defineProperty(q,"__esModule",{value:!0});var E=bb;function Da(e,$,r){return Math.max(Math.min(e,r),$)}q.lerp=E;var qa=Da;function fd(e,$,r,t,o){return Da(bb(e,$,o),r,t)}q.clamp=qa;var u=fd;function cd(e){return[].concat.apply([],e)}q.clerp=u;var Z=cd;function _c(e){return Math.floor(Math.random()*e.length)}q.flatten=Z;var I=_c;function $c(e,$){var r=$.indexOf(e);return r>-1&&($.splice(r,1),!0)}q.randomIndex=I;var ja=$c;function Yc(e,$){var r;return function(){var t=arguments;r||(e.apply(this,t),r=!0,setTimeout(function(){return r=!1},$))}}q.removeElement=ja;var W=Yc;q.throttle=W;var e={};Object.defineProperty(e,"__esModule",{value:!0});var Uc=["#3e2d2e","#eeeec7","#96c083","#5fa367","#eeeec7","#dec26d","#6e4c49","#3e625e","#4c547a","#66ccff","#ac4136"];e.default=Uc;var M={},Tc=M&&M.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(M,"__esModule",{value:!0});var Mc=Tc(e),Jc=function(){function t(t){this.size={w:1,h:1},this.pos={x:0,y:0},this.color=Mc.default[1],this.visible=!1,this.alpha=1,this.percentGrown=0,this.game=t,this.dSize={h:this.size.h*this.game.ss,w:this.size.w*this.game.ss}}return t.prototype.reJuice=function(t,e,i){this.pos.x=e,this.pos.y=i,this.percentGrown=0,this.startTime=t,this.visible=!0},t.prototype.update=function(t){this.visible&&(this.percentGrown=(t-this.startTime)/1500,this.visible=!(this.percentGrown>=1),this.alpha=u(.3,0,0,.3,this.percentGrown))},t.prototype.draw=function(t){var e=u(1,3,1,3,this.percentGrown);t.globalAlpha=this.alpha,t.fillStyle=this.color,t.fillRect(-this.dSize.w*e/2,-this.dSize.h*e/2,this.dSize.w*e,this.dSize.h*e)},t}(),Ic=Jc;M.default=Ic;var H={},Hc=H&&H.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(H,"__esModule",{value:!0});var Gc=Hc(M),Fc=2,Cc=1,Bc=4,Ac=1,yc=4,xc=6,Sa=["#94725d","#bfa17a","#eeeec7","#5a444e","#cd9957","#3e2d2e"],wc=function(){function t(t){var i=this;this.pos={x:0,y:0},this.size={h:b.TS,w:b.TS},this.visible=!0,this.skills=[],this.a={},this.tileIndex={x:0,y:0},this.energy=1,this.talking=!1,this.lastConvo=0,this.rot=Math.PI,this.lastDustAt=0,this.inConvoMode=!1,this.convoLookRight=!1,this.game=t;this.a.blinking={duration:300,minTimeDelta:3e3,openness:1,percentChance:.5,running:!1,startTime:0},this.a.lookAway={duration:0,minTimeDelta:1e3,offset:0,percentChance:.008,running:!1,startTime:0},this.stop(),this.color=Sa[I(Sa)],this.dusts=Array.from(Array(50).keys()).map(function(){return new Gc.default(i.game)}),this.dSize={h:b.TS*this.game.ss,w:b.TS*this.game.ss},this.squareSize=this.game.ss,this.rando=100*Math.random()}return Object.defineProperty(t.prototype,"walking",{get:function(){return this.a.walking.running},enumerable:!0,configurable:!0}),t.prototype.copy=function(){var i=new t(this.game);return i.move(this.pos),i.color=this.color,i.skills=this.skills,i},t.prototype.setConvoMode=function(t,i){this.inConvoMode=t,this.rot=Math.PI,this.squareSize=this.game.ss,this.size.w=b.TS,this.size.h=b.TS,this.dSize.w=this.size.w*this.game.ss,this.dSize.h=this.size.h*this.game.ss,t?(this.squareSize*=2,this.size.w*=2,this.size.h*=2,this.dSize.w*=2,this.dSize.h*=2,this.a.walking.tw=0):this.talking=!1,this.convoLookRight="right"===i},t.prototype.stop=function(){this.a.walking={duration:250,endPos:{x:0,y:0},running:!1,startPos:{x:-1,y:-1},startTime:0,t:0,tw:0}},t.prototype.move=function(t){this.pos.x=t.x,this.pos.y=t.y,this.tileIndex.x=Math.round(this.pos.x/b.TS),this.tileIndex.y=Math.round(this.pos.y/b.TS)},t.prototype.look=function(t){this.walk(t,!0)},t.prototype.walk=function(t,i){void 0===i&&(i=!1);var a=this.pos,s=a.x,e=a.y;switch(t){case"left":this.rot=-Math.PI/2,s-=b.TS;break;case"right":this.rot=Math.PI/2,s+=b.TS;break;case"down":this.rot=Math.PI,e+=b.TS;break;case"up":this.rot=0,e-=b.TS;}if(!i&&!this.walking){var n={x:this.pos.x,y:this.pos.y},o={x:s,y:e};return!!jb.call(this,o)&&(this.configureWalkingAnimation(n,o),!0)}},t.prototype.configureWalkingAnimation=function(t,i){var a=this.a.walking;a.startTime=this.game.tstamp,a.endPos=i,a.startPos=t,a.running=!0,a.t=0},t.prototype.update=function(t){if(this.autoWalkDirection&&this.walk(this.autoWalkDirection),-1!==this.a.walking.startPos.x){var i=(t-this.a.walking.startTime)/this.a.walking.duration,a=E(this.a.walking.startPos.x,this.a.walking.endPos.x,i),s=E(this.a.walking.startPos.y,this.a.walking.endPos.y,i);this.a.walking.t=i,i>=1?(a=this.a.walking.endPos.x,s=this.a.walking.endPos.y,this.a.walking.running=!1,this.a.walking.t=0,this.a.walking.tw=Math.max(this.a.walking.tw-100*b.MS,0)):this.a.walking.tw=Math.min(this.a.walking.tw+100*b.MS,this.a.walking.duration),this.move({x:a,y:s})}},t.prototype.draw=function(t,i){t.translate(this.dSize.w/2,this.dSize.h/2),t.rotate(this.rot),t.translate(-this.dSize.w/2,-this.dSize.h/2),t.fillStyle=this.color,t.fillRect(0,0,this.dSize.w,this.dSize.h);var a=this.a.walking.tw/this.a.walking.duration,s=t.createLinearGradient(0,this.dSize.h,0,1.5*this.dSize.h);if(s.addColorStop(0,this.color),s.addColorStop(a,"rgba(150, 192, 131, 0)"),t.fillStyle=s,t.fillRect(0,0,this.dSize.w,1.5*this.dSize.h),rc.call(this,i),ab.call(this,t,"left",this.a.blinking.openness,this.a.lookAway.offset),ab.call(this,t,"right",this.a.blinking.openness,this.a.lookAway.offset),this.talking){t.fillStyle="#000";var e=Math.sin(i/80+this.rando)+1;t.fillRect((this.convoLookRight?1:5)*this.squareSize,this.squareSize+e/4,2*this.squareSize+e,2*this.squareSize*e/2)}if(this.walking&&i-this.lastDustAt>30){var n=this.dusts.find(function(t){return!t.visible});if(n){var o=this.size.w/2*Math.random()+this.size.w/4,r=this.size.h/2*Math.random()+this.size.h/4,$=this.pos.x+o,h=this.pos.y+r;n.reJuice(i,$,h),this.lastDustAt=i}}},t}(),tc=wc;function rc(t){var i=this.a,a=i.blinking,s=i.lookAway;eb(a,t)&&(a.running=!0,a.startTime=t),eb(s,t)&&(s.running=!0,s.startTime=t),pc.call(this,a,t),qc.call(this,s)}function qc(t){t.running&&(t.offset=0===t.offset?1:0,t.running=!1)}function pc(t,i){var a=(i-t.startTime)/t.duration;t.openness=nc(a,0,1,!0),a>=1&&(t.running=!1)}function ab(t,i,a,s){var e="left"===i?0:Bc*this.squareSize;t.fillStyle="#000";var n=Ac,o=0;this.inConvoMode&&(n=yc),this.inConvoMode&&this.convoLookRight&&(o=xc*this.squareSize);var r=n*this.squareSize,$=Fc*this.squareSize,h=Cc*this.squareSize;t.fillRect(r+e-o,r,$,$*a),t.fillStyle="#fff",t.fillRect(r+e+s*this.squareSize-o,r,h,h*a)}function jb(t){var i=this.game.cl,a=t.x>=0&&t.x<=i.size.w-this.size.w&&t.y>=0&&t.y<i.size.h,s=t.x,e=t.y;return s/=b.TS,e/=b.TS,a&&i.tiles[this.game.cl.size.w/b.TS*e+s].wable}function eb(t,i){if(t.running)return!1;var a=i-t.startTime>t.minTimeDelta,s=t.percentChance>Math.random();return a&&s}function nc(t,i,a,s){void 0===s&&(s=!1);var e=a,n=i;if(s&&(e=i,n=a),t>=.5){var o=(t-.5)/.5;return u(e,n,i,a,o)}o=t/.5;return u(n,e,i,a,o)}H.default=tc;var n,i,ua={};Object.defineProperty(ua,"__esModule",{value:!0});var mc=function(){function e(e){this.pos={x:0,y:0},this.size={w:0,h:0},n=e,this.size={w:n.canvas.width,h:n.canvas.height},i={amplitude:0,dir:{x:1,y:1},pos:{x:0,y:0}}}return Object.defineProperty(e.prototype,"offset",{get:function(){return{x:i.pos.x+this.pos.x,y:i.pos.y+this.pos.y}},enumerable:!0,configurable:!0}),e.prototype.move=function(e){this.pos.x=e.x,this.pos.y=e.y},e.prototype.moveToPlayer=function(e){this.pos.x=n.canvas.width/2-e.pos.x*n.ss-e.dSize.w/2,this.pos.y=n.canvas.height/2-e.pos.y*n.ss-e.dSize.h/2;var $=-1*(n.cl.dSize.w-this.size.w),a=-1*(n.cl.dSize.h-this.size.h);this.pos.x>0&&(this.pos.x=0),this.pos.x<$&&(this.pos.x=$),this.pos.y>0&&(this.pos.y=0),this.pos.y<a&&(this.pos.y=a)},e.prototype.shakeScreen=function(){i.pos={x:0,y:0},i.amplitude=10*n.ss,i.dir.x=Ia(),i.dir.y=Ia()},e.prototype.updateShake=function(e){i.amplitude*=.9;var $=i.amplitude,a=i.dir;Math.abs($)<=.01?(i.pos.x=0,i.pos.y=0):(i.pos.x=Math.sin(e/50)*$*a.x,i.pos.y=Math.sin(e/50)*$*a.y)},e}(),lc=mc;function Ia(){return 2*Math.round(Math.random())-1}ua.default=lc;var ea={};Object.defineProperty(ea,"__esModule",{value:!0});var a=null,hc={cloud:{cMatrix:[[a,a,a,a,a,a,a,a],[a,a,a,a,a,a,a,a],[a,a,a,a,a,a,a,a],[a,a,a,1,1,a,a,a],[a,a,1,1,1,1,a,a],[a,a,1,1,1,1,1,a],[a,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1]],canvas:null},door:{cMatrix:na(0),canvas:null,interactable:!0},flowers:{cMatrix:[[2,2,2,2,2,2,2,2],[2,2,5,2,2,2,3,2],[2,5,4,5,2,2,2,2],[2,2,5,2,2,2,2,2],[2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2],[2,2,3,2,2,2,2,2],[2,2,2,2,2,2,2,2]],canvas:null},grass:{cMatrix:[[2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2],[2,2,3,2,2,2,2,2],[2,2,2,2,2,2,2,2],[2,2,2,2,2,2,3,2],[2,2,2,2,2,2,2,2],[2,2,3,2,2,2,2,2],[2,2,2,2,2,2,2,2]],canvas:null},green:{cMatrix:na(2),canvas:null},house:{cMatrix:[[2,2,2,2,2,2,2,2,2,2,2,6,6,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,6,6,6,6,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,6,6,6,6,6,6,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,6,6,6,6,6,6,6,6,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,6,6,6,6,6,6,6,6,6,6,2,2,2,2,2,2,2],[2,2,2,2,2,2,6,6,6,6,6,6,6,6,6,6,6,6,2,2,2,2,2,2],[2,2,2,2,2,6,6,6,6,6,6,6,6,6,6,6,6,6,6,2,2,2,2,2],[2,2,2,2,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,2,2,2,2],[2,2,2,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,2,2,2],[2,2,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,2,2],[2,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,2],[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6]],canvas:null,tileLength:3*b.TS},sky:{cMatrix:na(9),canvas:null},tree:{cMatrix:[[a,a,a,a,a,a,a,a],[a,a,7,7,7,7,a,a],[a,7,7,7,7,7,7,a],[a,7,7,7,7,7,7,a],[a,a,7,7,7,7,a,a],[a,a,a,6,6,a,a,a],[a,a,a,6,6,a,a,a],[a,a,6,6,6,6,a,a]],canvas:null,wable:!1},unwalkable:{canvas:null,visible:!1,wable:!1}};function na($){return new Array(b.TS).fill(null).map(function(){return new Array(b.TS).fill($)})}ea.default=hc;var N={},Qa=N&&N.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(N,"__esModule",{value:!0});var dc=Qa(e),o=Qa(ea),cc=function(){function e(e,t,i,$){this.dSize={w:b.TS,h:b.TS},this.pos={x:0,y:0},this.size={w:b.TS,h:b.TS},this.wable=!0,this.visible=!0,this.alpha=1,this.tileLength=b.TS,this.game=e,this.pos={x:i*b.TS,y:$*b.TS},this.tileIndex={x:i,y:$},this.name=t,this.cMatrix=o.default[t].cMatrix,this.wable=o.default[t].hasOwnProperty("wable")?o.default[t].wable:this.wable,this.visible=o.default[t].hasOwnProperty("visible")?o.default[t].visible:this.visible,this.tileLength=o.default[t].hasOwnProperty("tileLength")?o.default[t].tileLength:this.tileLength,this.dSize={h:this.tileLength*this.game.ss,w:this.tileLength*this.game.ss},this.cacheOffscreenContext()}return e.prototype.draw=function(e){e.globalAlpha=this.game.inTr()?Math.min(this.alpha,this.game.nextAlpha):this.alpha,e.drawImage(o.default[this.name].canvas,0,0)},e.prototype.moveleft=function(){this.pos.x=this.pos.x+this.size.w<0?this.lWidth:this.pos.x-.008*this.speed},e.prototype.cacheOffscreenContext=function(){var e=this,t=document.createElement("canvas");t.width=this.dSize.w,t.height=this.dSize.h;var i=t.getContext("2d");Z(this.cMatrix).map(function(e){return dc.default[e]}).forEach(function(t,$){if(t){i.fillStyle=t;var a=e.game.ss*($%e.tileLength),s=e.game.ss*Math.floor($/e.tileLength);i.fillRect(a,s,e.game.ss,e.game.ss)}}),o.default[this.name].canvas=t},e}(),bc=cc;N.default=bc;var w={},Xa=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(w,"__esModule",{value:!0});var ac=Xa(e),Za=Xa(N),_b=function(){function e(e){this.tiles=[],this.bgColor=ac.default[2],this.clouds=[],this.game=e}return e.prototype.levelWillStart=function(){},e.prototype.levelStarted=function(){},e.prototype.update=function(e){this.uables.forEach(function(t){return t.update(e)}),this.clouds.forEach(function(e){return e.moveleft()})},e.prototype.configViz=function(){this.dables=new Array(4).fill(null).map(function(){return new Array().fill(null)}),this.odables=[],this.uables=[]},e.prototype.configClouds=function(e,t,r){this.clouds=[];for(var o=0;o<20;o++){var a=new Za.default(this.game,"cloud",0,0);a.pos.x=ka(0,e),a.pos.y=ka(0,t),a.speed=ka(.2,1),a.alpha=r,a.lWidth=this.size.w,this.clouds.push(a)}},e.prototype.generateTiles=function(){var e=this.tileIndexes[0].length*b.TS,t=this.tileIndexes.length*b.TS;this.size={w:e,h:t},this.dSize={w:e*this.game.ss,h:t*this.game.ss};for(var r=0;r<this.tileIndexes.length;r++)for(var o=0;o<this.tileIndexes[r].length;o++){var a=this.tileTypeMap[this.tileIndexes[r][o]||0];this.tiles.push(new Za.default(this.game,a,o,r))}},e.prototype.addDables=function(e,t){var r;(r=this.dables[t]).push.apply(r,e)},e.prototype.addOdables=function(e){var t;(t=this.odables).push.apply(t,e)},e.prototype.addUables=function(e){var t;(t=this.uables).push.apply(t,e)},e}(),$b=_b;function ka(e,t){return Math.random()*(t-e)+e}w.default=$b;var la={};Object.defineProperty(la,"__esModule",{value:!0});var Zb={A:[[,1],[1,,1],[1,,1],[1,1,1],[1,,1]],B:[[1,1],[1,,1],[1,1,1],[1,,1],[1,1]],C:[[1,1,1],[1],[1],[1],[1,1,1]],D:[[1,1],[1,,1],[1,,1],[1,,1],[1,1]],E:[[1,1,1],[1],[1,1,1],[1],[1,1,1]],F:[[1,1,1],[1],[1,1],[1],[1]],G:[[,1,1],[1],[1,,1,1],[1,,,1],[,1,1]],H:[[1,,1],[1,,1],[1,1,1],[1,,1],[1,,1]],I:[[1,1,1],[,1],[,1],[,1],[1,1,1]],K:[[1,,,1],[1,,1],[1,1],[1,,1],[1,,,1]],L:[[1],[1],[1],[1],[1,1,1]],M:[[1,1,1,1,1],[1,,1,,1],[1,,1,,1],[1,,,,1],[1,,,,1]],N:[[1,,,1],[1,1,,1],[1,,1,1],[1,,,1],[1,,,1]],O:[[1,1,1],[1,,1],[1,,1],[1,,1],[1,1,1]],P:[[1,1,1],[1,,1],[1,1,1],[1],[1]],Q:[[,1,1],[1,,,1],[1,,,1],[1,,1,1],[1,1,1,1]],R:[[1,1],[1,,1],[1,,1],[1,1],[1,,1]],S:[[1,1,1],[1],[1,1,1],[,,1],[1,1,1]],T:[[1,1,1],[,1],[,1],[,1],[,1]],U:[[1,,1],[1,,1],[1,,1],[1,,1],[1,1,1]],V:[[1,,,,1],[1,,,,1],[,1,,1],[,1,,1],[,,1]],W:[[1,,,,1],[1,,,,1],[1,,,,1],[1,,1,,1],[1,1,1,1,1]],Y:[[1,,1],[1,,1],[,1],[,1],[,1]],Z:[[1,1,1,1,1],[,,,1],[,,1],[,1],[1,1,1,1,1]]," ":[[,],[,],[,],[,],[,]],".":[[,,],[,,],[,,],[1,1],[1,1]],"!":[[1,,],[1,,],[1,,],[,,],[1,,]],"^":[[,,,,],[,,1,,],[,1,1,1],[1,1,1,1,1],[1,1,1,1,1]],_:[[,,,,],[1,1,1,1,1],[1,1,1,1,1],[,1,1,1],[,,1,,]],"*":[[,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[,1,1,1]]};la.default=Zb;var C={},fb=C&&C.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(C,"__esModule",{value:!0});var ib=fb(e),Xb=fb(la),Wb=function(){function t(t,s,e,a){void 0===s&&(s=""),void 0===e&&(e=ib.default[1]),void 0===a&&(a={x:0,y:0}),this.words="",this.dSize={w:0,h:0},this.pos={x:0,y:0},this.visible=!0,this.shadow=!0,this.alpha=1,this.buddy=null,this.a={},this.upToIndex=null,this.game=t,this.words=s.toUpperCase(),this.upToIndex=this.words.length,this.color=e,this.move(a),this.pixelLetters=this.words.split("").map(function(t){return Xb.default[t]});var r=this.pixelLetters.map(function(t){return Math.max.apply(Math,t.map(function(t){return t.length}))}).reduce(function(t,s){return t+s},0)+this.pixelLetters.length-1;this.size={w:r,h:b.LH},this.dSize={h:this.size.h*this.game.ss,w:this.size.w*this.game.ss};this.a.floatText={duration:3e3,endPos:{x:0,y:0},running:!1,startPos:{x:0,y:0},startTime:0}}return t.prototype.draw=function(t,s){var e=this.pos.x,a=this.game.inTr()?Math.min(this.alpha,this.game.nextAlpha):this.alpha,r=Math.floor(this.game.ss/2);t.globalAlpha=a;for(var i=0;i<this.upToIndex;i++){for(var o=this.pos.y,h=0,l=this.pixelLetters[i],$=0;$<l.length;$++){for(var n=l[$],p=0;p<n.length;p++)n[p]&&(this.shadow&&(t.fillStyle=ib.default[0],t.fillRect(e+p*this.game.ss+r,o+r,this.game.ss,this.game.ss)),t.fillStyle=this.color,t.fillRect(e+p*this.game.ss,o,this.game.ss,this.game.ss));h=Math.max(h,n.length*this.game.ss),o=this.game.ss*($+1)+this.pos.y}e+=this.game.ss+h}Aa.call(this,s)},t.prototype.touched=function(){},t.prototype.move=function(t){this.pos.x=Math.floor(t.x),this.pos.y=Math.floor(t.y)},t.prototype.showUpToIndex=function(t){this.upToIndex=t},t.prototype.startFloat=function(t,s){this.a.floatText.startTime=this.game.tstamp,this.a.floatText.startPos={x:t.x,y:t.y-this.size.h},this.a.floatText.endPos={x:s.x,y:s.y},this.a.floatText.running=!0,this.move(this.a.floatText.startPos)},t.prototype.update=function(t){Aa.call(this,t)},t}(),Ub=Wb;function Aa(t){var s=this.a.floatText;if(s.running){var e=(t-s.startTime)/s.duration,a=E(s.startPos.x,s.endPos.x,e);this.words!==b.LT&&(a+=10*Math.sin(6*e*Math.PI));var r=E(s.startPos.y,s.endPos.y,e);e>=1&&(s.running=!1),this.alpha=1-e,this.move({x:a,y:r})}}C.default=Ub;var r={},Ca=r&&r.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0});var ta=Ca(e),Nb=Ca(C),Lb=function(){function t(t,i,o,s){void 0===s&&(s=ta.default[8]),this.visible=!0,this.alpha=1,this.ani=!1,this.texts=[],this.startTime=null,this.game=t,this.pos=i,this.strokePos=i,this.color=s,this.updateSize(o),this.move(i)}return t.prototype.move=function(t){this.pos.x=t.x,this.pos.y=t.y,this.strokePos.x=Math.floor(this.pos.x)+.5,this.strokePos.y=Math.floor(this.pos.y)+.5,Ha.call(this)},t.prototype.updateSize=function(t){this.size={h:t.h,w:t.w},this.dSize={h:this.size.h*this.game.ss,w:this.size.w*this.game.ss}},t.prototype.draw=function(t,i){var o=this,s=this.game.inTr()?Math.min(this.alpha,this.game.nextAlpha):this.alpha;t.globalAlpha=s,t.fillStyle=this.color,this.color&&t.fillRect(this.pos.x,this.pos.y,this.dSize.w,this.dSize.h),t.strokeStyle=ta.default[1],t.fillStyle=ta.default[1],t.lineWidth=this.game.ss,t.strokeRect(this.strokePos.x,this.strokePos.y,this.dSize.w,this.dSize.h);var e=new Array(this.texts.length).fill(0);if(this.startTime){var r=this.texts.reduce(function(t,i){return t+i.words.length},0),a=Math.min(Math.floor((i-this.startTime)/50),r);r===a&&(this.ani=!1),e=this.texts.map(function(t,i){var s=o.texts.slice(0,i).reduce(function(t,i){return i.words.length+t},0);return Math.min(a-s,t.words.length)})}this.texts.forEach(function(o,s){o.showUpToIndex(e[s]),o.draw(t,i)})},t.prototype.setWords=function(t){var i=this;this.texts=t.map(function(t){return new Nb.default(i.game,t)}),Ha.call(this)},t.prototype.aniText=function(t){this.startTime=t,this.ani=!0},t}(),Jb=Lb;function Ha(){var t=this;if(this.texts.length){var i=b.LS*this.game.ss,o=b.LH*this.game.ss,s=this.texts.length,e=s*o+(s-2)*i;this.texts.forEach(function(o,s){var r=t.pos.x+t.game.ss*(t.size.w-o.size.w)/2,a=t.pos.y+(t.dSize.h-e)/2+i*s;o.move({x:r,y:a})})}}r.default=Jb;var D={},$=D&&D.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(D,"__esModule",{value:!0});var Ib=$(r),ca=$(e),Hb=$(C),Gb=function(){function e(e,t,i){this.pos={x:0,y:0},this.visible=!0,this.percentFull=0,this.a={},this.game=e,this.energyText=new Hb.default(this.game,i,ca.default[1]),this.energyText.shadow=!1,this.size=Object.assign({},this.energyText.size),this.dSize={h:(this.size.h+2)*this.game.ss,w:(this.size.w+2)*this.game.ss};var r={h:this.size.h+2,w:this.size.w+2};this.box=new Ib.default(e,t,r,null);this.a.level={duration:1e3,endLevel:0,running:!1,startLevel:0,startTime:0},this.move(t)}return Object.defineProperty(e.prototype,"animating",{get:function(){var e=this;return!!Object.keys(this.a).map(function(t){return e.a[t]}).find(function(e){return e.running})},enumerable:!0,configurable:!0}),e.prototype.move=function(e){this.pos.x=e.x,this.pos.y=e.y,this.box.move(this.pos),this.energyText.move({x:e.x+this.game.ss/2+2.5,y:e.y+this.game.ss/2+2.5})},e.prototype.draw=function(e,t){Db.call(this,t),e.globalAlpha=this.game.inTr()?this.game.nextAlpha:1,e.fillStyle=ca.default[10],e.fillRect(this.pos.x,this.pos.y,this.dSize.w,this.dSize.h),e.fillStyle=ca.default[7],e.fillRect(Math.ceil(this.pos.x+1),Math.ceil(this.pos.y+1),Math.floor(Math.max(this.dSize.w*this.percentFull-2,0)),Math.floor(this.dSize.h-2)),this.box.draw(e,t),this.energyText.draw(e,t)},e.prototype.animateToLevel=function(e){this.a.level.startTime=this.game.tstamp,this.a.level.startLevel=this.percentFull,this.a.level.endLevel=e,this.a.level.running=!0},e}(),Fb=Gb;function Db(e){if(this.a.level.running){var t=(e-this.a.level.startTime)/this.a.level.duration,i=E(this.a.level.startLevel,this.a.level.endLevel,t);t>=1&&(i=this.a.level.endLevel,this.a.level.running=!1),this.percentFull=i}}D.default=Fb;var t={},xb=t&&t.__extends||function(){var $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function($,a){$.__proto__=a}||function($,a){for(var e in a)a.hasOwnProperty(e)&&($[e]=a[e])};return function(a,e){function r(){this.constructor=a}$(a,e),a.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),O=t&&t.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(t,"__esModule",{value:!0});var f,Ua,j,x,L,R,s,l,v,rb=O(w),mb=O(r),G=O(e),db=O(D),V=O(C),lb=4,oc=2,hb=3,X=.5,sd=.35,gb=0,A=0,T=!1,nb=1,ob=null,pb=null,qb=null,ra=[],sb=function($){function a(a){var e=$.call(this,a)||this;e.bgColor=G.default[9],e.tileTypeMap=["green","flowers","sky","tree"],s=new db.default(e.game,{x:e.game.ss,y:e.game.ss},"ENERGY"),x=new db.default(e.game,{x:e.game.ss,y:e.game.ss},"CONVO"),f=new mb.default(e.game,{x:0,y:0},{h:0,w:0}),v=new V.default(e.game,"^"),R=new V.default(e.game,"_");var r=W(e.handleInput.bind(e),b.TT);return e.handleInput=r,v.touched=function(){return e.handleInput("ArrowUp")},R.touched=function(){return e.handleInput("ArrowDown")},e}return xb(a,$),Object.defineProperty(a.prototype,"boxPosY",{get:function(){return f.pos.y/this.game.ss-this.game.p.size.h-lb},enumerable:!0,configurable:!0}),a.prototype.handleInput=function($){switch($){case"ArrowUp":ha.call(this,1);break;case"ArrowDown":ha.call(this,-1);break;case"Enter":Ab.call(this);}},a.prototype.handleTouch=function($){var a=this,e=20*this.game.sf,r=ra.find(function(r){var t=Object.assign({},r.dSize),o=Object.assign({},r.pos);return t.w*=a.game.sf,t.h*=a.game.sf,o.x*=a.game.sf,o.y*=a.game.sf,$.clientX+e>=o.x&&$.clientX-e<=o.x+t.w&&$.clientY+e>=o.y&&$.clientY-e<=o.y+t.h&&r.visible});r&&r.touched()},a.prototype.levelWillStart=function(){var $=this;(j=this.game.levels.world.currentBuddy.copy()).setConvoMode(!0,"left"),T=!1,this.game.p.setConvoMode(!0,"right"),L=0,this.usedTopics=[],ob=null,Ua=[this.game.p,j],j.skills.length>2&&(nb=sd),(l=this.game.p.skills.map(function(a){return new V.default($.game,a)})).forEach(function(a){return a.touched=function(){l[A]===a&&$.handleInput("Enter")}})},a.prototype.levelStarted=function(){x.animateToLevel(L),s.animateToLevel(this.game.p.energy)},a.prototype.resize=function(){this.configViz()},a.prototype.update=function(a){if($.prototype.update.call(this,a),this.game.c.move({x:gb,y:0}),Ka.call(this),Kb.call(this),T=wa(this.odables).length>0||this.game.inTr()||!!qb||!!pb,wb(this.odables))if(L>=1){var e=1===this.game.p.skills.length?"post-listen":"post-convo";e=j.skills.length>2?"win":e,this.game.qLevel(this.game.levels.world,e)}else this.game.p.energy<=0&&this.game.qLevel(this.game.levels.world,"nap")},a.prototype.configViz=function(){$.prototype.configViz.call(this),ra=[];var a=this.game.sizeInTiles();gb=-a.w*b.TS*this.game.ss/2,Ka.call(this),ub.call(this),ha.call(this,0),this.tileIndexes=vb(this.game),this.generateTiles(),this.addDables(this.tiles,0),this.addDables(Ua,1),this.addOdables([f,v,R,s,x].concat(l)),ra.push.apply(ra,[v,R].concat(l)),this.configClouds(this.size.w,this.game.p.pos.y-b.TS,.6),this.addDables(this.clouds,0)},a}(rb.default),tb=sb;function ub(){var $=this.game.canvas.height-b.BS.h*this.game.ss-2*this.game.ss;f.move({x:this.game.boxPos().x,y:$}),f.updateSize(b.BS);var a=s.dSize.w+x.dSize.w+hb*this.game.ss,e=(this.game.canvas.width-a)/2;s.move({x:e,y:s.pos.y});var r=s.pos.x+s.dSize.w+hb*this.game.ss;x.move({x:r,y:x.pos.y});var t=this.game.boxPos().x/this.game.ss-j.size.w/2-gb/this.game.ss,o=t+f.dSize.w/this.game.ss-j.size.w/2,i={x:t+this.game.p.size.w/2,y:this.boxPosY};this.game.p.move(i),j.move({x:o,y:i.y})}function vb($){for(var a=Math.min($.p.tileIndex.y+1,$.sizeInTiles().h),e=$.sizeInTiles(),r=new Array(2*e.h).fill(null).map(function(){return new Array(2*e.w).fill(null).map(function(){return I([0,1])})}),t=0;t<a;t++)r[t]=r[t].map(function(){return 2});var o=r[a-1];return o&&(r[a-1]=o.map(function(){return 3})),r}function wb($){return!x.animating&&0===wa($).length}function ha($){if(!T){var a=l[A+$]||l[A];A=l.indexOf(a),l.forEach(function($){return $.alpha=X}),this.game.pa("walk")}}function yb($){L=qa(Math.round(100*(L+$))/100,0,1)}function zb($,a){$.energy=qa(Math.round(100*($.energy+a))/100,0,1)}function Ab(){var $=this;if(!T){T=!0;var a=A;Ma.call(this,this.game.p,a),pb=setTimeout(function(){return Bb.call($,a)},2e3);var e=j.skills.indexOf(b.LT);1!==this.game.p.skills.length&&(e=I(j.skills)),qb=setTimeout(function(){return Ma.call($,j,e)},4500)}}function Bb($){var a=this.game.p.skills[$];pb=null,1===this.game.p.skills.length?fa.call(this,-.1,.5):a===b.LT&&2===this.game.p.skills.length?fa.call(this,-.1,.5):a===b.LT?(_.call(this,-.1,.25),this.game.pa("good")):ob===a?Cb.call(this,-.15,.5):j.skills.includes(a)?fa.call(this,-.1,.34):Eb.call(this,-.2),x.animateToLevel(L),s.animateToLevel(this.game.p.energy)}function Cb($,a){var e=this,r=function(){return aa.call(e,j,"totally!",G.default[2])};r(),window.setTimeout(r,500),window.setTimeout(r,1e3),_.call(this,$,a),this.game.pa("good",3)}function fa($,a){aa.call(this,j,"cool!",G.default[2]),_.call(this,$,a),this.game.pa("good")}function Eb($){aa.call(this,j,"oh...",G.default[10]),_.call(this,$,0),this.game.c.shakeScreen(),this.game.pa("bad")}function _($,a){zb(this.game.p,$),yb(a*nb)}function aa($,a,e){var r=new V.default(this.game,a,e);r.buddy=$;var t=this.boxPosY*this.game.ss+this.game.p.dSize.h/2,o={x:f.pos.x+this.game.p.dSize.w/2,y:t},i={x:this.game.canvas.width,y:-b.LH};$!==this.game.p&&(o.x+=f.dSize.w-r.dSize.w-this.game.p.dSize.w,i.x=0),a===b.LT&&(i.x=o.x),r.startFloat(o,i),this.addOdables([r]),this.addUables([r])}function Ma($,a){if($===j&&(qb=null),!(L>=1||this.game.p.energy<=0)){var e=$.skills[a],r=e===b.LT?G.default[9]:G.default[1];aa.call(this,$,e,r),$===j&&(ob=e,this.usedTopics.includes(e)||this.usedTopics.push(e)),e!==b.LT&&this.game.pa("walk",5)}}function Ka(){var $=this,a=oc*this.game.ss,e=f.pos.x+f.dSize.w-v.dSize.w-a,r=f.pos.y+f.dSize.h/2-v.dSize.h/2,t=f.pos.x+a,o=r;v.move({x:e,y:r}),R.move({x:t,y:o}),R.alpha=0===A||T?X:1,v.alpha=A===l.length-1||T?X:1,l.forEach(function(a,e){var r=A-e;a.alpha=0!==r||T?X:1;var t=f.pos.x+f.dSize.w/2-a.dSize.w/2,o=f.pos.y+f.dSize.h/2-a.dSize.h/2+r*b.LS*$.game.ss;a.move({x:t,y:o}),a.visible=!(Math.abs(r)>1)})}function wa($){return $.filter(function($){return $ instanceof V.default&&$.buddy})}function Kb(){var $=wa(this.odables);Ua.forEach(function(a){return a.talking=!!$.find(function($){return $.words!==b.LT&&$.buddy===a})});for(var a=$.length-1;a>=0;a--){var e=$[a];if(!e)break;e.a.floatText.running||(ja(e,this.odables),this.uables.splice(a,1))}}t.default=tb;var y={},Mb=y&&y.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),Ea=y&&y.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(y,"__esModule",{value:!0});var Ob=Ea(r),Pb=Ea(w),Qb=1,Rb=function(e){function t(t){var r=e.call(this,t)||this;return r.tileTypeMap=["green","flowers","grass","tree"],r.box=new Ob.default(r.game,{x:0,y:0},{h:0,w:0}),r.box.setWords(["CONVO IRL","","TAP TO PLAY"]),r}return Mb(t,e),t.prototype.resize=function(){this.configViz()},t.prototype.update=function(t){e.prototype.update.call(this,t),this.game.c.pos.x-=.05*Qb,this.game.c.pos.x<-this.game.canvas.width&&(Qb=-1),this.game.c.pos.x>0&&(Qb=1)},t.prototype.configViz=function(){e.prototype.configViz.call(this),this.tileIndexes=Tb(this.game.sizeInTiles(),this.tileTypeMap),this.generateTiles(),this.box.move(this.game.boxPos()),this.box.updateSize(b.BS),this.addDables(this.tiles,0),this.addOdables([this.box]),this.configClouds(this.size.w,this.size.h,.3),this.addDables(this.clouds,3)},t.prototype.levelStarted=function(){var e=this;window.setTimeout(function(){return e.box.aniText(e.game.tstamp)},200)},t.prototype.handleInput=function(){this.game.inTr()||this.box.ani||this.game.qLevel(this.game.levels.world)},t.prototype.handleTouch=function(){this.handleInput()},t}(Pb.default),Sb=Rb;function Tb(e,t){return new Array(2*e.h).fill(null).map(function(){return new Array(2*e.w).fill(null).map(function(){return I(t)})})}y.default=Sb;var B={},Vb=B&&B.__extends||function(){var $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function($,a){$.__proto__=a}||function($,a){for(var e in a)a.hasOwnProperty(e)&&($[e]=a[e])};return function(a,e){function r(){this.constructor=a}$(a,e),a.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),P=B&&B.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(B,"__esModule",{value:!0});var xa,Yb,cb,_a,c,k,F,ba,z,ec=P(e),fc=P(w),gc=P(r),p=P(H),ic=P(D),jc=[["great news! a","new kid moved","into the woods!"],["become friends","by having a","convo... irl!"],["first level up!","chat with","your neighbors!"],["talk to them","about their","interests!"]],kc=[["keep at it","and make","new friends!"],["if you are","low on energy","take a nap!"]],Ga=[["well done!","you made a","new friend!"],["maybe you","will become","best buds!"],["be kind to","your friends","because"],["every quest","is better","with friends!"]],da={x:18*b.TS,y:7*b.TS},pa={x:4*b.TS,y:5*b.TS},g=["BAKING","FRANCE","SPORTS","ANIME","BOOKS","MATH","CATS"],$a=g.slice(),va={x:4*b.TS,y:6*b.TS},Wa={pressedAt:0,key:null},sc=0,ia=[],uc=function($){function a(a){var e=$.call(this,a)||this;e.tileTypeMap=["green","flowers","grass","tree","house","unwalkable","door"],e.tileIndexes=[[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,,,,3,3,3,3,,,,,,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,2,,,3,3,3,3,,1,,,,3,3,3,3,3,,,3,3],[3,3,3,4,5,5,3,,,2,,3,3,3,,,,,,3,3,3,3,,,,3,3],[3,3,3,5,5,5,3,,1,,,3,3,2,,,,2,,,,3,,,,3,3,3],[3,3,3,5,6,5,3,,,,1,,,,,,,,,,,,,,,3,3,3],[3,3,3,1,1,1,1,3,3,,,,,,,,,,,,,,,,,,,3],[3,3,3,1,1,1,1,3,3,3,3,,,,,,1,,,,,,,,,,,3],[3,3,3,3,,,,3,3,3,3,3,,2,,,,,,,,,,,,,,3],[3,,2,3,3,,2,,3,3,3,,,,,,,1,,,,,,,,,,3],[3,,,3,3,3,3,,,,,,,,,,,,,,,,,,,,,3],[3,,,2,3,3,3,,,,,,,,,,,,,,,,,,,,,3],[3,1,,3,3,3,,,,,,,,,,,,,,1,,,3,,,,,3],[3,,,3,3,2,,,,,,,,,,,,,,3,,,2,3,,,,3],[3,,,3,3,,,,2,,,,,,,,,,,3,3,,,2,3,3,3,3],[3,,,3,,,,,,,1,3,3,,,,,,,,3,3,,,4,5,5,3],[3,,,,,,,,3,3,3,3,,1,,,,,,,3,3,,,5,5,5,3],[3,,,3,3,3,,3,3,3,3,,,,,,3,3,3,3,3,3,,,5,6,5,3],[3,3,3,3,3,3,3,3,3,3,3,2,,,,,,3,3,3,3,3,,2,1,1,1,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]],xa=function(){return ma.call(e,jc)},Yb=function(){return ma.call(e,kc)},cb=function(){return ma.call(e,Ga)},e.state="intro";var r=W(e.handleTouch.bind(e),b.TT),t=W(e.handleInput.bind(e),b.TT);return e.handleTouch=r,e.handleInput=t,e.generateTiles(),z=new ic.default(e.game,{x:0,y:a.ss},"ENERGY"),c=new gc.default(e.game,e.game.boxPos(),b.BS),Dc.call(e),e}return Vb(a,$),a.prototype.handleInput=function($){this.game.inTr()||Ra.call(this)||(Wa={pressedAt:this.game.tstamp,key:$})},a.prototype.handleTouch=function($){if(!this.game.inTr()&&!this.game.p.walking&&!Ra.call(this)){var a=this.game.c,e=a.size,r=e.h,t=e.w,o=a.offset,s=$.clientX*t/window.innerWidth-o.x,i=$.clientY*r/window.innerHeight-o.y,y=s-this.game.p.pos.x*this.game.ss,n=i-this.game.p.pos.y*this.game.ss,v=Math.abs(y),P=Math.abs(n),l=this.game.ss*b.TS/2;v<l&&P<l||(v>P?y>0?this.handleInput("ArrowRight"):this.handleInput("ArrowLeft"):n<0?this.handleInput("ArrowUp"):this.handleInput("ArrowDown"))}},a.prototype.resize=function(){var $=(this.game.canvas.width-z.dSize.w)/2;z.move({x:$,y:z.pos.y}),c.move(this.game.boxPos()),c.updateSize(b.BS)},a.prototype.update=function(a){$.prototype.update.call(this,a),Ec.call(this),Oa.call(this,this.game.p.tileIndex),this.game.c.moveToPlayer(this.game.p),k.pos.x<=da.x-5*b.TS&&(k.autoWalkDirection="right"),k.pos.x>=da.x+5*b.TS&&(k.autoWalkDirection="left")},a.prototype.configViz=function(){$.prototype.configViz.call(this),ia=[],this.addDables(this.tiles,0),this.addDables(this.game.p.dusts,1),this.addDables(k.dusts,1),this.addDables([this.game.p],2),this.addDables(_a,2),this.addOdables([z,c]),ia.push.apply(ia,_a),this.addUables(this.game.p.dusts.concat([this.game.p,k],k.dusts,[F])),this.configClouds(this.size.w,this.size.h,.3),this.addDables(this.clouds,3),this.resize()},a.prototype.levelStarted=function(){switch(z.animateToLevel(this.game.p.energy),k.move(da),this.game.p.move(va),this.game.p.stop(),this.game.p.setConvoMode(!1),this.state){case"intro":xa(),this.game.pa("good");break;case"nap":this.game.p.move(pa),Na.call(this);break;case"win":this.game.p.energy=1,this.game.pa("good"),cb();break;case"post-listen":case"post-convo":this.game.pa("good"),zc.call(this),this.game.p.lastConvo=this.game.tstamp;}},a}(fc.default),vc=uc;function Ta(){c.visible=!1}function Ra(){if("play"===this.state)return!1;if(c.ani)return!0;switch(this.state){case"sleeping":Ta.call(this),this.state="play",this.handleInput("ArrowDown"),this.game.pa("good");break;case"post-convo":Ta.call(this),this.state="play",this.currentBuddy.lastConvo=this.game.tstamp;break;case"post-listen":Yb()&&(this.state="play",F.walk("right"),F.look("left"));break;case"intro":xa()&&(this.state="play");break;case"win":cb(),0===Ga.length&&(this.state="game-over",sc=this.game.tstamp,Y.game=this.game,Y.size=Object.assign({},this.size),Y.dSize=Object.assign({},this.dSize),this.addDables([Y],3),this.game.pa("good"),z.animateToLevel(1));}return this.game.pa("walk"),!0}function ma($){var a=$[0];return a?(c.visible=!0,c.setWords(a),c.aniText(this.game.tstamp),$.shift(),!1):(c.visible=!1,!0)}function zc(){var $=this;if(this.currentBuddy){var a=this.game.levels.convo.usedTopics.filter(function(a){return!$.game.p.skills.includes(a)}),e=a.length>0?a[I(a)]:null;c.visible=!0,e?(c.setWords(["nice convo!","you learned",e+"!"]),this.game.p.skills.push(e)):c.setWords(["nice convo!","that was a","good time!"]),c.aniText(this.game.tstamp)}}function Oa($){var a=ia.find(function(a){return a.tileIndex.x===$.x&&a.tileIndex.y===$.y});return a&&this.game.tstamp-a.lastConvo>1e3&&!c.visible?(this.currentBuddy=a,va.x=this.game.p.pos.x,va.y=this.game.p.pos.y,this.game.qLevel(this.game.levels.convo),!0):!!a}function Na(){this.game.p.energy=1,z.animateToLevel(this.game.p.energy),c.setWords(["","zzzzzz...",""]),c.aniText(this.game.tstamp),c.visible=!0,this.state="sleeping"}function J($){var a=$a.find(function(a){return a!==$});return ja(a,$a),a}function Dc(){var $;(F=new p.default(this.game)).move({x:7*b.TS,y:10*b.TS}),F.skills.push(b.LT,g[6]),F.look("up");var a=new p.default(this.game);a.move({x:8*b.TS,y:1*b.TS}),a.skills.push(g[0],J(g[0]));var e=new p.default(this.game);e.move({x:18*b.TS,y:3*b.TS}),e.skills.push(g[1],J(g[1]));var r=new p.default(this.game);r.move({x:25*b.TS,y:2*b.TS}),r.skills.push(g[2],J(g[2]));var t=new p.default(this.game);t.move({x:15*b.TS,y:18*b.TS}),t.skills.push(g[3],J(g[3])),t.look("up");var o=new p.default(this.game);o.move({x:26*b.TS,y:8*b.TS}),o.skills.push(g[4],J(g[4])),o.look("left"),(k=new p.default(this.game)).autoWalkDirection="left",k.skills.push(g[5],J(g[5])),k.a.walking.duration=600,(ba=new p.default(this.game)).move({x:23*b.TS,y:18*b.TS}),ba.look("left"),($=ba.skills).push.apply($,g),_a=[F,a,e,r,ba,t,o,k]}function Ec(){if(this.game.tstamp-Wa.pressedAt>220)return!1;if(this.game.p.walking)return!1;var $=Object.assign({},this.game.p.tileIndex),a=null;switch(Wa.key){case"ArrowUp":a="up",$.y-=1;break;case"ArrowDown":a="down",$.y+=1;break;case"ArrowLeft":a="left",$.x-=1;break;case"ArrowRight":a="right",$.x+=1;break;default:return;}return Oa.call(this,$)?void 0:($.x===pa.x/b.TS&&$.y===pa.y/b.TS&&Na.call(this),this.game.p.walk(a)&&this.game.pa("walk"),!0)}B.default=vc;var Y={alpha:0,dSize:{w:0,h:0},draw:function($){$.fillStyle=ec.default[0],$.globalAlpha=Math.min((this.game.tstamp-sc)/2e3,.8),$.fillRect(0,0,this.dSize.w,this.dSize.h)},game:null,pos:{x:0,y:0},size:{w:0,h:0},visible:!0};var ga,U={};!function(t,e){"function"==typeof ga&&ga.amd?ga(["exports"],e):"object"==typeof U&&"string"!=typeof U.nodeName?e(U):e(t.TinyMusic={})}(U,function(t){var e=440*Math.pow(Math.pow(2,1/12),-9),s=/^[0-9.]+$/,i=/\s+/,o=/(\d+)/,n={};function r(t){var e=t.split(i);this.frequency=r.getFrequency(e[0])||0,this.duration=r.getDuration(e[1])||0}function c(t,e,s){this.ac=t||new AudioContext,this.createFxNodes(),this.tempo=e||120,this.loop=!0,this.smoothing=0,this.staccato=0,this.notes=[],this.push.apply(this,s||[])}"B#-C|C#-Db|D|D#-Eb|E-Fb|E#-F|F#-Gb|G|G#-Ab|A|A#-Bb|B-Cb".split("|").forEach(function(t,e){t.split("-").forEach(function(t){n[t]=e})}),r.getFrequency=function(t){var s=t.split(o),i=n[s[0]],r=(s[1]||4)-4;return e*Math.pow(Math.pow(2,1/12),i)*Math.pow(2,r)},r.getDuration=function(t){return s.test(t)?parseFloat(t):t.toLowerCase().split("").reduce(function(t,e){return t+("w"===e?4:"h"===e?2:"q"===e?1:"e"===e?.5:"s"===e?.25:0)},0)},c.prototype.createFxNodes=function(){var t=this.gain=this.ac.createGain();return[["bass",100],["mid",1e3],["treble",2500]].forEach(function(e,s){(s=this[e[0]]=this.ac.createBiquadFilter()).type="peaking",s.frequency.value=e[1],t.connect(t=s)}.bind(this)),t.connect(this.ac.destination),this},c.prototype.push=function(){return Array.prototype.forEach.call(arguments,function(t){this.notes.push(t instanceof r?t:new r(t))}.bind(this)),this},c.prototype.createCustomWave=function(t,e){e||(e=t),this.waveType="custom",this.customWave=[new Float32Array(t),new Float32Array(e)]},c.prototype.createOscillator=function(){return this.stop(),this.osc=this.ac.createOscillator(),this.customWave?this.osc.setPeriodicWave(this.ac.createPeriodicWave.apply(this.ac,this.customWave)):this.osc.type=this.waveType||"square",this.osc.connect(this.gain),this},c.prototype.scheduleNote=function(t,e){var s=60/this.tempo*this.notes[t].duration,i=s*(1-(this.staccato||0));return this.setFrequency(this.notes[t].frequency,e),this.smoothing&&this.notes[t].frequency&&this.slide(t,e,i),this.setFrequency(0,e+i),e+s},c.prototype.getNextNote=function(t){return this.notes[t<this.notes.length-1?t+1:0]},c.prototype.getSlideStartDelay=function(t){return t-Math.min(t,60/this.tempo*this.smoothing)},c.prototype.slide=function(t,e,s){var i=this.getNextNote(t),o=this.getSlideStartDelay(s);return this.setFrequency(this.notes[t].frequency,e+o),this.rampFrequency(i.frequency,e+s),this},c.prototype.setFrequency=function(t,e){return this.osc.frequency.setValueAtTime(t,e),this},c.prototype.rampFrequency=function(t,e){return this.osc.frequency.linearRampToValueAtTime(t,e),this},c.prototype.play=function(t){return t="number"==typeof t?t:this.ac.currentTime,this.createOscillator(),this.osc.start(t),this.notes.forEach(function(e,s){t=this.scheduleNote(s,t)}.bind(this)),this.osc.stop(t),this.osc.onended=this.loop?this.play.bind(this,t):null,this},c.prototype.stop=function(){return this.osc&&(this.osc.onended=null,this.osc.disconnect(),this.osc=null),this},t.Note=r,t.Sequence=c});var Q={},K=Q&&Q.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Q,"__esModule",{value:!0});var Kc,Lc,d,Nc=K(H),Oc=K(ua),Pc=K(t),Qc=K(y),Rc=K(B),Sc=K(U),Ya=5,Pa=16*b.TS*Ya,Vc=window.AudioContext||window.webkitAudioContext,Wc=new Vc,Xc=120,h={duration:1e3,nextLevelAlpha:0,prevLevelAlpha:1,prevLevelScale:1,running:!1,startTime:0},Zc=!1,Ba=null,ya=null,ad=function(){function t(t){this.tstamp=0,this.ss=Ya,this.sf=1,this.nextAlpha=1,this.p=new Nc.default(this),this.p.skills.push("WEATHER"),this.canvas=t,(d=t.getContext("2d",{alpha:!1})).mozImageSmoothingEnabled=!1,d.webkitImageSmoothingEnabled=!1,this.levels={convo:new Pc.default(this),startScreen:new Qc.default(this),world:new Rc.default(this)},this.c=new Oc.default(this)}return t.prototype.boxPos=function(){return{x:(this.canvas.width-b.BS.w*this.ss)/2,y:(this.canvas.height-b.BS.h*this.ss)/2}},t.prototype.inTr=function(){return h.running},t.prototype.update=function(t){if(Zc||(this.tstamp=t,this.switchLevel(this.levels.startScreen),this.resize(),Zc=!0),this.tstamp=t,this.cl.update(t),this.inTr()){var $=(t-h.startTime)/h.duration;h.prevLevelScale=u(1,5,1,5,$),h.prevLevelAlpha=u(1,0,0,1,$),h.nextLevelAlpha=u(0,1,0,1,$),this.nextAlpha=h.nextLevelAlpha,$>=1&&(h.running=!1,ya=null)}},t.prototype.draw=function(t){var $=this;if(d&&this.c){this.c.updateShake(t),this.inTr()&&(d.globalAlpha=h.nextLevelAlpha),d.fillStyle=this.cl.bgColor,d.fillRect(0,0,this.canvas.width,this.canvas.height);var e=this.c.offset;if(this.cl.dables.forEach(function(a){a.forEach(function(a){if(a&&a.visible){var r=a.pos.x*$.ss+e.x,i=a.pos.y*$.ss+e.y;r+a.dSize.w<0||r>$.canvas.width||i+a.dSize.h<0||i>$.canvas.height||(d.translate(r+.5|0,i+.5|0),d.globalAlpha=$.inTr()?h.nextLevelAlpha:1,a.draw(d,t),d.setTransform(1,0,0,1,0,0))}})}),d.globalAlpha=1,ya){d.globalAlpha=h.prevLevelAlpha;var a=h.prevLevelScale,r=(this.canvas.width*a-this.canvas.width)/2,i=(this.canvas.height*a-this.canvas.height)/2;d.drawImage(ya,-r,-i,this.canvas.width*a,this.canvas.height*a),d.globalAlpha=1}this.inTr()&&(d.globalAlpha=h.nextLevelAlpha),this.cl.odables.forEach(function($){$.visible&&$.draw(d,t)}),d.globalAlpha=1}},t.prototype.resize=function(){var t=window.innerWidth/window.innerHeight;t>=1?Lc=(Kc=Pa)/t:Kc=(Lc=Pa)*t,this.canvas.width=Kc,this.canvas.height=Lc,this.c.size={w:this.canvas.width,h:this.canvas.height},this.sf=window.innerWidth/this.canvas.width,this.cl&&this.cl.resize()},t.prototype.pa=function(t,$){void 0===$&&($=1);var e={a:[["- e"],[]],bad:[["C2 e","C1 q"],["A3 e","A2 q"]],good:[["C2 e","- s","C2 e","C3 q"],["A3 e","- s","A3 e","A4 q"]],walk:[["C1 s"],["- e"]]};[Z(new Array($).fill(e[t][0])),Z(new Array($).fill(e[t][1]))].map(function(t){return new Sc.default.Sequence(Wc,Xc,t)}).forEach(function(t){t.gain.gain.value=.01,t.loop=!1,t.play()})},t.prototype.qLevel=function(t,$){Ba=t,$&&(Ba.state=$),h.startTime=this.tstamp,h.running=!0,(ya=new Image).src=this.canvas.toDataURL("png"),this.switchLevel(Ba)},t.prototype.handleInput=function(t){this.cl.handleInput(t.key)},t.prototype.handleTouch=function(t){this.cl.handleTouch(t)},t.prototype.sizeInTiles=function(){return{w:Math.ceil(this.canvas.width/this.ss/b.TS),h:Math.ceil(this.canvas.height/this.ss/b.TS)}},t.prototype.switchLevel=function(t){this.cl=t,this.cl.levelWillStart(),this.cl.configViz(),this.cl.levelStarted()},t}(),bd=ad;Q.default=bd;var oa={};Object.defineProperty(oa,"__esModule",{value:!0});function dd(t,$,e){var r=0,u=0;return function(a){for(r+=Math.min(a-u,10*b.MS),u=a;r>=t;)$.call(e,a),r-=t}}var ed=dd;oa.default=ed;var S={},La=S&&S.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(S,"__esModule",{value:!0});var hd=La(Q),id=La(oa),jd=document.getElementById("game"),m=new hd.default(jd),ld=id.default(b.MS,m.update,m),Fa=null,nd=!1,od=!1;function za($){Fa&&nd&&m.handleTouch(Fa),ld($),m.draw($),requestAnimationFrame(za)}function Va($){od||(m.pa("a",1),od=!0),sa($),nd=!0}function sa($){$.preventDefault();var a=$;$.touches&&(a=$.changedTouches[0]),Fa=a}function Ja(){Fa=null,nd=!1}requestAnimationFrame(za),window.onresize=m.resize.bind(m),window.onkeydown=m.handleInput.bind(m),window.onmousedown=Va,window.ontouchstart=Va,window.onmouseup=Ja,window.ontouchend=Ja,window.addEventListener("onmousemove",sa,{passive:!1}),window.addEventListener("touchmove",sa,{passive:!1});if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=S}else if(typeof define==="function"&&define.amd){define(function(){return S})}})();</script>