forked from eoinmcg/buzzoff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
98 lines (61 loc) · 34.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!-- <!DOCTYPE HTML> -->
<html lang="en">
<head> <meta charset="UTF-8"> <title>BuzzOff</title>
<meta name="viewport" content="width=device-width, initial-scale=1"><style type="text/css">
body { margin: 0; padding: 0; background: #222; font-family: "Lucida Console", Courier, monospace;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
canvas { background: #fff; display: block; margin: 0 auto; cursor: crosshair; display: none;
image-rendering: pixelated;
image-rendering: -moz-pixelated;
image-rendering: -webkit-pixelated;
}
@-moz-keyframes boom {
0% { -moz-transform: translate(2px, 1px) rotate(0deg); }
10% { -moz-transform: translate(-1px, -2px) rotate(-1deg); }
20% { -moz-transform: translate(-3px, 0px) rotate(1deg); }
30% { -moz-transform: translate(0px, 2px) rotate(0deg); }
40% { -moz-transform: translate(1px, -1px) rotate(1deg); }
50% { -moz-transform: translate(-1px, 2px) rotate(-1deg); }
60% { -moz-transform: translate(-3px, 1px) rotate(0deg); }
70% { -moz-transform: translate(2px, 1px) rotate(-1deg); }
80% { -moz-transform: translate(-1px, -1px) rotate(1deg); }
90% { -moz-transform: translate(2px, 2px) rotate(-1deg); }
100% { -moz-transform: translate(px, 0px) rotate(0deg); }
}
@-webkit-keyframes boom {
0% { -webkit-transform: translate(2px, 1px) rotate(0deg); }
10% { -webkit-transform: translate(-1px, -2px) rotate(-1deg); }
20% { -webkit-transform: translate(-3px, 0px) rotate(1deg); }
30% { -webkit-transform: translate(0px, 2px) rotate(0deg); }
40% { -webkit-transform: translate(1px, -1px) rotate(1deg); }
50% { -webkit-transform: translate(-1px, 2px) rotate(-1deg); }
60% { -webkit-transform: translate(-3px, 1px) rotate(0deg); }
70% { -webkit-transform: translate(2px, 1px) rotate(-1deg); }
80% { -webkit-transform: translate(-1px, -1px) rotate(1deg); }
90% { -webkit-transform: translate(2px, 2px) rotate(-1deg); }
100% { -webkit-transform: translate(px, 0px) rotate(0deg); }
}
.shake {
-moz-animation-name: boom;
-moz-animation-duration: 0.5s;
-moz-transform-origin:50% 50%;
-moz-animation-timing-function: linear;
-webkit-animation-name: boom;
-webkit-animation-duration: 0.5s;
-webkit-transform-origin:50% 50%;
-webkit-animation-timing-function: linear;
}
h1 { left: 0; line-height: 200px; margin: auto; margin-top: -100px; position: absolute; top: 50%; width: 100%; text-align: center; }
#l { color: #ff0; font-size: 150%; }
</style>
</head>
<body>
<div id="l"><h1 id="h">Loading</h1></div>
<canvas id="b"></canvas>
<script>function J(){this.B=function(t){for(var i=0;24>i;i++)this[String.fromCharCode(97+i)]=t[i]||0;.01>this.c&&(this.c=.01),t=this.b+this.c+this.e,.18>t&&(t=.18/t,this.b*=t,this.c*=t,this.e*=t)}}$={},$.Game=function(t,i,e){this.id=t,this.w=i,this.h=e,this.cx=i/2,this.cy=e/2,this.score=0,this.hiScore=localStorage.getItem("hiScore")||0,this.tick=0,this.mobile=!!("ontouchstart"in window),this.bgs={},this.imgs={},this.fonts={},this.ents=[],this.sfx={},$.u=$.utils},$.Game.prototype.boot=function(){var t=this,i=window.addEventListener;this.c=$.u.getId(this.id),this.ctx=this.c.getContext("2d"),this.l=$.u.getId("l"),this.c.addEventListener("mozAnimationEnd",function(){t.c.className=""},!1),this.c.addEventListener("webkitAnimationEnd",function(){t.c.className=""},!1),i("resize",function(){t.scale()},!1),this.input=new $.Input(this),this.load=new $.Load(this),this.explode=new $.Emitter(this)},$.Game.prototype.init=function(){var t=this;this.c.style.display="block",this.l.style.display="none",this.scale(),this.favicon(),this.changeState("Intro"),function i(){t.loop(),requestAnimationFrame(i,this.c)}()},$.Game.prototype.favicon=function(){var t=document.createElement("canvas");t.width=16,t.height=16;var i=t.getContext("2d"),e=this.imgs.bee_2;try{i.drawImage(e,0,0)}catch(s){return}var h=document.createElement("link");h.type="image/x-icon",h.rel="shortcut icon",h.href=t.toDataURL("image/x-icon"),document.getElementsByTagName("head")[0].appendChild(h)},$.Game.prototype.changeState=function(t){this.ents=[],this.tick=0,this.input.down=!1,this.state=new $[t](this)},$.Game.prototype.move=function(t){var i=this.getPos(t);this.mx=i.x,this.my=i.y,this.angle=this.getAngle(this.w/2,this.h/2)},$.Game.prototype.loop=function(){this.tick+=1,this.fadeText=Math.sin(.05*this.tick)+1,this.state.update(),this.state.render(),this.input.updatePower()},$.Game.prototype.getAngle=function(t,i){var e=this.mx-t,s=this.my-i;return Math.atan2(s,e)},$.Game.prototype.scale=function(){{var t=window.innerHeight,i=this.w/this.h,e=t*i;e/this.w}this.mobile&&t<window.innerWidth?(this.l.style.display="block",$.u.getId("h").innerHTML="Rotate Device",this.c.style.display="none"):(this.l.style.display="none",this.c.style.display="block"),this.c.width=this.w,this.c.height=this.h,this.cx=this.w/2,this.cy=this.h/2,this.c.style.width=~~e+"px",this.c.style.height=~~t+"px"},$.Game.prototype.makeSprite=function(t,i){var e=new $[t];return e.init(this,i),e},$.Game.prototype.stringW=function(t,i){if(i.f){var e,s=0;for(t=t.split(""),e=0;e<t.length;e+=1)s+=i.w[e]*i.scale;return this.w/2-s/2}},$.Game.prototype.drawString=function(t,i,e,s){if(t=t.toUpperCase(),i.scale=i.scale||1,i){var h,a,o;if(!i.f)for(i.f=[h=0],a=0,o=i.w.length;++a<o;)i.f[a]=h+=i.w[a-1]*i.scale;for(t=t.split(""),a=0,o=t.length;o>a;)(h=i.c.indexOf(t[a++]))>=0&&(this.ctx.drawImage(i,i.f[h],0,i.w[h]*i.scale,i.height,e,s,i.w[h]*i.scale,i.height),e+=i.w[h]*i.scale)}},$.Game.prototype.getByName=function(t){for(var i=this.ents,e=i.length,s=[];e--;)i[e].name===t&&s.push(i[e]);return s},$.Game.prototype.getByGroup=function(t){for(var i=this.ents,e=i.length,s=[];e--;)i[e].group===t&&s.push(i[e]);return s},$.Game.prototype.sfxPlay=function(t){try{this.sfx[t].play()}catch(i){console.log(i)}},$.Load=function(t){this.game=t,this.imgsLoaded=0,this.imgsTotal=Object.keys($.data.i).length,this.init=function(){var t,i=this.game,e=$.data.i;for(t in e)e.hasOwnProperty(t)&&(i.imgs[t]=new Image,i.imgs[t].onload=this.checkLoaded(),i.imgs[t].src=e[t])},this.checkLoaded=function(){this.imgsLoaded+=1,this.imgsLoaded===this.imgsTotal&&(this.resize(),this.mkFonts(),this.mkBgs(),this.mkSfx(),t.init(this.state))},this.resize=function(){{var t,i,e,s,h,a=this.game,o=Object.keys($.data.i),r=10,n=o.length;this.imgsTotal}for(n=0;n<o.length;n+=1)for(h=$.data.resize[o[n]]||{hurt:!1,r:"1"},i=h.r.split("-"),t=parseInt(i[0],10),r=parseInt(i[1],10)||t,e=t;r>=e;e+=1)s=o[n],a.imgs[s+"_"+e]=$.utils.resize(a.imgs[s],e),h.hurt&&(a.imgs[s+"_hurt_"+e]=$.utils.resize(a.imgs[s],e,[200,0,0])),h.shadow&&(a.imgs[s+"_shadow_"+e]=$.utils.resize(a.imgs[s],e,[0,0,0]))},this.mkFonts=function(){var t,i=this.game,e=$.data.f;for(t in e.t)i.fonts[t]=this.mkFont(e.t[t][0],e.t[t][1])},this.mkFont=function(t,i){var e=$.data.f,s=this.game;t=t||1;var h=$.utils.resize(s.imgs.font,t,i);return h.scale=t,h.w=e.w,h.c=e.c,h.h=e.h,h},this.mkSfx=function(){var t,i=$.data.sfx,e=this.game;for(t in i)i.hasOwnProperty(t)&&(e.sfx[t]=new Audio,e.sfx[t].src=jsfxr($.data.sfx[t]))},this.mkBgs=function(){var t,i,e,s,h=this.game,a=document.createElement("canvas");for(a.width=h.w,a.height=h.h,t=a.getContext("2d"),t.fillStyle="#4e9a06",t.fillRect(0,0,h.w,h.h),xc=0;5e3>xc;xc+=1)i=~~(Math.random()*h.w),e=~~(Math.random()*h.h),t.fillStyle="rgba(0,0,0,0.05)",t.fillRect(i,e,4,4),t.fillStyle="rgba(255,255,255,0.025)",t.fillRect(i,e+4,4,2);for(t.globalAlpha=.5,xc=0;15>xc;xc+=1){s=~~(3*Math.random())+2,i=~~(Math.random()*h.w),e=~~(Math.random()*(h.h/2)+60);try{t.drawImage(h.imgs["flower_"+s],i,e)}catch(o){console.log(o)}}t.globalAlpha=1;var r=new Image;r.src=a.toDataURL("image/gif"),h.bgs.grass=r},this.init()},$.utils={getId:function(t){return document.getElementById(t)},rndArray:function(t){return t[~~(Math.random()*t.length)]},resize:function(t,i,e){if(i=i||1,e=e||!1,0===t.width)return!1;var s=t.width*i,h=t.height*i,a=document.createElement("canvas");a.width=t.width,a.height=t.height;var o=a.getContext("2d");try{o.drawImage(t,0,0)}catch(r){return}var n=o.getImageData(0,0,t.width,t.height),A=document.createElement("canvas");A.width=s,A.height=h;var l,g,c=A.getContext("2d"),p=c.getImageData(0,0,s,h);for(l=0;h>l;l++)for(g=0;s>g;g++){var m=4*(Math.floor(l/i)*t.width+Math.floor(g/i)),d=4*(l*s+g);p.data[d]=n.data[m],p.data[d+1]=n.data[m+1],p.data[d+2]=n.data[m+2],p.data[d+3]=n.data[m+3],0===n.data[m+3]?(p.data[d]=0,p.data[d+1]=0,p.data[d+2]=0,p.data[d+3]=0):e&&(p.data[d]=e[0],p.data[d+1]=e[1],p.data[d+2]=e[2],p.data[d+3]=255)}c.putImageData(p,0,0);var u=new Image;return u.src=A.toDataURL("image/png"),u}},$.Input=function(t){var i=window.addEventListener,e=this;this.game=t,this.x=t.w/2,this.y=t.h/2,this.down=!1,this.released=!1,this.power=!1,i("mousedown",function(){e.down=1},!1),i("mouseup",function(){e.down=0,e.released=1},!1),i("mousemove",function(t){e.trackMove(t)},!1),i("touchstart",function(){e.down=1},!1),i("touchmove",function(t){t.preventDefault(),e.trackMove(t.touches[0])},!1),i("touchend",function(){e.down=0,e.released=1},!1),this.trackMove=function(t){var i=this.game,e=i.c.offsetTop,s=i.c.offsetLeft,h=parseInt(i.c.style.width,10)/i.c.width,a=~~((t.pageX-s)/h);y=~~((t.pageY-e)/h),a=a>i.w?i.w:a,a=0>a?0:a,y=y>i.h?i.h:y,y=0>y?0:y,this.x=a,this.y=y},this.updatePower=function(){this.down&&this.power<30?this.power+=.2:this.down||(this.power=0,this.released=0)},this.getAngle=function(t,i){var e=this.x-t,s=this.y-i;return Math.atan2(s,e)}},$.Emitter=function(t){this.game=t,this.init=function(t,i,e,s){var h,a=this.game;for(h=0;t>h;h+=1)a.ents.push(new $.Particle(this.game,i,e,s))}},$.Sprite=function(t,i,e){this.game=t,this.x=i||0,this.y=e||0,this.speed=4,this.scale=2,this.explodes=!1,this.remove=!1,this.group="",this.vx=0,this.vy=0},$.Sprite.prototype.mkImg=function(t){this.img=this.game.imgs[t+"_"+this.scale],this.w=this.img.width,this.h=this.img.height,this.cx=this.x+this.w/2,this.cy=this.y+this.y/2},$.Sprite.prototype.outOfBounds=function(){return this.x<0||this.y<0||this.x>this.game.w||this.y>this.game.h},$.Sprite.prototype.update=function(){this.x+=this.vx,this.y+=this.vy,this.remove=this.outOfBounds()},$.Sprite.prototype.render=function(){this.game.ctx.drawImage(this.img,this.x,this.y)},$.Sprite.prototype.rotate=function(t,i){{var e=document.createElement("canvas"),s=e.getContext("2d"),h=Math.max(t.width,t.height)+6;i*(180/Math.PI)}return e.width=h,e.height=h,s.translate(h/2,h/2),s.rotate(i+Math.PI/2),s.drawImage(t,-(t.width/2),-(t.height/2)),e},$.Sprite.prototype.hitGroup=function(t){for(var i=this.game,e=i.ents.length;e--;)i.ents[e].group===t&&this.hit(i.ents[e])&&(this.doDamage(i.ents[e]),i.ents[e].kill())},$.Sprite.prototype.hit=function(t){return!(t.y+t.h-1<this.y||t.y>this.y+this.h-1||t.x+t.w-1<this.x||t.x>this.x+this.w-1)},$.Sprite.prototype.doDamage=function(t){this.health-=t},$.Sprite.prototype.preKill=function(){var t=this.game;t.score+=this.scale||1,t.sfxPlay("explode")},$.Sprite.prototype.kill=function(){this.preKill();var t=this.game;this.remove=!0,this.explodes&&(t.explode.init(2*this.scale,this.x,this.y,5),t.ents.push(new $.Explosion(t,{scale:2*this.scale,x:this.x,y:this.y})))},$.Sprite.prototype.getTarget=function(t){return t=this.game.getByName(t),t[~~(Math.random()*t.length)]},$.Particle=function(t,i,e){this.game=t,this.x=i,this.y=e,this.v=5*Math.random()+5,this.vx=(2*Math.random()-1)*this.v,this.vy=(2*Math.random()-1)*this.v,this.ttl=100*Math.random()+100,this.hlife=this.ttl/2,this.o=1,this.i=t.imgs.frag_3,this.i2=t.imgs.frag_5,this.frame=this.i2,this.name="particle",this.group="particles"},$.Particle.prototype.update=function(){this.x+=this.vx,this.y+=this.vy,this.ttl-=5,this.vx*=.95,this.vy*=.95,this.ttl<this.hlife&&(this.frame=this.i),~~this.vx<=0&&this.o>=0&&(this.o-=.05),this.o<=0&&(this.remove=!0)},$.Particle.prototype.render=function(){this.ttl>0&&this.o>0&&(this.game.ctx.globalAlpha=this.o,this.game.ctx.drawImage(this.frame,this.x,this.y),this.game.ctx.globalAlpha=1)},$.Transition=function(){this.update=function(){},this.render=function(){}},$.data={sfx:{powerup:[0,,.0129,.5211,.4714,.4234,,,,,,.4355,.5108,,,,,,1,,,,,.5],shoot:[1,,.135,.2756,.3189,.5769,.2,-.2639,,,,,,.8807,-.3628,,.1912,-.0219,1,,,.0185,,.5],explode:[3,,.3708,.5822,.3851,.0584,,-.0268,,,,-.0749,.7624,,,,,,1,,,,,.5],hurt:[0,,.1812,,.1349,.4524,,.2365,,,,,,.0819,,,,,1,,,,,.5]},i:{explosion:"data:image/gif;base64,R0lGODlhQAAIAMIGAKQAAMwAAM5cAPV5AO3UAPzpTwAAAAAAACH5BAEKAAcALAAAAABAAAgAAANjeLrc7gC8SaulsQEhpApBtoBX+ZAMiB7bMHRLFAWxAtAaXq1fUeg3V4glGCheEtHN5lmymg1dSnoIFAjAgDBZPMJYzJpN7ODtqCpgEfkJeWggEdxtqj81HA/4Pubb/xUigHUJADs=",logo:"data:image/gif;base64,R0lGODlhGAALAMIEAAAAAC40NsSgAO3UAP///////////////yH5BAEKAAQALAAAAAAYAAsAAAM+GLDUSoyoOMGjAOamua7ctXUcMwiEgBJnurYcfKreHKsv7u183y8jkATYEzlGQ18Sw0TeXA1YdOWzTWvURgIAOw==",bug:"data:image/gif;base64,R0lGODlhBQAGAMIEAFw1ZnVQe61/qO3UAAAAAAAAAAAAAAAAACH5BAEKAAQALAAAAAAFAAYAAAMOSBSq7AOsEACgUQogSAIAOw==",health:"data:image/gif;base64,R0lGODlhBQAFAKEDAKQAAMwAAMwDEf///yH5BAEKAAMALAAAAAAFAAUAAAILnGwhAgs/Hhh0jgIAOw==",bomb:"data:image/gif;base64,R0lGODlhBgAHAMIEAC40Nu8pKVVXU+7u7AAAAAAAAAAAAAAAACH5BAEKAAQALAAAAAAGAAcAAAMQSBra0wSABoSY8soop9pEAgA7",firepower:"data:image/gif;base64,R0lGODlhBgAGAMIEAKQAAMwAAPV5APyvPgAAAAAAAAAAAAAAACH5BAEKAAQALAAAAAAGAAYAAAMOSBq6AU7AEMQAk0KFVQIAOw==",skull:"data:image/gif;base64,R0lGODlhBwAHAMICAKQAAMwAAC40Nv///y40Ni40Ni40Ni40NiH5BAEKAAQALAAAAAAHAAcAAAMUSASsC6OxQUGAYuRL+4XBEATPSCYAOw==",slider:"data:image/gif;base64,R0lGODlhCAAGAKECAC40Nu7u7P///////yH5BAEKAAMALAAAAAAIAAYAAAIRXI4jAgcSWAugrfniOtugMxQAOw==",hornet:"data:image/gif;base64,R0lGODlhBwAIAMIBAKQAAC40NnKfz8SgAC40Ni40Ni40Ni40NiH5BAEKAAQALAAAAAAHAAgAAAMWSBraxC7IJoYVRAgZtLKDAwyAQ4RKAgA7",flower:"data:image/gif;base64,R0lGODlhAwADAKECAHKfz////wAAAAAAACH5BAEKAAIALAAAAAADAAMAAAIEVAx3BQA7",frag:"data:image/gif;base64,R0lGODlhAwADAKECAMSgAO3UAP///////yH5BAEKAAIALAAAAAADAAMAAAIEVBwgWgA7",sting:"data:image/gif;base64,R0lGODlhAwADAKECAKQAAMwAAP///////yH5BAEKAAIALAAAAAADAAMAAAIEVBxwUAA7",ant:"data:image/gif;base64,R0lGODlhBgAHAKECAMwAAC40Nv///////yH5BAEKAAIALAAAAAAGAAcAAAINjGKJJsd6HGqOAgREAQA7",ant2:"data:image/gif;base64,R0lGODlhBgAHAKECAMwAAC40Nv///////yH5BAEKAAIALAAAAAAGAAcAAAINlBKGm9faGIJGAAREAQA7",font:"data:image/gif;base64,R0lGODlh3wEJAKEBAP///wAAAAAAAAAAACH5BAEKAAAALAAAAADfAQkAAAL+hI+py+0Po5y02ouz3rz7D4biSJbmiabqugRB5rIyFs+G+x54rtc3jtj9fMIfgMgzGpHBHPDoRCaLvemzyivGmNBoT/msha8J8pXand6aZl/amuw2sWVyGht3o6EKcdwx5tXyVwfhNoSoRPfFt6h4t5T1wkQpOcc4x4WJprfjN+nXyFf5pXk5aik3Krq3J5pp1fdHtIZpWxhZmvo5pDXLOSbr+Xi42Eks2FAsy7wJ2mtbfAzZKzkNaxwsZcp62Dn8FrqNDc2Gi8oW+3z72K57qloVVFtef2tH9emNL01Yl9fmkitk7CIsSxcM10F2UipssUQqF8F3Ehs9dPSKFyqGcanIUYMX0Z6ncefcUVS0cNuvk6/QlSw4EiBCf/3AXfuXLGNOZf6agYTY8yaNdR/jffT1z2PDk0hVaTS6LCDJaP2ExYIK8GAbfdZWYjTaEmxAe0eBDSRbNSzPKOoIXVQ7SFgiuApl2riLl8HCvHz7jthrqKdfwG84EPaLOLHixYwbO35cogAAOw==",bee:"data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gcXCzosgCo5sgAAAJZJREFUGNNjYGBgYNAzMfv/7t2b/3omZv+R2QwMDAxMDAwMDEsXz2RABzAxRpjAn5f+/2HsE9s3MtgkQOQYGRgYGIrmn/+/Z2o6igku2TMZ+hINGRmL5p//z8DAwNDl1cDw8fVGBgYGBobrZxgY1v0/j7DCJHXJ/1/nJ6GYwGaYx3BmdgwjihtObN8IVwBzAwqAeRNZDACxZDnBB1kAnwAAAABJRU5ErkJggg== ",worm:"data:image/gif;base64,R0lGODlhBQAFAMIEADMzM/8Amf9mzGb/AC40Ni40Ni40Ni40NiH5BAEKAAAALAAAAAAFAAUAAAMLCBC6w0EMAV9jIAEAOw==",wormh:"data:image/gif;base64,R0lGODlhBQAFAKEDAAAAAP8Uk/9ptC40NiH5BAEKAAMALAAAAAAFAAUAAAILnB8SEyAQklAsjgIAOw==",hive:"data:image/gif;base64,R0lGODlhCgAJAMIAAAAAAC40NsSgAO3UAAAAAAAAAAAAAAAAACH5BAEKAAQALAAAAAAKAAkAAAMZSCos+mLI4Va7a053O9PaNwWAJA5kSXlXAgA7",x:"data:image/gif;base64,R0lGODdhAQABAIAAAAAAAAAAACwAAAAAAQABAAACAkQBADs="},resize:{explosion:{r:"1-9"},logo:{shadow:!0,r:"10"},bee:{shadow:!0,r:"2-4"},firepower:{r:"4"},bomb:{r:"4"},health:{r:"4"},hive:{hurt:!0,r:"3-9"},sting:{r:"1-9"},ant:{hurt:!0,r:"1-9"},ant2:{hurt:!0,r:"1-9"},skull:{r:"1-9"},worm:{r:"4"},wormh:{r:"4"},hornet:{shadow:!0,r:"1-9"},frag:{r:"1-9"},flower:{r:"1-9"},slider:{r:"6"},bug:{r:"1-9"}},f:{t:{p:[!1,!1],h1:[7,[255,255,0]],h1_s:[7,[0,0,0]],h1_p:[7,[255,105,180]],pwup:[4,[255,255,0]],h2:[2,[255,255,255]],h2_p:[2,[255,0,255]],h2_s:[2,[0,0,0]]},c:"ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789!@#$%^&*()-=[]\\;',./_+{}|:\"<>?`~",w:[8,8,8,8,6,6,8,8,5,8,8,6,9,9,6,8,8,8,8,6,8,9,9,9,9,6,5,8,6,8,8,8,8,8,8,8,8,5,9,9,8,9,6,8,9,5,5,6,6,5,5,6,5,5,5,4,6,8,9,6,6,5,4,6,6,6,8,5,8],h:18}};var W=new function(){this.A=new J;var t,i,e,s,h,a,o,r,n,A,l,g;this.reset=function(){var t=this.A;s=100/(t.f*t.f+.001),h=100/(t.g*t.g+.001),a=1-.01*t.h*t.h*t.h,o=1e-6*-t.i*t.i*t.i,t.a||(l=.5-t.n/2,g=5e-5*-t.o),r=0<t.l?1-.9*t.l*t.l:1+10*t.l*t.l,n=0,A=1==t.m?0:2e4*(1-t.m)*(1-t.m)+32},this.D=function(){this.reset();var s=this.A;return t=1e5*s.b*s.b,i=1e5*s.c*s.c,e=1e5*s.e*s.e+10,t+i+e|0},this.C=function(c,p){var m=this.A,d=1!=m.s||m.v,u=.1*m.v*m.v,f=1+3e-4*m.w,w=.1*m.s*m.s*m.s,y=1+1e-4*m.t,x=1!=m.s,v=m.x*m.x,$=m.g,S=m.q||m.r,b=.2*m.r*m.r*m.r,M=m.q*m.q*(0>m.q?-1020:1020),I=m.p?(2e4*(1-m.p)*(1-m.p)|0)+32:0,B=m.d,E=m.j/2,k=.01*m.k*m.k,C=m.a,G=t,D=1/t,H=1/i,O=1/e,m=5/(1+20*m.u*m.u)*(.01+w);m>.8&&(m=.8);for(var R,L,P,K,N,m=1-m,T=!1,Q=0,U=0,z=0,F=0,W=0,_=0,Y=0,J=0,X=0,j=0,V=Array(1024),Z=Array(32),q=V.length;q--;)V[q]=0;for(q=Z.length;q--;)Z[q]=2*Math.random()-1;for(q=0;p>q;q++){if(T)return q;if(I&&++X>=I&&(X=0,this.reset()),A&&++n>=A&&(A=0,s*=r),a+=o,s*=a,s>h&&(s=h,$>0&&(T=!0)),L=s,E>0&&(j+=k,L*=1+Math.sin(j)*E),L|=0,8>L&&(L=8),C||(l+=g,0>l?l=0:l>.5&&(l=.5)),++U>G)switch(U=0,++Q){case 1:G=i;break;case 2:G=e}switch(Q){case 0:z=U*D;break;case 1:z=1+2*(1-U*H)*B;break;case 2:z=1-U*O;break;case 3:z=0,T=!0}S&&(M+=b,P=0|M,0>P?P=-P:P>1023&&(P=1023)),d&&f&&(u*=f,1e-5>u?u=1e-5:u>.1&&(u=.1)),N=0;for(var ti=8;ti--;){if(Y++,Y>=L&&(Y%=L,3==C))for(R=Z.length;R--;)Z[R]=2*Math.random()-1;switch(C){case 0:K=l>Y/L?.5:-.5;break;case 1:K=1-2*(Y/L);break;case 2:K=Y/L,K=K>.5?6.28318531*(K-1):6.28318531*K,K=0>K?1.27323954*K+.405284735*K*K:1.27323954*K-.405284735*K*K,K=0>K?.225*(K*-K-K)+K:.225*(K*K-K)+K;break;case 3:K=Z[Math.abs(32*Y/L|0)]}d&&(R=_,w*=y,0>w?w=0:w>.1&&(w=.1),x?(W+=(K-_)*w,W*=m):(_=K,W=0),_+=W,F+=_-R,K=F*=1-u),S&&(V[J%1024]=K,K+=V[(J-P+1024)%1024],J++),N+=K}N=.125*N*z*v,c[q]=N>=1?32767:-1>=N?-32768:32767*N|0}return p}};window.jsfxr=function(t){W.A.B(t);var i=W.D();t=new Uint8Array(4*((i+1)/2|0)+44);var i=2*W.C(new Uint16Array(t.buffer,44),i),e=new Uint32Array(t.buffer,0,44);e[0]=1179011410,e[1]=i+36,e[2]=1163280727,e[3]=544501094,e[4]=16,e[5]=65537,e[6]=44100,e[7]=88200,e[8]=1048578,e[9]=1635017060,e[10]=i;for(var i=i+44,e=0,s="data:audio/wav;base64,";i>e;e+=3)var h=t[e]<<16|t[e+1]<<8|t[e+2],s=s+("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[h>>18]+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[h>>12&63]+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[h>>6&63]+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[63&h]);return e-=i,s.slice(0,s.length-e)+"==".slice(0,e)},$.Intro=function(t){this.game=t,this.hw=t.w/2;try{t.ctx.drawImage(t.imgs.skull_8,125,240)}catch(i){return void(window.location.href=window.location.href)}t.sfxPlay("powerup")},$.Intro.prototype.update=function(){var t=this.game;(t.input.down||t.tick>200)&&t.changeState("Splash")},$.Intro.prototype.render=function(){var t=this.game;t.ctx.font='18px "Lucida Console", Console, monospace',this.t1=~~(this.hw-t.ctx.measureText("@eoinmcg").width/2),this.t2=~~(this.hw-t.ctx.measureText("Presents...").width/2),t.ctx.fillStyle="#333333",t.ctx.fillRect(0,0,t.w,t.h),t.ctx.fillRect(0,0,t.w,t.h),t.ctx.fillStyle="#ff0",t.ctx.fillText("@eoinmcg",this.t1,150),t.ctx.fillText("Presents...",this.t2,200)},$.Splash=function(t){this.game=t,this.startTxt=t.mobile?"TAP TO PLAY":"CLICK TO PLAY"},$.Splash.prototype.update=function(){var t=this.game;t.input.down&&t.changeState("Play")},$.Splash.prototype.render=function(){var t,i,e=this.game,s=6,h=50;for(e.ctx.fillStyle="#729fcf",e.ctx.fillRect(0,0,e.w,e.h),t=0;s>=t;t+=1)i=e.h-h*(t+1),e.ctx.fillStyle="rgba(255,255,255,0."+(s-t-2)+")",e.ctx.fillRect(0,i-h,e.w,i);e.ctx.fillStyle="#4e9a06",e.ctx.fillRect(0,400,e.w,e.h),e.ctx.fillStyle="rgba(0,0,0,0.1)",e.ctx.fillRect(0,e.h-40,e.w,e.h),e.ctx.globalAlpha=.4,e.ctx.drawImage(e.imgs.logo_shadow_10,48,72),e.ctx.globalAlpha=1,e.ctx.drawImage(e.imgs.logo_10,50,70),e.ctx.globalAlpha=e.fadeText,e.drawString(this.startTxt,e.fonts.h2_s,84,251),e.drawString(this.startTxt,e.fonts.h2_p,85,250),e.ctx.globalAlpha=1,e.ctx.drawImage(e.imgs.hive_9,125,340);var a=""+~~e.hiScore,o="000000";a=o.substring(0,o.length-a.length)+a,e.drawString("HI "+a,e.fonts.h2_s,110,20),e.drawString("HI "+a,e.fonts.h2,108,18)},$.Play=function(t){var i,e,s=[20,90,200,270];for(this.game=t,t.chargeSpeed=3,t.p1=new $.Bee(t),t.ents.push(t.p1),t.slider=new $.Slider(t),t.ents.push(t.slider),i=0;i<s.length;i+=1)e=new $.Hive(t,{x:s[i],y:380}),t.ents.push(e);t.score=0,t.maxCombo=0,t.newHiScore=!1,this.scoreCount=t.score,this.level=0,this.nextLevel=1200,this.baddies=["Ant","Hornet","Worm","Bug","Skull"],this.getLevelData()},$.Play.prototype.update=function(){var t,i=this.game,e=i.getByName("hive");0===e.length&&i.changeState("Gameover"),this.tick>this.nextLevel&&this.getLevelData(),this.tick===this.levelData.powerUp&&i.ents.push(new $.Powerup(i)),this.tick%this.levelData.spawnInterval===0&&(t=$.utils.rndArray(this.levelData.baddies),i.ents.push(new $[t](i))),i.input.released&&(i.p1.power<4?i.sfxPlay("hurt"):(i.sfxPlay("shoot"),i.ents.push(new $.Bullet(i,{power:i.p1.power,angle:i.p1.angle,x:i.p1.cx,y:i.p1.cy}))),i.p1.power=0);for(var s=i.ents.length;s--;)i.ents[s].update();for(s=i.ents.length;s--;)i.ents[s].remove&&i.ents.splice(s,1);this.scoreCount<i.score&&(this.scoreCount+=.2),this.tick+=1},$.Play.prototype.render=function(){var t=this.game,i=t.ents.length;for(t.ctx.drawImage(t.bgs.grass,0,0);i--;)t.ents[i].render();var e=""+~~this.scoreCount,s="0000000";e=s.substring(0,s.length-e.length)+e,t.drawString(e,t.fonts.h2_s,110,20),t.drawString(e,t.fonts.h2,108,18)},$.Play.prototype.getLevelData=function(){var t=[],i=~~(Math.random()*this.nextLevel),e=$.utils;this.level<this.baddies.length?this.levelData={baddies:[this.baddies[this.level]],spawnInterval:200,powerUp:i}:(t.push(e.rndArray(this.baddies)),t.push(e.rndArray(this.baddies)),this.levelData={baddies:t,spawnInterval:100,powerUp:i}),this.tick=0,this.level+=1},$.Gameover=function(t){this.game=t,t.input.down=0,this.drawCalls=["score","combo"],this.currCalls=[],this.interval=75,this.counter=0,t.score>t.hiScore&&(this.drawCalls.push("newHi"),t.hiScore=t.score,localStorage.setItem("hiScore",t.hiScore))},$.Gameover.prototype.update=function(){var t=this.game;this.counter+=1,this.counter%this.interval===0&&this.currCalls.length<this.drawCalls.length&&(this.currCalls.push(this.drawCalls[this.currCalls.length]),t.sfx.powerup.play()),t.input.down&&(this.tweet()?window.location="https://twitter.com/intent/tweet?&text=I+scored+"+t.score+"+in+BuzzOff&hashtags=js13kgames&via=eoinmcg&url=http%3A%2F%2Farcade.starfish.ie%2Fbuzzoff":t.changeState("Splash"))},$.Gameover.prototype.render=function(){var t,i=this.game,e=i.imgs.skull_9;for(i.ctx.fillStyle="rgba(200,0,0,1)",i.ctx.fillRect(0,0,i.w,i.h),i.ctx.globalAlpha=.2,i.ctx.drawImage(e,0,0,e.width,e.height,50,100,250,250),i.ctx.globalAlpha=1,this.gameover(),t=0;t<this.currCalls.length;t+=1)this[this.currCalls[t]]();this.twitter()},$.Gameover.prototype.score=function(){var t,i=this.game,e="SCORE "+i.score;t=i.stringW(e,i.fonts.h2),i.drawString(e,i.fonts.h2_s,t-2,202),i.drawString(e,i.fonts.h2,t,200)},$.Gameover.prototype.combo=function(){var t,i=this.game,e="MAX COMBO "+i.maxCombo;t=i.stringW(e,i.fonts.h2),i.drawString(e,i.fonts.h2_s,t-2,242),i.drawString(e,i.fonts.h2,t,240)},$.Gameover.prototype.newHi=function(){var t,i=this.game,e="NEW HISCORE";t=i.stringW(e,i.fonts.h2),i.drawString(e,i.fonts.h2_s,t-2,282),i.drawString(e,i.fonts.h2,t,280)},$.Gameover.prototype.gameover=function(){var t,i,e=this.game;e.ctx.globalAlpha=e.fadeText,i="GAME",t=e.stringW(i,e.fonts.h1),e.drawString(i,e.fonts.h1_s,t-2,52),e.drawString(i,e.fonts.h1,t,50),i="OVER",t=e.stringW(i,e.fonts.h1),e.drawString(i,e.fonts.h1_s,t-2,102),e.drawString(i,e.fonts.h1,t,100),e.ctx.globalAlpha=1},$.Gameover.prototype.twitter=function(){var t,i=200,e=this.game,s=e.w/2-i/2,h="TWEET SCORE";e.ctx.fillStyle="#55ACEE",e.ctx.fillRect(s,380,i,60),e.ctx.fillRect(s-5,385,i+10,50),t=e.stringW(h,e.fonts.h2_s),e.drawString(h,e.fonts.h2,t+11,401),e.drawString(h,e.fonts.h2_s,t+10,400)},$.Gameover.prototype.tweet=function(){var t=this.game.input,i=t.x,e=t.y;return e>380&&i>55&&265>i},$.Ant=function(t){$.Sprite.call(this),this.game=t;var i,e,s=t.w,h=this.getTarget("hive")||t.p1;this.name="ant",this.group="baddies",this.scale=~~(3*Math.random())+2,this.explodes=!0,this.angle=Math.random()*Math.PI*2,this.x=Math.cos(this.angle)*s+s/2,this.y=Math.sin(this.angle)*s+s/2,this.y=-10,this.mkImg("ant"),e=Math.atan2(h.cy-this.y,h.cx-this.x),i=e*(180/Math.PI)+180,i*=Math.PI/180,this.img=this.rotate(this.img,i),this.img2=this.rotate(t.imgs["ant2_"+this.scale],i),this.frames=2,this.frame=0,this.animTick=0,this.animReset=8-this.scale,this.vx=0,this.vy=.2+~~(2*Math.random()),this.vx=Math.cos(e)*((5-this.scale)/2),this.vy=Math.sin(e)*((5-this.scale)/2)},$.Ant.prototype=new $.Sprite,$.Ant.prototype.constructor=$.Sprite,$.Ant.prototype.update=function(){this.x+=this.vx,this.y+=this.vy,this.animTick>this.animReset&&(this.animTick=0,this.frame+=1),this.frame>=this.frames&&(this.frame=0),this.animTick+=1,!this.remove&&this.y>this.game.h+this.w&&(this.remove=!0)},$.Ant.prototype.render=function(){var t=this.game,i=this.frame>0?this.img:this.img2;t.ctx.drawImage(i,this.x,this.y)},$.Bug=function(t){$.Sprite.call(this),this.game=t;t.w,this.getTarget("hive")||t.p1;this.name="skull",this.group="baddies",this.scale=~~(3*Math.random())+2,this.explodes=!0,this.x=Math.random()*t.w,this.y=0,this.xConst=this.x,this.xMove=20*Math.random()+20,this.xSpeed=2*Math.random()*-1,this.vy=1,this.mkImg("bug"),this.t=0},$.Bug.prototype=new $.Sprite,$.Bug.prototype.constructor=$.Sprite,$.Bug.prototype.update=function(){this.game;this.t+=.05,this.x=this.xMove*Math.sin(this.t*this.xSpeed)+this.xConst,this.y+=this.vy,!this.remove&&this.y<0-this.w&&(this.remove=!0)},$.Bug.prototype.render=function(){var t=this.game;t.ctx.drawImage(this.img,this.x,this.y)},$.Skull=function(t){$.Sprite.call(this),this.game=t;t.w,this.getTarget("hive")||t.p1;this.name="skull",this.group="baddies",this.scale=~~(3*Math.random())+2,this.explodes=!0,this.x=Math.random()*t.w,this.y=0,this.mkImg("skull"),this.t=0,this.A=0,this.B=-100,this.C=1,this.D=0,this.E=30,this.F=200,this.G=.5,this.H=1},$.Skull.prototype=new $.Sprite,$.Skull.prototype.constructor=$.Sprite,$.Skull.prototype.update=function(){this.y+this.h>this.game.h&&(this.remove=!0),this.vx=this.A+this.B*Math.sin(this.C*this.t+this.D),this.vy=this.E+this.F*Math.sin(this.G*this.t+this.H),this.x+=.015*this.vx,this.y+=.015*this.vy,this.t+=.05},$.Skull.prototype.render=function(){var t=this.game;t.ctx.drawImage(this.img,this.x,this.y)},$.Worm=function(t){$.Sprite.call(this),this.game=t;t.w,this.getTarget("hive")||t.p1;this.name="worm",this.group="baddies",this.scale=4,this.explodes=!0,this.angle=Math.random()*Math.PI*2,this.x=Math.random()*(t.w/3)+t.cx,this.y=0,this.mkImg("wormh"),this.b=t.imgs["worm_"+this.scale],this.bLen=3,this.A=0,this.B=-1*(200*Math.random()+100),this.C=1,this.D=0,this.E=50*Math.random()+50,this.F=50*Math.random()+50,this.G=1*Math.random(),this.H=Math.PI/2,this.pos=[],this.t=0},$.Worm.prototype=new $.Sprite,$.Worm.prototype.constructor=$.Sprite,$.Worm.prototype.render=function(){var t,i=0;for(i=1;i<=this.bLen;i+=1)t=this.prevPos(this.w/2*i),this.game.ctx.drawImage(this.b,t.x,t.y);this.game.ctx.drawImage(this.img,this.x,this.y)},$.Worm.prototype.update=function(){this.y+this.h>this.game.h&&(this.remove=!0),this.vx=this.A+this.B*Math.sin(this.C*this.t+this.D),this.vy=this.E+this.F*Math.sin(this.G*this.t+this.H),this.x+=.005*this.vx,this.y+=.015*this.vy,this.t+=.05,this.pos.push({x:this.x,y:this.y})},$.Worm.prototype.prevPos=function(t){return this.pos[this.pos.length-t]||{x:-20,y:-20}},$.Bee=function(t){$.Sprite.call(this,t),this.game=t,this.name="bee",this.power=0,this.powerMax=30,this.scale=4,this.mkImg("bee"),this.shadow=t.imgs.bee_shadow_4,this.x=this.game.w/2-this.img.width/2,this.y=this.game.h/2-this.img.height/2+120,this.cx=this.x+this.img.width/2,this.cy=this.y+this.img.height/2,this.angle=0},$.Bee.prototype=new $.Sprite,$.Bee.prototype.constructor=$.Sprite,$.Bee.prototype.render=function(){var t,i=this.game;this.power=i.input.power,i.input.down&&this.power<this.powerMax&&(this.power+=i.chargeSpeed),this.power>this.powerMax&&(this.power=this.powerMax),i.ctx.fillStyle="#000",i.ctx.strokeRect(130,40,2*this.powerMax,10),i.ctx.fillStyle="#c20",i.ctx.fillRect(130,40,2*this.power,10),i.ctx.fillStyle="rgba(255,255,255,0.15)",i.ctx.fillRect(130,45,2*this.power,5),i.ctx.globalAlpha=1,t=i.input.getAngle(this.cx,this.cy),this.angle=t,this.angle>0&&(this.angle*=-1),this.angle<-2.6?this.angle=-2.6:this.angle>-.4&&(this.angle=-.4),this.hover=~~(Math.sin(.5*i.tick)+.5),i.ctx.globalAlpha=.3,i.ctx.drawImage(this.rotate(this.shadow,this.angle),this.x+3,this.y+5),i.ctx.globalAlpha=1,i.ctx.drawImage(this.rotate(this.img,this.angle),this.x,this.y+this.hover)},$.Hornet=function(t){$.Sprite.call(this),this.game=t;var i=(t.w,this.getTarget("hive")||t.p1);this.name="hornet",this.group="baddies",this.scale=~~(3*Math.random())+2,this.explodes=!0,this.x=i.cx,this.y=-30,this.mkImg("hornet"),this.shadow=t.imgs["hornet_shadow_"+this.scale],this.vx=0,this.vy=~~(1*Math.random())+1},$.Hornet.prototype=new $.Sprite,$.Hornet.prototype.constructor=$.Sprite,$.Hornet.prototype.update=function(){this.x+=this.vx,this.y+=this.vy,!this.remove&&this.y>this.game.h+this.w&&(this.remove=!0)},$.Hornet.prototype.render=function(){var t=this.game;t.ctx.globalAlpha=.2,t.ctx.drawImage(this.shadow,this.x+5,this.y-6),t.ctx.globalAlpha=1,t.ctx.drawImage(this.img,this.x,this.y)},$.Bullet=function(t,i){$.Sprite.call(this,t),this.game=t,this.angle=i.angle,this.x=i.x,this.y=i.y,this.speed=4,this.group="bullets",this.name="bullet",this.remove=!1,this.power=i.power||2,this.scale=~~(this.power/3-1)||2,this.w=this.h=this.size,this.angle=this.game.p1.angle,this.mkImg("sting"),this.img=this.rotate(this.img,this.angle),this.vx=this.speed*Math.cos(this.angle),this.vy=this.speed*Math.sin(this.angle),this.combo=0,this.max=9},$.Bullet.prototype=new $.Sprite,$.Bullet.prototype.constructor=$.Sprite,$.Bullet.prototype.update=function(){this.x+=this.vx,this.y+=this.vy,this.remove=this.outOfBounds(),this.hitGroup("baddies"),this.outOfBounds()&&this.kill()},$.Bullet.prototype.preKill=function(){if(this.combo>1){var t=this.game;t.ents.push(new $.Combo(t,{c:"x "+this.combo})),t.sfxPlay("powerup"),this.combo>t.maxCombo&&(t.maxCombo=this.combo)}},$.Bullet.prototype.doDamage=function(){this.scale<this.max?this.remove=!0:this.combo+=1},$.Hive=function(t,i){$.Sprite.call(this,t),this.game=t,this.name="hive",this.group="hives",this.scale=3,this.mkImg("hive"),this.iHurt=this.game.imgs["hive_hurt_"+this.scale],this.x=i.x,this.y=i.y,this.cx=this.x-this.img.width/2,this.cy=this.y-this.img.height/2,this.alpha=0,this.explodes=!0,this.health=10},$.Hive.prototype=new $.Sprite,$.Hive.prototype.constructor=$.Sprite,$.Hive.prototype.update=function(){this.hitGroup("baddies")},$.Hive.prototype.render=function(){var t=this.game;this.game.ctx.drawImage(this.img,this.x,this.y),t.ctx.globalAlpha=this.alpha,this.game.ctx.drawImage(this.iHurt,this.x,this.y),t.ctx.globalAlpha=1},$.Hive.prototype.repair=function(){this.health+=3,this.health>=10?(this.health=10,this.alpha=0):this.alpha=(10-this.health)/10},$.Hive.prototype.doDamage=function(t){var i=this.game;this.health-=t.scale,i.c.className="shake",i.sfxPlay("hurt"),this.alpha=(10-this.health)/10,this.alpha>=1&&this.kill()},$.Explosion=function(t,i){$.Sprite.call(this,t),this.game=t,this.name="explosion",this.scale=i.scale||8,this.frames=7,this.frame=0,this.img=new Image,this.img.src=$.data.i.explosion,this.w=this.img.width*this.scale/(this.frames+1),this.h=this.img.height*this.scale,this.img=$.utils.resize(this.img,this.scale,!1),this.animTick=0,this.animReset=2,this.x=i.x-this.w/2,this.y=i.y-this.h/2,this.vx=0,this.vy=0},$.Explosion.prototype=new $.Sprite,$.Explosion.prototype.constructor=$.Sprite,$.Explosion.prototype.update=function(){this.animTick>this.animReset&&(this.animTick=0,this.frame+=1),this.frame>this.frames&&(this.remove=!0,this.frame=this.frames),this.animTick+=1},$.Explosion.prototype.render=function(){var t=this.game;t.ctx.drawImage(this.img,0+this.frame*this.w,0,this.w,this.h,this.x,this.y,this.w,this.h)},$.Combo=function(t,i){$.Sprite.call(this,t),this.game=t,this.vx=0,this.vy=-1.5,this.c=i.c,this.o=1,this.font=i.font||t.fonts.h1_p,this.x=t.stringW(this.c,this.font)||50,this.y=t.h/2,this.name="msgs"},$.Combo.prototype=new $.Sprite,$.Combo.prototype.constructor=$.Sprite,$.Combo.prototype.update=function(){this.y+=this.vy,this.vy*=1.01,this.y<0&&(this.remove=!0)},$.Combo.prototype.render=function(){var t=this.game;t.drawString(this.c,this.font,this.x,this.y)},$.Slider=function(t){$.Sprite.call(this,t),this.game=t,this.name="slider",this.scale=6,this.mkImg("slider"),this.x=this.game.w/2-this.img.width/2,this.y=this.game.h/2-this.img.height/2+200,this.cx=this.x+this.img.width/2,this.cy=this.y+this.img.height/2,this.min=0,this.max=this.game.w-(this.img.width+this.min)},$.Slider.prototype=new $.Sprite,$.Slider.prototype.constructor=$.Sprite,$.Slider.prototype.update=function(){this.x=this.game.input.x-this.img.width/2,this.x<this.min&&(this.x=this.min),this.x>this.max&&(this.x=this.max)},$.Slider.prototype.render=function(){var t=this.game;t.ctx.fillStyle="rgba(0,0,0,0.2)",t.ctx.fillRect(this.min,this.y,this.max+this.img.width-this.min,this.img.height),t.ctx.globalAlpha=.7,t.ctx.drawImage(this.img,this.x,this.y),t.ctx.globalAlpha=1},$.Powerup=function(t){$.Sprite.call(this),this.game=t;t.w;this.types=["health","firepower","bomb"],this.name=$.utils.rndArray(this.types),this.group="powerups",this.scale=4,this.explodes=!1,this.x=t.cx,this.y=-30,this.mkImg(this.name),this.vx=0,this.vy=.3+~~(1*Math.random())},$.Powerup.prototype=new $.Sprite,$.Powerup.prototype.constructor=$.Sprite,$.Powerup.prototype.update=function(){this.x+=this.vx,this.y+=this.vy,this.hitGroup("bullets"),!this.remove&&this.y>this.game.h+this.w&&(this.remove=!0)},$.Powerup.prototype.render=function(){var t=this.game;t.ctx.drawImage(this.img,this.x,this.y)},$.Powerup.prototype.doDamage=function(){var t=this.game;
t.sfxPlay("powerup"),t.ents.push(new $.Combo(t,{c:this.name,font:t.fonts.pwup})),t.explode.init(2*this.scale,this.x,this.y,5),this.remove=!0,"health"===this.name?this.doHealth():"firepower"===this.name?this.doFirepower():"bomb"===this.name&&this.doBomb()},$.Powerup.prototype.doHealth=function(){for(var t=this.game.getByName("hive"),i=t.length;i--;)t[i].repair()},$.Powerup.prototype.doFirepower=function(){this.game.chargeSpeed+=1},$.Powerup.prototype.doBomb=function(){for(var t=this.game.getByGroup("baddies"),i=t.length;i--;)t[i].kill()},window.addEventListener("load",function(){var t=new $.Game("b",320,480);t.boot()},!1);</script></body>
</html>