- Author:
- davebee
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- Compo:
- classic
- Demo link:
- https://js1k.com/2010-first/demo/682
- Shortlink:
- https://js1k.com/682
- Blog post:
- please update here!
- Bytes:
- 1024
- Chars:
- 1024
- Submission
m='moveTo';l='lineTo';s='strokeStyle';r='strokeRect';R=Math.random;V=1;c=0;X=(d=document).getElementById('c');h=X.height=500;X.width=h*2;X = X.getContext('2d');a=10;A=[];K=0;Z=0;g=1;t=0;M=200;N=100;O=300;P=400;Q=600;function $(){K+=V;if(K>100){K=1;c++}if(c>20){c=0;V++;a++}X.clearRect(-h,-h,3*h,3*h);X[s]='#000';X.beginPath();X[m](N,0);X[l](P,M);X[l](P,O);X[l](N,h);X[m](900,0);X[l](Q,M);X[l](Q,O);X[l](900,h);X[m](P,O);X[l](Q,O);X[m](P-3*K,M-2*K);X[l](P-3*K,O+2*K);X[l](Q+3*K,O+2*K);X[l](Q+3*K,M-2*K);X.stroke();X[s]='#f0f';if(A[0]&&A[0][0]>N){A.shift();t++}L=A.length;if(L<a&&R()*N<2)A.push([0,N*R()]);H=225+Z;while(L-->0){B=A[L];D=B[0];p=1;if(B[1]<45)p=-1;I=O+2*D-(N+4*D)*B[1]/90+p*(10+D/2);J=10+D/2;X[r](P-3*D,I,M+6*D,J);B[0]+=V;if(D==N)if((I>H&&I<H+50)||(I+J>H&&I+J<H+50))g=0;}X[s]='red';X[r](450,H,N,50);if(g)setTimeout($,33);else E()}$();function E(){X.fillRect(-h,-h,3*h,3*h);alert('YOU LOOSE\nScore: '+t)}d.onkeydown=function(e){k=e.keyCode-39;Z+=z=3*k*V;if(Z<-125)Z=-125;else if(Z>125)Z=125;else X.translate(0,-z)}
- Description
- This demo try to mimic the 80's arcade game "STAR WARS", when Luke has to destroy the death star.
It just mimmic the part where you should avoid the pipe.
Controls: up/down arrow.
Scoring: one point for each pipe miss.
Use the force little Jedi ...
note: On Opera, the keydown event is send only once,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YW3NdPSdyZWQnO1hbcl0oNDUwLEgsTiw1MCk7aWYoZylzZXRUaW1lb3V0KCQsMzMpO2Vsc2UgRSgpfSQoKTtmdW5jdGlvbiBFKCl7WC5maWxsUmVjdCgtaCwtaCwzKmgsMypoKTthbGVydCgnWU9VIExPT1NFXG5TY29yZTogJyt0KX1kLm9ua2V5ZG93bj1mdW5jdGlvbihlKXtrPWUua2V5Q29kZS0zOTtaKz16PTMqaypWO2lmKFo8LTEyNSlaPS0xMjU7ZWxzZSBpZihaPjEyNSlaPTEyNTtlbHNlIFgudHJhbnNsYXRlKDAsLXopfQ==
- Original source
//the code was hand compressed, but it could help read it.
m='moveTo';
l='lineTo';
s='strokeStyle';
r='strokeRect';
R=Math.random;
V=1;
c=0;
X=(d=document).getElementById('c');
h=X.height=500;
X.width=h*2;
X = X.getContext('2d');
a=10;
A=[];
K=0;
Z=0;
g=1;
t=0;
M=200;
N=100;
O=300;
P=400;
Q=600;
function $(){
K+=V;
if(K>100){K=1;c++}
if(c>20){c=0;V++;a++}
X.clearRect(-h,-h,3*h,3*h);
X[s]='#000';
X.beginPath();
X[m](N,0);
X[l](P,M);
X[l](P,O);
X[l](N,h);
X[m](900,0);
X[l](Q,M);
X[l](Q,O);
X[l](900,h);
X[m](P,O);
X[l](Q,O);
X[m](P-3*K,M-2*K);
X[l](P-3*K,O+2*K);
X[l](Q+3*K,O+2*K);
X[l](Q+3*K,M-2*K);
X.stroke();
X[s]='#f0f';
if(A[0]&&A[0][0]>N){A.shift();t++}
L=A.length;
if(L<a&&R()*N<2)A.push([0,N*R()]);
H=225+Z;
while(L-->0){
B=A[L];
D=B[0];
p=1;
if(B[1]<45)p=-1;
I=O+2*D-(N+4*D)*B[1]/90+p*(10+D/2);
J=10+D/2;
X[r](P-3*D,I,M+6*D,J);
B[0]+=V;
if(D==N)if((I>H&&I<H+50)||(I+J>H&&I+J<H+50))g=0;
}
X[s]='red';
X[r](450,H,N,50);
if(g)setTimeout($,33);else E()
}
$();
function E(){X.fillRect(-h,-h,3*h,3*h);alert('YOU LOOSE\nScore: '+t)}
d.onkeydown=function(e){
k=e.keyCode-39;
Z+=z=3*k*V;
if(Z<-125)Z=-125;
else if(Z>125)Z=125;
else X.translate(0,-z)
}