.9&&(t++,a=" (+1 choice)"),0===_p?(e++,t++,l=" (+1 upgrade and choice)"):_p<=3&&(t++,l=" (+1 choice)");e--;){let _=function(_){let e=_x().map(_=>({..._,score:Math.random()+(_M[_.id]||0)})).sort((_,e)=>_.score-e.score).filter(_=>A[_.id]<_.max).slice(0,_).sort((_,e)=>_.id>e.id?1:-1);return e.forEach(_=>{_S(_.id)}),e.map(_=>({text:_.name+(A[_.id]?" lvl "+(A[_.id]+1):""),icon:W["icon:"+_.id],value:_.id,help:_.help(A[_.id]+1)}))}(t+A.one_more_choice-A.instant_upgrade);if(!_.length)break;let o=`
You just finished level ${G+1}/${_N()} and picked those upgrades so far :
${_W()}
`,s=await et({title:"Pick an upgrade "+(e?"("+(e+1)+")":""),actions:_,text:`
You caught ${_o-_u} coins ${a} out of ${_v} in ${Math.round(_7/1e3)} seconds${r}.
You missed ${_p} times ${l}.
${r&&a&&l&&"Impressive, keep it up !"||(r||a||l)&&"Well done !"||"Try to catch all coins, never miss the bricks or clear the level under 30s to gain additional choices and upgrades."}
`,allowClose:!1,textAfterButtons:o});A[s]++,"instant_upgrade"===s&&(e+=2),_Z.upgrades_picked++}P(void 0,void 0),_m()}function _f(_){Z(!1),_>0&&_k().then(),G=_,_8=0,_V=_7=0,_u=_o,_v=0,_p=0,_Z.levelsPlayed++,P(void 0,void 0),_e(),_m();let t=_w();t.size!==E&&(E=t.size,__()),_d=[],_g=[...t.bricks],_y=[],U.src="data:image/svg+xml;UTF8,"+t.svg,em(),function(){if(!ea("record"))return;!o&&(s=(o=document.createElement("canvas")).getContext("2d",{antialias:!1,alpha:!1}),l=(a=o.captureStream(0)).getVideoTracks()[0],ea("sound")&&_5()&&e&&a.addTrack(e.stream.getAudioTracks()[0])),o.width=N,o.height=Y;let _=[],t=new MediaRecorder(a,{videoBitsPerSecond:35e5});r=t,t.start(),r.pause(),t.ondataavailable=function(e){_.push(e.data)},t.onstop=async function(){let e;let t=new Blob(_,{type:"video/webm"});if(t.size<2e5)return;for(;!(e=document.getElementById("level-recording-container"));)await new Promise(_=>setTimeout(_,200));let r=document.createElement("video");r.autoplay=!0,r.controls=!1,r.disablePictureInPicture=!0,r.disableRemotePlayback=!0,r.width=o.width,r.height=o.height,r.loop=!0,r.muted=!0,r.playsInline=!0,r.src=URL.createObjectURL(t);let a=document.createElement("a");a.download=function(_="webm"){return"breakout-71-capture-"+new Date().toISOString().replace(/[^0-9\-]+/gi,"-")+"."+_}("webm"),a.target="_blank",a.href=r.src,a.textContent=`Download video (${(t.size/1e6).toFixed(2)}MB)`,e.appendChild(r),e.appendChild(a)}}()}function _w(){return B[G%B.length]}let _z=_I();function _x(){return f.filter(_=>_z>=_.threshold).filter(_=>!_?.requires||A[_?.requires])}let _M={};function _S(_){_M[_]=Math.round(Date.now()/1e3)}let _B={},_G=!1,_R=0;function _L(_){for(let _ of(_z=_I(),!function(_=null){let e=_B?.level;delete _B.level;let t=_B?.level?k.filter(_=>_.name===e):[],r=k.filter(_=>_z>=_.threshold).filter(_=>_.name!==_B?.level).filter(e=>e.name!==_||1===k.length).sort(()=>Math.random()-.5);B=t.concat(r.slice(0,10).sort((_,e)=>_.sortKey-e.sortKey))}(_7||_o?_w().name:null),_Z=_q(),_o=0,_R=0,f))A[_.id]=0;if(_)Object.assign(A,_),_G=!0;else{_G=!1;let _=_x().filter(_=>_.giftable),e=_B?.perk||ea("easy")&&"slow_down"||_[Math.floor(Math.random()*_.length)].id;A[e]=1,delete _B.perk,_S(e)}_f(0),eh()}let _A=0;function _C(_){X=!0,(V=_)F+N-L/2&&(V=F+N-L/2),H||_7||_b()}z.addEventListener("mouseup",_=>{0===_.button&&(H?Z(!0):(q(),ea("pointerLock")&&z.requestPointerLock().then()))}),z.addEventListener("mousemove",_=>{document.pointerLockElement===z?_C(V+_.movementX):_C(_.x)}),z.addEventListener("touchstart",_=>{_.preventDefault(),_.touches?.length&&(_C(_.touches[0].pageX),q())}),z.addEventListener("touchend",_=>{_.preventDefault(),Z(!0)}),z.addEventListener("touchcancel",_=>{_.preventDefault(),Z(!0),X=!0}),z.addEventListener("touchmove",_=>{_.touches?.length&&_C(_.touches[0].pageX)});let _O=performance.now();function _T(_,e){return _a(Math.floor(e/j),Math.floor((_-I)/j))}function _P(_){if(_g[_])return _}function _E(_,e,t){return _P(_T(_-t,e-t))??_P(_T(_+t,e-t))??_P(_T(_+t,e+t))??_P(_T(_-t,e+t))}function _H(_,e,t){if(_.destroyed)return;_.previousX=_.x,_.previousY=_.y,_.x+=_.vx*t,_.y+=_.vy*t,_.sx||=0,_.sy||=0,_.sx+=_.previousX-_.x,_.sy+=_.previousY-_.y,_.sx*=.9,_.sy*=.9,A.wind&&(_.vx+=(V-(I+D/2))/D*A.wind*.5);let r=0,a=0;return _.xK-F-e&&(_.x=K-F-e,_.vx*=-1,a=1),a+2*r}let _V=0;function _$(_){return A.telekinesis&&!_.hitSinceBounce&&_.vy<0}const _q=()=>({started:Date.now(),levelsPlayed:0,runTime:0,coins_spawned:0,score:0,bricks_broken:0,misses:0,balls_lost:0,puck_bounces:0,upgrades_picked:1,max_combo:1,max_level:0});let _Z=_q();function _I(){try{return JSON.parse(localStorage.getItem("breakout_71_total_score")||"0")}catch(_){return 0}}function _F(_,e){let t;if(!H)return;Z(!0),em(),function(_){try{localStorage.setItem("breakout_71_total_play_time",JSON.stringify(JSON.parse(localStorage.getItem("breakout_71_total_play_time")||"0")+_))}catch(_){}}(_Z.runTime),_Z.max_level=G+1;let r=-300,a=()=>"animation-delay:"+(r+=800)+"ms;",l="",o=_I(),s=o-_o,i=(t=[],f.forEach(_=>{_.threshold&&t.push({threshold:_.threshold,title:_.name+" (Perk)"})}),k.forEach(_=>{t.push({threshold:_.threshold,title:_.name+" (Level)"})}),t.filter(_=>_.threshold).sort((_,e)=>_.threshold-e.threshold));i.filter(_=>_.threshold>s&&_.threshold{l+=`
${_.title}
`});let c=function(_,e){let t=_.length;for(;--t;)if(e(_[t],t,_))return _[t]}(i,_=>_.threshold<=o)?.threshold||0,n=i.find(_=>_.threshold>o);if(n){let _=n?.threshold-c;e+=`Score ${n.threshold-o} more points to reach the next unlock.`;let t=((o-c)/_).toFixed(2);l+=`
${n.title}
`,i.slice(i.indexOf(n)+1).slice(0,3).forEach(_=>{l+=`
${_.title}
`})}O=1,et({allowClose:!0,title:_,text:`
${_G?"This test run and its score are not being recorded
":""}
${e}
${l}
`,actions:[{value:null,text:"Start a new run",help:""}],textAfterButtons:`
${function(){let _="";try{let e=JSON.parse(localStorage.getItem("breakout_71_runs_history")||"[]");e.sort((_,e)=>_.score-e.score).reverse(),(e=e.slice(0,100)).push({..._Z,perks:A,appVersion:y}),_G||localStorage.setItem("breakout_71_runs_history",JSON.stringify(e,null,2));let t=(_,t,r)=>{let a=e.map(_=>t(_)||0),l=Math.min(...a),o=Math.max(...a);if(l===o)return"";o-l<10&&(l=Math.max(0,o-10),o=Math.max(o,l+10));let s=Math.min(a.length,10);if(s<3)return"";let i=[],c=[];for(let _=0;_Math.min(i.length-1,Math.floor((_-l)/n));if(a.forEach(_=>{if(isNaN(_))return;let e=h(_);i[e]++,c[e]+=_}),i.filter(_=>_).length<3)return"";let m=Math.max(...i),b=a[a.length-1],g=h(b),y=i.map((_,e)=>{let t=`height: ${_/m*80}px`;return`${!_&&" "||e==g&&b+r||Math.round(c[e]/_)+r}`}).join("");return`${_} : ${b}${r}
${y}
`};_+=t("Total score",_=>_.score,""),_+=t("Catch rate",_=>Math.round(_.score/_.coins_spawned*100),"%"),_+=t("Bricks broken",_=>_.bricks_broken,""),_+=t("Bricks broken per minute",_=>Math.round(_.bricks_broken/_.runTime*6e4)," bpm"),_+=t("Hit rate",_=>Math.round((1-_.misses/_.puck_bounces)*100),"%"),_+=t("Duration per level",_=>Math.round(_.runTime/1e3/_.levelsPlayed),"s"),_+=t("Level reached",_=>_.levelsPlayed,""),_+=t("Upgrades applied",_=>_.upgrades_picked,""),_+=t("Balls lost",_=>_.balls_lost,""),_+=t("Average combo",_=>Math.round(_.coins_spawned/_.bricks_broken),""),(_+=t("Max combo",_=>_.max_combo,""))&&(_=`Find below your run statistics compared to your ${e.length-1} best runs.
`+_)}catch(_){console.warn(_)}return _}()}
`}).then(()=>_L())}function _D(_,e,t){let r=_g[_];if(r){if("black"===r){delete _g[_];let t=_t(_),r=_r(_);_4.explode(e.x);let a=_%E,l=Math.floor(_/E),o=1+A.bigger_explosions;for(let _=-o;_<=o;_++)for(let t=-o;t<=o;t++){let r=_a(l+t,a+_);_g[r]&&-1!==r&&_D(r,e,!0)}_d.forEach(_=>{let e=_.x-t,a=_.y-r,l=Math.max(j,Math.abs(e)+Math.abs(a));_.vx+=e/l*10*o/_.weight,_.vy+=a/l*10*o/_.weight}),_s=Date.now(),_y.push({type:"ball",duration:150,time:_7,size:2*j,color:"white",x:t,y:r}),_l(7*(1+A.bigger_explosions),t,r,"white",150,S),e.hitSinceBounce++,_Z.bricks_broken++}else if(r){if(e.hitSinceBounce++,A.sturdy_bricks&&A.sturdy_bricks>5*Math.random()){_4.coinBounce(e.x,1);return}let a=_t(_),l=_r(_);_g[_]="";let o=O;A.sturdy_bricks&&(o+=Math.ceil((10+A.sturdy_bricks)/10*o)),_v+=o,_Z.coins_spawned+=o,_Z.bricks_broken++;let s=400*(ea("basic")?.5:1),i=Math.max(1,Math.ceil(o/(_d.length>400?1:Math.floor(s-_d.length)/3)));for(;o>0;){let _=Math.min(i,o);(_<0||isNaN(_))&&console.error({points:_}),o-=_;let t=a+(Math.random()-.5)*(j-S),s=l+(Math.random()-.5)*(j-S);_d.push({points:_,color:A.metamorphosis?r:"gold",x:t,y:s,previousX:t,previousY:s,vx:e.previousVX*(.5+Math.random()),vy:e.previousVY*(.5+Math.random()),sx:0,sy:0,a:Math.random()*Math.PI*2,sa:Math.random()-.5,weight:.8+.2*Math.random()})}O+=Math.max(0,A.streak_shots+A.compound_interest+A.left_is_lava+A.right_is_lava+A.top_is_lava+A.picky_eater-Math.round(Math.random()*A.soft_reset)),t||((A.picky_eater||A.pierce_color)&&r!==_h&&r?(A.picky_eater&&P(e.x,e.y),_h=r):_4.comboIncreaseMaybe(e.x,1)),_y.push({type:"ball",duration:40,time:_7,size:j,color:r,x:a,y:l}),_l(5+Math.min(O,30),a,l,r,150,S/2)}_g[_]||"black"===r||e.hitItem?.push({index:_,color:r})}}function _N(){return 7+A.extra_levels}let _Y=document.createElement("canvas"),_j="",_X={};function _U(_,e,t,r,a=0){let l="puck"+e+"_"+t+"_"+r;if(!_X[l]){let _=document.createElement("canvas");_.width=t,_.height=2*r;let a=_.getContext("2d");a.fillStyle=e,a.beginPath(),a.moveTo(0,2*r),a.lineTo(0,1.25*r),a.bezierCurveTo(0,.75*r,t,.75*r,t,1.25*r),a.lineTo(t,2*r),a.fill(),_X[l]=_}_.drawImage(_X[l],Math.round(V-t/2),Y-2*r+a)}function _J(_,e,t,r,a,l=""){let o="ball"+e+"_"+t+"_"+l,s=Math.round(t);if(!_X[o]){let _=document.createElement("canvas");_.width=s,_.height=s;let t=_.getContext("2d");t.beginPath(),t.arc(s/2,s/2,Math.round(s/2)-1,0,2*Math.PI),t.fillStyle=e,t.fill(),l&&(t.lineWidth=2,t.strokeStyle=l,t.stroke()),_X[o]=_}_.drawImage(_X[o],Math.round(r-s/2),Math.round(a-s/2))}function _K(_,e,t,r,a,l,o){let s=(Math.round(o/Math.PI*64)%32+32)%32,i="coin with halo_"+e+"_"+t+"_"+l+"_"+("gold"===e?s:"whatever");if(!_X[i]){let _=document.createElement("canvas");_.width=t,_.height=t;let r=_.getContext("2d");r.beginPath(),r.arc(t/2,t/2,t/2,0,2*Math.PI),r.fillStyle=e,r.fill(),"gold"===e&&(r.strokeStyle=l,r.stroke(),r.beginPath(),r.arc(t/2,t/2,t/2*.6,0,2*Math.PI),r.fillStyle="rgba(255,255,255,0.5)",r.fill(),r.translate(t/2,t/2),r.rotate(s/16),r.translate(-t/2,-t/2),r.globalCompositeOperation="multiply",_1(r,"$",e,t-2,t/2,t/2+1),_1(r,"$",e,t-2,t/2,t/2+1)),_X[i]=_}_.drawImage(_X[i],Math.round(r-t/2),Math.round(a-t/2))}function _Q(_,e,t,r,a){let l="fuzzy-circle"+e+"_"+t,o=Math.round(3*t);if(!_X[l]){let _=document.createElement("canvas");_.width=o,_.height=o;let t=_.getContext("2d"),r=t.createRadialGradient(o/2,o/2,0,o/2,o/2,o/2);r.addColorStop(0,e),r.addColorStop(1,"transparent"),t.fillStyle=r,t.fillRect(0,0,o,o),_X[l]=_}_.drawImage(_X[l],Math.round(r-o/2),Math.round(a-o/2))}function _1(_,e,t,r,a,l,o=!1){let s="text"+e+"_"+t+"_"+r+"_"+o;if(!_X[s]){let _=document.createElement("canvas");_.width=r*e.length,_.height=r;let a=_.getContext("2d");a.fillStyle=t,a.textAlign=o?"left":"center",a.textBaseline="middle",a.font=r+"px monospace",a.fillText(e,o?0:_.width/2,_.height/2,_.width),_X[s]=_}_.drawImage(_X[s],o?a:Math.round(a-_X[s].width/2),Math.round(l-_X[s].height/2))}let _2=NaN,_0=6;function _3(_,e,t){(_0+=_)>11&&(_0=0),_0<0&&(_0=11);let r=_=>{let r=392*Math.pow(1.05945594920268,_),a=Math.abs(_-5.5),l=Math.max(0,t*(1-a/16.5));return _6(r,e,l),r.toFixed(2)+" at "+Math.floor(100*l)+"% diff "+a};r(12+_0),r(_0),r(-12+_0)}const _4={wallBeep:_=>{ea("sound")&&_6(800,(_-I)/D)},comboIncreaseMaybe:(_,e)=>{if(!ea("sound"))return;let t=0;!isNaN(_2)&&(_2O&&(t=-1)),_3(t,(_-I)/D,e),_2=O},comboDecrease(){ea("sound")&&_3(-1,.5,.5)},coinBounce:(_,e)=>{ea("sound")&&_6(1200,(_-I)/D,e,.1,"triangle")},explode:_=>{ea("sound")&&!function(_=.5){let r=_5();if(!t){let _=2*r.sampleRate,e=(t=r.createBuffer(1,_,r.sampleRate)).getChannelData(0);for(let t=0;t<_;t++)e[t]=2*Math.random()-1}let a=r.createBufferSource();a.buffer=t;let l=r.createGain();a.connect(l);let o=r.createBiquadFilter();o.type="lowpass",o.frequency.setValueAtTime(1e3,r.currentTime),l.connect(o);let s=r.createStereoPanner();s.pan.setValueAtTime(2*_-1,r.currentTime),o.connect(s),s.connect(r.destination),s.connect(e),l.gain.setValueAtTime(1,r.currentTime),l.gain.exponentialRampToValueAtTime(.01,r.currentTime+1),o.frequency.exponentialRampToValueAtTime(60,r.currentTime+1),a.start(r.currentTime),a.stop(r.currentTime+1)}((_-I)/D)},revive:()=>{ea("sound")&&function(_=440){let t=_5(),r=[t.createOscillator(),t.createOscillator(),t.createOscillator()];r.forEach((e,r)=>{e.type="sine",e.frequency.setValueAtTime(_+2*r,t.currentTime)});let a=t.createGain();r.forEach(_=>_.connect(a));let l=t.createStereoPanner();l.pan.setValueAtTime(0,t.currentTime),a.connect(l),l.connect(t.destination),l.connect(e),a.gain.setValueAtTime(0,t.currentTime),a.gain.linearRampToValueAtTime(.5,t.currentTime+.5),a.gain.exponentialRampToValueAtTime(.001,t.currentTime+2),r.forEach(_=>_.start(t.currentTime)),r.forEach(_=>_.stop(t.currentTime+2))}(500)},coinCatch(_){ea("sound")&&_6(900,(_-I)/D,.8,.1,"triangle")}};function _5(){return _||(e=(_=new(window.AudioContext||window.webkitAudioContext)).createMediaStreamDestination()),_}function _6(_=800,t=.5,r=1,a=.1,l="sine"){let o=_5(),s=o.createOscillator();s.type=l,s.frequency.setValueAtTime(_,o.currentTime);let i=o.createGain();s.connect(i);let c=o.createStereoPanner();c.pan.setValueAtTime(2*t-1,o.currentTime),i.connect(c),c.connect(o.destination),c.connect(e),i.gain.setValueAtTime(.8*r,o.currentTime),i.gain.exponentialRampToValueAtTime(.001,o.currentTime+a),s.start(o.currentTime),s.stop(o.currentTime+a)}let _7=0,_8=0;window.addEventListener("visibilitychange",()=>{document.hidden&&Z(!0)});const _9=document.getElementById("score");let e_=0,ee=null;function et({title:_,text:e,actions:t,allowClose:r=!0,textAfterButtons:a="",actionsAsGrid:l=!1}){return e_++,new Promise(o=>{let s=document.createElement("div");function i(_){o(_),setTimeout(()=>{document.body.removeChild(s)})}if(document.body.appendChild(s),s.className="popup "+(l?"actionsAsGrid ":""),r){let _=document.createElement("button");_.title="close",_.className="close-modale",_.addEventListener("click",_=>{_.preventDefault(),i(void 0)}),ee=()=>{i(void 0)},s.appendChild(_)}let c=document.createElement("div");if(_){let e=document.createElement("h2");e.innerHTML=_,c.appendChild(e)}if(e){let _=document.createElement("div");_.innerHTML=e,c.appendChild(_)}let n=document.createElement("section");if(c.appendChild(n),t?.filter(_=>_).forEach(({text:_,value:e,help:t,disabled:r,className:a="",icon:l=""})=>{let o=document.createElement("button");o.innerHTML=`
${l}
${_}
${t||""}
`,r?o.setAttribute("disabled","disabled"):o.addEventListener("click",_=>{_.preventDefault(),i(e)}),o.className=a,n.appendChild(o)}),a){let _=document.createElement("div");_.className="textAfterButtons",_.innerHTML=a,c.appendChild(_)}s.appendChild(c),c.querySelector("button:not([disabled])")?.focus()}).then(_=>(e_--,ee=null,_),()=>{ee=null,e_--})}let er={};function ea(_){if(void 0===er[_])try{let e=localStorage.getItem("breakout-settings-enable-"+_);e&&(er[_]=JSON.parse(e))}catch(_){console.warn(_)}return er[_]??w[_]?.default??!1}async function el(){Z(!0);let _=await et({title:` ${_o} points at level ${G+1} / ${_N()}`,text:`
${_G?"This is a test run, score is not recorded permanently
":""}
Upgrades picked so far :
${_W()}
`,allowClose:!0,actions:[{text:"Resume",help:"Return to your run",value:()=>{}},{text:"Restart",help:"Start a brand new run.",value:()=>{_L()}}]});_&&_()}async function eo(){Z(!0);let _=[{text:"Resume",help:"Return to your run",value(){}},{text:"Starting perk",help:"Try perks and levels you unlocked",value(){es()}}];for(let e of Object.keys(w))w[e]&&_.push({disabled:w[e].disabled(),icon:ea(e)?W["icon:checkmark_checked"]:W["icon:checkmark_unchecked"],text:w[e].name,help:w[e].help,value:()=>{!function(_){er[_]=!ea(_);try{localStorage.setItem("breakout-settings-enable-"+_,JSON.stringify(er[_]))}catch(_){console.warn(_)}w[_].afterChange()}(e),eo()}});let e=Math.max(...f.map(_=>_.threshold));(document.fullscreenEnabled||document.webkitFullscreenEnabled)&&(null!==document.fullscreenElement?_.push({text:"Exit Fullscreen",icon:W["icon:exit_fullscreen"],help:"Might not work on some machines",value(){eb()}}):_.push({icon:W["icon:fullscreen"],text:"Fullscreen",help:"Might not work on some machines",value(){eb()}})),_.push({text:"Creative mode",help:_I()({icon:e.icon,text:e.name,help:(_[e.id]||0)+"/"+e.max,value:e,className:_[e.id]?"":"grey-out-unless-hovered"})),{text:"Start run",value:"start"}]});){if("start"===e){_L(_);break}e&&(_[e.id]=((_[e.id]||0)+1)%(e.max+1))}}}),_.push({text:"Reset Game",help:"Erase high score and statistics",async value(){await et({title:"Reset",actions:[{text:"Yes",value:!0},{text:"No",value:!1}],allowClose:!0})&&(localStorage.clear(),window.location.reload())}});let t=await et({title:"Breakout 71",text:"",allowClose:!0,actions:_,textAfterButtons:`
Made in France by Renan LE CARO.
Privacy Policy
F-Droid
Google Play
itch.io
Gitlab
Web version
HackerNews
v.${y}
`});t&&t()}async function es(){let _=_I(),e=[...f.sort((_,e)=>_.threshold-e.threshold).map(({name:e,id:t,threshold:r,icon:a,fullHelp:l})=>({text:e,help:_>=r?l:`Unlocks at total score ${r}.`,disabled:__.threshold-e.threshold).map(e=>{let t=_>=e.threshold;return{text:e.name,help:t?`A ${e.size}x${e.size} level with ${e.bricks.filter(_=>_).length} bricks`:`Unlocks at total score ${e.threshold}.`,disabled:!t,value:{level:e.name},icon:W[e.name]}})],t=Math.round(e.filter(_=>!_.disabled).length/e.length*100),r=await et({title:`You unlocked ${t}% of the game.`,text:`
Your total score is ${_}. Below are all the upgrades and levels the games has to offer.
${t<100?"The greyed out ones can be unlocked by increasing your total score. The total score increases every time you score in game.":""}
`,textAfterButtons:`
Your high score is ${_i}.
Click an item above to start a run with it.
`,actions:e,allowClose:!0});r&&(!G||await et({title:"Restart run to try this item?",text:"You're about to start a new run with the selected unlocked item, is that really what you wanted ? ",actions:[{value:!0,text:"Restart game to test item"},{value:!1,text:"Cancel"}]}))&&(_B=r,_L())}function ei(_,e){return Math.sqrt(Math.pow(_.x-e.x,2)+Math.pow(_.y-e.y,2))}function ec(){return`hsl(${2*Math.round(_7/4)%360},100%,70%)`}function en(_,e,t,r){let a=ei(_,e),l=D/2;if(a>l)return;let o=(_.x-e.x)/a,s=(_.y-e.y)/a,i=-t*(l-a)/(1.2*l)/3*Math.min(500,_7)/500;r&&void 0!==e.vx&&void 0!==e.vy&&(e.vx+=o*i,e.vy+=s*i),_.vx-=o*i,_.vy-=s*i,_y.push({type:"particle",duration:100,time:_7,size:S/2,color:ec(),ethereal:!0,x:_.x,y:_.y,vx:-(10*o)+_.vx+(Math.random()-.5)*2,vy:-(10*s)+_.vy+(Math.random()-.5)*2}),r&&void 0!==e.vx&&void 0!==e.vy&&_y.push({type:"particle",duration:100,time:_7,size:S/2,color:ec(),ethereal:!0,x:e.x,y:e.y,vx:10*o+e.vx+(Math.random()-.5)*2,vy:10*s+e.vy+(Math.random()-.5)*2})}function eh(){ea("record")&&r?.state==="recording"&&r?.pause()}function em(){ea("record")&&r&&(r?.stop(),r=null)}function eb(){try{if(null!==document.fullscreenElement)document.exitFullscreen?document.exitFullscreen().then():document.webkitCancelFullScreen&&document.webkitCancelFullScreen();else{let _=document.documentElement;_.requestFullscreen?_.requestFullscreen().then():_.webkitRequestFullscreen&&_.webkitRequestFullscreen()}}catch(_){console.warn(_)}}_9.addEventListener("click",_=>{_.preventDefault(),el().then()}),document.getElementById("menu")?.addEventListener("click",_=>{_.preventDefault(),eo().then()});const eg={ArrowLeft:0,ArrowRight:0,Shift:0};function ey(_,e){eg[_]=e,_A=(eg.ArrowRight-eg.ArrowLeft)*(1+2*eg.Shift)*D/50}document.addEventListener("keydown",_=>{"f"!==_.key.toLowerCase()||_.ctrlKey||_.metaKey?_.key in eg&&ey(_.key,1):eb()," "===_.key&&!e_&&(H?Z(!0):q(),_.preventDefault())}),document.addEventListener("keyup",_=>{let e=document.querySelector("button:focus");if(_.key in eg)ey(_.key,0);else if("ArrowDown"===_.key&&e?.nextElementSibling?.tagName==="BUTTON")e?.nextElementSibling?.focus();else if("ArrowUp"===_.key&&e?.previousElementSibling?.tagName==="BUTTON")e?.previousElementSibling?.focus();else if("Escape"===_.key&&ee)ee();else if("Escape"===_.key&&H)Z(!0);else if("m"!==_.key.toLowerCase()||e_){if("s"!==_.key.toLowerCase()||e_)return;el().then()}else eo().then();_.preventDefault()}),__(),_L(),function _(){_e();let e=performance.now();if(L=D/12*(3-A.smaller_puck+A.bigger_puck),_A&&_C(V+_A),H){_7+=e-_O,_Z.runTime+=e-_O,_Z.max_combo=Math.max(_Z.max_combo,O);let _=Math.min(4,(e-_O)/(1e3/60));_*=+!!H,_d=_d.filter(_=>!_.destroyed),_n=_n.filter(_=>!_.destroyed);let t=_g.filter(_=>_&&"black"!==_).length;if(_7>_V+1e3&&A.hot_start&&(_V=_7,function(_,e,t){let r=Math.max(0,O-(O=Math.max(T(),O-_)));r&&(_4.comboDecrease(),void 0!==e&&void 0!==t&&_y.push({type:"text",text:"-"+r,time:_7,color:"red",x:e,y:t,duration:300,size:20}))}(A.hot_start,V,Y-40)),t<=A.skip_last&&!_8&&(_g.forEach((_,e)=>{_&&_D(e,_n[0],!0)}),_8++),t||_d.length){if(H||_7){let e=!1,t=Math.round(S/2);if(_d.forEach(r=>{if(r.destroyed)return;A.coin_magnet&&(r.vx+=_*(V-r.x)/(100+Math.pow(r.y-Y,2)+Math.pow(r.x-V,2))*A.coin_magnet*100);let a=1-(.03*A.viscosity+.005)*_;r.vy*=a,r.vx*=a,r.vx>7*C&&(r.vx=7*C),r.vx<-7*C&&(r.vx=-7*C),r.vy>7*C&&(r.vy=7*C),r.vy<-7*C&&(r.vy=-7*C),r.a+=r.sa,r.vy+=_*r.weight*.8;let l=Math.abs(r.sx)+Math.abs(r.sx),o=_H(r,t,_);if(r.y>Y-t-20&&r.y_i&&!_G&&(_i=_o,localStorage.setItem("breakout-3-hs",_o.toString())),ea("basic")||_y.push({type:"particle",duration:100+50*Math.random(),time:_7,size:S/2,color:r.color,x:r.previousX,y:r.previousY,vx:(K-r.x)/100,vy:-r.y/100,ethereal:!0}),Date.now()-_c>16&&(_c=Date.now(),_4.coinCatch(r.x)),_Z.score+=r.points;else r.y>Q+t&&(r.destroyed=!0,A.compound_interest&&P(r.x,r.y));let s=function(_){let e=S/2,{x:t,y:r,previousX:a,previousY:l}=_,o=_E(a,r,e),s=_E(t,l,e),i=void 0===o&&void 0===s&&_E(t,r,e)||void 0;if(void 0!==o||void 0!==i){_.y=_.previousY,_.vy*=-1;let a=_g[_T(t-e,r+e)],l=_g[_T(t+e,r+e)];a&&!l&&(_.vx+=1,_.sa-=1),!a&&l&&(_.vx-=1,_.sa+=1)}return(void 0!==s||void 0!==i)&&(_.x=_.previousX,_.vx*=-1),o??s??i}(r);A.metamorphosis&&void 0!==s&&_g[s]&&r.color!==_g[s]&&"black"!==_g[s]&&!r.coloredABrick&&(_g[s]=r.color,r.coloredABrick=!0),(void 0!==s||o)&&(r.vx*=.8,r.vy*=.8,r.sa*=.9,l>20&&!e&&(e=!0,_4.coinBounce(r.x,.2)),3>Math.abs(r.vy)&&(r.vy=0))}),_n.forEach(e=>(function(_,e){_.previousVX=_.vx,_.previousVY=_.vy;let t=1+A.telekinesis+A.ball_repulse_ball+A.puck_repulse_ball+A.ball_attract_ball;if(_$(_)&&(t+=3,_.vx+=(V-_.x)/1e3*e*A.telekinesis),_.vx*_.vx+_.vy*_.vy0?1:-1)*.02/t),A.ball_repulse_ball)for(let e of _n)e.x>=_.x||en(_,e,A.ball_repulse_ball,!0);if(A.ball_attract_ball)for(let e of _n)e.x>=_.x||function(_,e,t){let r=ei(_,e),a=.5*D;if(r1&&!ea("basic"))for(let e=0;e<_.hitItem?.length-1&&e.5,l=Math.random()>.5?1:-1,o=Math.random()>.5?1:-1;_y.push({type:"particle",duration:250,ethereal:!0,time:_7,size:S/2,color:r,x:_t(t)+l*j/2,y:_r(t)+o*j/2,vx:a?0:-l*C,vy:a?-o*C:0})}let r=_H(_,10,e);r&&(A.left_is_lava&&r%2&&_.xI+D/2&&P(_.x,_.y),A.top_is_lava&&r>=2&&P(_.x,_.y+20),_4.wallBeep(_.x),_.bouncesList?.push({x:_.previousX,y:_.previousY}));let a=Y-20-10;if(_.y>a&&Math.abs(_.x-V)<10+L/2&&_.vy>0){let e=Math.sqrt(_.vx*_.vx+_.vy*_.vy),t=Math.atan2(-L/2,_.x-V);_.vx=e*Math.cos(t),_.vy=e*Math.sin(t),_4.wallBeep(_.x),A.streak_shots&&P(_.x,_.y),A.respawn&&_.hitItem.slice(0,-1).slice(0,A.respawn).forEach(({index:_,color:e})=>{_g[_]||"black"===e||(_g[_]=e)}),_.hitItem=[],_.hitSinceBounce||(_Z.misses++,_p++,P(_.x,_.y),_y.push({type:"text",text:"miss",duration:500,time:_7,size:30,color:"red",x:V,y:Y-40})),_Z.puck_bounces++,_.hitSinceBounce=0,_.sapperUses=0,_.piercedSinceBounce=0,_.bouncesList=[{x:_.previousX,y:_.previousY}]}_.y>Y+10&&H&&(_.destroyed=!0,_Z.balls_lost++,_n.find(_=>!_.destroyed)||(A.extra_life?(A.extra_life--,_m(),_4.revive(),Z(!1),_d=[],_y.push({type:"ball",duration:500,time:_7,size:2*j,color:"white",x:_.x,y:_.y})):_F("Game Over","You dropped the ball after catching "+_o+" coins. ")));let l=function(_){let{x:e,y:t,previousX:r,previousY:a}=_,l=_E(r,t,10),o=_E(e,a,10),s=void 0===l&&void 0===o&&_E(e,t,10)||void 0,i=_.piercedSinceBounce<3*A.pierce;return i&&(void 0!==l||void 0!==o||void 0!==s)&&_.piercedSinceBounce++,A.pierce_color&&(void 0===l||_g[l]===_h)&&(void 0===o||_g[o]===_h)&&(void 0===s||_g[s]===_h)&&(i=!0),void 0===l&&void 0===s||i||(_.y=_.previousY,_.vy*=-1),void 0===o&&void 0===s||i||(_.x=_.previousX,_.vx*=-1),l??o??s}(_);if(void 0!==l){let e=_g[l];_D(l,_,!1),_.sapperUses1&&(_y.push({type:"particle",duration:100*_.sparks,time:_7,size:S/2,color:_h,x:_.x,y:_.y,vx:(Math.random()-.5)*C,vy:(Math.random()-.5)*C,ethereal:!1}),_.sparks=0))})(e,_)),A.wind){let _=(V-(I+D/2))/D*2*A.wind;for(let e=0;e.5&&_y.push({type:"particle",duration:150,ethereal:!0,time:_7,size:S/2,color:ec(),x:F+Math.random()*N,y:Math.random()*Y,vx:8*_,vy:0})}_y.forEach(e=>{"particle"===e.type&&(e.x+=e.vx*_,e.y+=e.vy*_,!e.ethereal&&(e.vy+=.5,_P(_T(e.x,e.y))&&(e.destroyed=!0)))})}}else G+1<_N()?_f(G+1):_F("Run finished with "+_o+" points","You cleared all levels for this run.");if(O>T()){let _=!ea("basic")&&(O-T())*Math.random()>5&&H&&{type:"particle",duration:100*(Math.random()+1),time:_7,size:S/2,color:"red",ethereal:!0};if(A.top_is_lava&&_&&_y.push({..._,x:F+Math.random()*N,y:0,vx:(Math.random()-.5)*10,vy:5}),A.left_is_lava&&_&&_y.push({..._,x:F,y:Math.random()*Y,vx:5,vy:(Math.random()-.5)*10}),A.right_is_lava&&_&&_y.push({..._,x:F+N,y:Math.random()*Y,vx:-5,vy:(Math.random()-.5)*10}),A.compound_interest){let e=V,t=0;do e=F+N*Math.random(),t++;while(Math.abs(e-V){let{x:e,y:t,time:r,color:a,size:l,type:o,duration:s}=_;x.globalAlpha=Math.min(1,2-(_7-r)/s*2),"particle"===o&&_J(x,a,l,e,t)});else if(x.globalCompositeOperation="source-over",x.globalAlpha=.4,x.fillStyle="#000",x.fillRect(0,0,n,h),x.globalCompositeOperation="screen",x.globalAlpha=.6,_d.forEach(_=>{_.destroyed||_Q(x,_.color,2*S,_.x,_.y)}),_n.forEach(_=>{_Q(x,_h,40,_.x,_.y)}),x.globalAlpha=.5,_g.forEach((_,e)=>{if(!_)return;let t=_t(e),r=_r(e);_Q(x,"black"==_?"#666":_,j,t,r)}),x.globalAlpha=1,_y.forEach(_=>{let{x:e,y:t,time:r,color:a,size:l,type:o,duration:s}=_;x.globalAlpha=Math.min(1,2-(_7-r)/s*2),"ball"===o&&_Q(x,a,l,e,t),"particle"===o&&_Q(x,a,3*l,e,t)}),x.globalAlpha=.2,x.globalCompositeOperation="multiply",x.fillStyle="black",x.fillRect(0,0,n,h),x.globalAlpha=.8,x.globalCompositeOperation="multiply",c.svg&&U.width&&U.complete){if(J.title!==c.name){J.title=c.name,J.width=K,J.height=Q;let _=J.getContext("2d");_.fillStyle=c.color||"#000",_.fillRect(0,0,K,Q);let e=x.createPattern(U,"repeat");e&&(_.fillStyle=e,_.fillRect(0,0,n,h))}x.drawImage(J,0,0)}else x.fillStyle="#000",x.fillRect(0,0,n,h);x.globalAlpha=1,x.globalCompositeOperation="source-over";let b=Date.now()-_s+5,g=b<200;if(g){let _=(A.bigger_explosions+1)*50/b;x.translate(Math.sin(Date.now())*_,Math.sin(Date.now()+36)*_)}if(x.globalCompositeOperation="source-over",function(){x.globalAlpha=1;let _=O>T()&&A.picky_eater,e=D+"_"+_g.join("_")+R.complete+"_"+_+"_"+_h+"_"+A.pierce_color;if(e!==_j){_j=e,_Y.width=D,_Y.height=D+1;let t=_Y.getContext("2d");t.clearRect(0,0,D,D),t.resetTransform(),t.translate(-I,0),_g.forEach((e,r)=>{let a=_t(r),l=_r(r);if(!e)return;let o=_h!==e&&"black"!==e&&_&&"red"||e;(function(_,e,t,r,a){let l=Math.ceil(r-j/2),o=Math.ceil(a-j/2),s=Math.ceil(r+j/2)-1-l,i=Math.ceil(a+j/2)-1-o,c="brick"+e+"_"+t+"_"+s+"_"+i;if(!_X[c]){var n,h,m,b,g,y;let _=document.createElement("canvas");_.width=s,_.height=i;let r=_.getContext("2d");r.fillStyle=e,r.strokeStyle=t,r.lineJoin="round",r.lineWidth=2,n=r,h=1,m=1,b=s-2,g=i-2,y=2,n.beginPath(),n.moveTo(3,1),n.lineTo(h+b-y,m),n.quadraticCurveTo(h+b,m,h+b,m+y),n.lineTo(h+b,m+g-y),n.quadraticCurveTo(h+b,m+g,h+b-y,m+g),n.lineTo(h+y,m+g),n.quadraticCurveTo(h,m+g,h,m+g-y),n.lineTo(h,m+y),n.quadraticCurveTo(h,m,h+y,m),n.closePath(),r.fill(),r.stroke(),_X[c]=_}_.drawImage(_X[c],l,o,s,i)})(t,e,o,a,l),"black"===e&&(t.globalCompositeOperation="source-over",function(_,e,t,r,a){let l="svg"+e+"_"+t+"_"+e.complete;if(!_X[l]){let _=document.createElement("canvas");_.width=t,_.height=t;let r=_.getContext("2d"),a=t/Math.max(e.width,e.height),o=e.width*a,s=e.height*a;r.drawImage(e,(t-o)/2,(t-s)/2,o,s),_X[l]=_}_.drawImage(_X[l],Math.round(r-t/2),Math.round(a-t/2))}(t,R,j,a,l))})}x.drawImage(_Y,I,0)}(),x.globalCompositeOperation="screen",(_y=_y.filter(_=>_7-_.time<_.duration&&!_.destroyed)).forEach(_=>{let{x:e,y:t,time:r,color:a,size:l,type:o,duration:s}=_,i=_7-r;x.globalAlpha=Math.max(0,Math.min(1,2-i/s*2)),"text"===o?(x.globalCompositeOperation="source-over",_1(x,_.text,a,l,e,t-i/10)):"particle"===o&&(x.globalCompositeOperation="screen",_J(x,a,l,e,t),_Q(x,a,l,e,t))}),x.globalAlpha=1,x.globalCompositeOperation="source-over",_d.forEach(_=>{_.destroyed||_K(x,_.color,S,_.x,_.y,c.color||"black",_.a)}),_d.length>10&&!ea("basic")&&(x.globalAlpha=Math.min(.8,(_d.length-10)/50),_n.forEach(_=>{_J(x,c.color||"#000",120,_.x,_.y)})),x.globalAlpha=1,x.globalCompositeOperation="source-over",_n.forEach(_=>{_J(x,_h,20,_.x,_.y,M),_$(_)&&(x.strokeStyle=M,x.beginPath(),x.bezierCurveTo(V,Y,V,_.y,_.x,_.y),x.stroke())}),x.globalAlpha=1,x.globalCompositeOperation="source-over",A.streak_shots&&O>T()&&_U(x,"red",L,20,-2),_U(x,M,L,20),O>1){x.globalCompositeOperation="source-over";let _="x "+O,e=20*_.length/1.8+2*S,t=V-e/2;eT();x.globalCompositeOperation="source-over",F?(x.fillStyle=y&&A.left_is_lava?"red":M,x.fillRect(I-1,0,1,h),x.fillStyle=y&&A.right_is_lava?"red":M,x.fillRect(n-I+1,0,1,h)):(x.fillStyle="red",y&&A.left_is_lava&&x.fillRect(0,0,1,h),y&&A.right_is_lava&&x.fillRect(n-1,0,1,h)),A.top_is_lava&&O>T()&&(_=x,e=F,t=0,r=N,i=1,_.fillStyle="red",_.fillRect(e,0,r,1));let d=A.compound_interest&&O>T();x.fillStyle=d?"red":M,ea("mobile-mode")?(x.fillRect(F,Y,N,1),H||_1(x,"Press and hold here to play",M,20,K/2,Y+(Q-Y)/2)):d&&x.fillRect(F,Y-1,N,1),g&&x.resetTransform(),ea("record")&&H&&a&&(s&&(s.drawImage(z,F,0,N,Y,0,0,o.width,o.height),s.fillStyle="#FFF",s.textBaseline="top",s.font="12px monospace",s.textAlign="right",s.fillText(_o.toString(),o.width-12,12),s.textAlign="left",s.fillText("Level "+(G+1)+"/"+_N(),12,12)),l?.requestFrame?l?.requestFrame():a?.requestFrame&&a.requestFrame())})(),requestAnimationFrame(_),_O=e}();