- Author:
- Todd Pastel
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- todd.jloop.com
- Compo:
- classic
- Demo link:
- https://js1k.com/2012-love/demo/1258
- Shortlink:
- https://js1k.com/1258
- Blog post:
- please update here!
- Bytes:
- 1006
- Chars:
- 1004
- Submission
function d(b,c,d,g){var h=f((d-b)/t),i=f((g-c)/t);if(h){var j=f(e()*h)*t+b;a.C(j+1,c-2,t-1,4)}if(i){var k=f(e()*i)*t+c;a.C(b-2,k+1,4,t-1)}}function m(b,c,g,h){var i=f((g-b)/t)-1,j=f((h-c)/t)-1;if(i&&j){var k=(f(e()*(i-1))+1)*t+b,l=(f(e()*(j-1))+1)*t+c,n=f(e()*4);a.F(k,c,1,o(c-h));a.F(b,l,o(b-g),1);if(n!=0)d(k,c,k,l);if(n!=1)d(k,l,g,l);if(n!=2)d(k,l,k,h);if(n!=3)d(b,l,k,l);m(b,c,k,l);m(k,c,g,l);m(b,l,k,h);m(k,l,g,h)}}c.width=c.height=201;with(c.style)width=height=innerHeight-25+"px";document.body.style.textAlign="center";var t=10,M=Math,e=M.random,f=M.floor,o=M.abs,X=Y=5,I=J=0;a.C=a.clearRect;a.F=a.fillRect;m(0,0,200,200);a.strokeRect(.5,.5,200,200);a.fillStyle="red";a.fillText("❤",191,200);a.fillStyle="blue";onkeydown=function(a){I=J=0;W=a.which;if(W==87)J=-1;if(W==83)J=1;if(W==65)I=-1;if(W==68)I=1};T=0;S=setInterval(function(){D=a.getImageData(X+I,Y+J,1,1).data;if(D[0]){alert("You found love in "+T/1e3+" seconds.");clearInterval(S)}if(!D[3]){a.C(X,Y,1,1);X+=I;Y+=J;a.F(X,Y,1,1)}T+=20},20);
- Description
- Controls
W - up
A - left
S - down
D - right
You are a lonely pixel looking for love in this maze of a world.
The maze is generated using the recursive division method. The source was mostly compressed by hand and finished off with UglifyJS. Enjoy!
- Base64 encoded
ZnVuY3Rpb24gZChiLGMsZCxnKXt2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Y3Rpb24oKXtEPWEuZ2V0SW1hZ2VEYXRhKFgrSSxZK0osMSwxKS5kYXRhO2lmKERbMF0pe2FsZXJ0KCJZb3UgZm91bmQgbG92ZSBpbiAiK1QvMWUzKyIgc2Vjb25kcy4iKTtjbGVhckludGVydmFsKFMpfWlmKCFEWzNdKXthLkMoWCxZLDEsMSk7WCs9STtZKz1KO2EuRihYLFksMSwxKX1UKz0yMH0sMjApOw==
- Original source
c.width=c.height=201;
with(c.style)width=height=innerHeight-25+'px';
document.body.style.textAlign='center';
var t=10,M=Math,e=M.random,f=M.floor,o=M.abs,X=Y=5,I=J=0;
a.C=a.clearRect;
a.F=a.fillRect;
function m(x,y,i,j){
var g=f((i-x)/t)-1,h=f((j-y)/t)-1;
if(g && h){
var u=((f(e()*(g-1))+1)*t)+x,v=((f(e()*(h-1))+1)*t)+y,r=f(e()*4);
a.F(u,y,1,o(y-j));
a.F(x,v,o(x-i),1);
if(r!=0)
d(u,y,u,v);
if(r!=1)
d(u,v,i,v);
if(r!=2)
d(u,v,u,j);
if(r!=3)
d(x,v,u,v);
m(x,y,u,v);
m(u,y,i,v);
m(x,v,u,j);
m(u,v,i,j);
}
}
function d(x,y,i,j){
var g=f((i-x)/t),h=f((j-y)/t);
if(g){
var u=(f(e()*g)*t)+x;
a.C(u+1,y-2,t-1,4);
}
if(h){
var v=(f(e()*h)*t)+y;
a.C(x-2,v+1,4,t-1);
}
}
m(0,0,200,200);
a.strokeRect(.5,.5,200,200);
a.fillStyle='red';
a.fillText('❤',191,200);
a.fillStyle='blue';
onkeydown=function(E){
I=J=0;
W=E.which;
if(W==87)
J=-1;
if(W==83)
J=1;
if(W==65)
I=-1;
if(W==68)
I=1;
}
T=0;
S=setInterval(function(){
D=a.getImageData(X+I,Y+J,1,1).data;
if(D[0]){
alert('You found love in '+T/1000+' seconds.');
clearInterval(S);
}
if(!D[3]){
a.C(X,Y,1,1);
X+=I;
Y+=J;
a.F(X,Y,1,1);
}
T+=20;
},20);