sh={lx:0,ly:0,x:0,y:0,tx:0,ty:0,s:10},aW=[],aB=[],ded=!1,sc=0,onmousemove=d=>{sh.tx=d.clientX,sh.ty=d.clientY,aB.push({x:sh.x,y:sh.y,vx:sh.x-d.clientX,vy:sh.y-d.clientY,s:5})};var collide=function(d,f){var g=d.s+f.s,h=d.x-f.x,k=d.y-f.y;return g>Math.sqrt(h*h+k*k)};setInterval(function(){if(!0!=ded){c.clearRect(0,0,a.width,a.height),c.fillText("(C) "+sc,0,10),sh.lx=sh.x,sh.ly=sh.y,sh.x-=(sh.x-sh.tx)/10,sh.y-=(sh.y-sh.ty)/10,!1==collide({s:1,x:sh.x,y:sh.y},{s:1,x:sh.lx,y:sh.ly})&&aW.push({x:sh.x,y:sh.y,s:5}),c.fillRect(sh.x-5,sh.y-5,10,10);for(var f,d=0;d<aB.length;++d){if(f=aB[d],f.x-=0.5*f.vx,f.y-=0.5*f.vy,0>f.x||0>f.y||f.x>a.width||f.y>a.height){aB.splice(d,1),--d;continue}c.fillRect(f.x-2.5,f.y-2.5,5,5);for(var h,g=0;g<aW.length;++g)if(h=aW[g],!0==collide(f,h)){aB.splice(d,1),--d,++sc,h.s-=10,5>h.s&&(aW.splice(g,1),--g);break}}for(var k,d=0;d<aW.length;++d)k=aW[d],k.s+=0.1,c.beginPath(),c.arc(k.x,k.y,k.s,0,2*Math.PI),c.stroke(),10<k.s&&(ded|=collide(k,sh))}},30);
// Pollute - (c) Arcade Badgers 2018
// Written by Steven Campbell
// @ArcadeBadgers @stuckieGAMEZ
ship = { lx: 0, ly: 0, x: 0, y: 0, tx: 0, ty: 0, s: 10 };
aWaste = [];
aBullets = [];
dead = false;
score = 0;
onmousemove=e=>{
ship.tx = e.clientX;
ship.ty = e.clientY;
var bullet = { x: ship.x, y: ship.y, vx:(ship.x - e.clientX), vy:(ship.y - e.clientY), s: 5 };
aBullets.push(bullet);
}
var collide = function(a, b) {
var r = a.s + b.s;
var x = a.x - b.x;
var y = a.y - b.y;
return r > Math.sqrt( (x*x) + (y*y) );
};
setInterval(function() {
if (true == dead)
return;
c.clearRect(0, 0, a.width, a.height);
c.fillText("(C) " + score, 0, 10);
ship.lx = ship.x;
ship.ly = ship.y;
ship.x -= (ship.x - ship.tx) / 10;
ship.y -= (ship.y - ship.ty) / 10;
if (false == collide({s:1, x:ship.x, y:ship.y}, {s: 1, x:ship.lx, y:ship.ly})) {
var waste = { x: ship.x, y: ship.y, s: 5 };
aWaste.push(waste);
}
c.fillRect(ship.x-5, ship.y-5, 10, 10);
for (var i = 0; i < aBullets.length; ++i) {
var obj = aBullets[i];
obj.x -= obj.vx * 0.5;
obj.y -= obj.vy * 0.5;
if ((obj.x < 0 ) || (obj.y < 0) || (obj.x > a.width) || (obj.y > a.height)) {
aBullets.splice(i, 1);
--i;
continue;
}
c.fillRect(obj.x - 2.5, obj.y - 2.5, 5, 5);
for (var j = 0; j < aWaste.length; ++j) {
var objB = aWaste[j];
if (true == collide(obj, objB)) {
aBullets.splice(i, 1);
--i;
++score;
objB.s -= 10;
if (5 > objB.s) {
aWaste.splice(j, 1);
--j;
}
break;
}
}
};
for (var i = 0; i < aWaste.length; ++i) {
var obj = aWaste[i];
obj.s += 0.1;
c.beginPath();
c.arc(obj.x, obj.y, obj.s, 0, 2*Math.PI);
c.stroke();
if (10 < obj.s)
dead |= collide(obj, ship);
};
}, 30);