var w=window.innerWidth, h=window.innerHeight, amount=((w*h)/10000)|0; outOf.textContent=amount+1; c.width=w; c.height=h; var ctx=c.getContext('2d'); var inGame=false, cells=[]; function getRandomColor(min){ return 'rgb(cr, cg, cb)'.replace( 'cr', (Math.random()*(255-min))|0+min).replace( 'cg', (Math.random()*(255-min))|0+min).replace( 'cb', (Math.random()*(255-min))|0+min) }; clicked=false; function init(){ clicked=false; ctx.fillStyle='black'; ctx.fillRect(0, 0, w, h); score.textContent='0'; cells=[]; for(var n=0; nw) this.vx*=-1; if(this.y<0||this.y>h) this.vy*=-1; ctx.fillStyle=this.color; ctx.beginPath(); ctx.arc(this.x, this.y, Math.abs(this.size/2), 0, Math.PI*2); ctx.fill(); ctx.closePath(); //ctx.fillRect(this.x-this.size/2, this.y-this.size/2, this.size, this.size); if(this.exploded){ if(this.size>0){ this.explosionSize+=1/this.explosionSize*10; this.size-=0.05; }else{ cells.splice(cells.indexOf(this), 1); } ctx.beginPath(); ctx.arc(this.x, this.y, this.explosionSize, 0, Math.PI*2); for(var i=0; i