- Author:
- shining_armor
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- Compo:
- canvas
- Demo link:
- https://js1k.com/2017-magic/demo/2813
- Shortlink:
- https://js1k.com/2813
- Blog post:
- please update here!
- Bytes:
- 1019
- Chars:
- 1019
- Submission
R=Math.random;B=c.beginPath.bind(c);M=c.moveTo.bind(c);Q=c.quadraticCurveTo.bind(c);A=(x,y,r)=>c.arc(x,y,r,0,7);F=c.fill.bind(c);c.lineWidth=6;c.font="55px Arial";z=20;X=Y=T=P=180;U=D=V=S=0;W=2;C=[];for(i=7;i--;)C[i]={X:90,Y:-90,J:1};d.onkeydown=e=>{U=e.which==38;D=e.which==40};d.onkeyup=e=>U=D=0;setInterval(_=>{if(S+1){Y+=V+=D-U;Y=Y<z?z:Y>340?340:Y;V*=.8;c[f="fillStyle"]=q="#77e";c.fillRect(0,0,640,360);T+=(Y-T)*.05;P+=(Y-P)*.1;for(i=7;i--;)c.strokeStyle="#"+"f00f90ff00708cf00f83d".substr(i*3,3),B(),M(-9,T+6*i-z),Q(40,P+6*i-z,X-35,Y+6*i-z),c.stroke();c[f]="#038";x=X+10;y=Y-15;B();M(X-26,Y-5);Q(X,Y-2,X-26,Y+3);F();M(X-3,Y-3);Q(x,Y-z,X-25,y);F();M(X,Y-5);Q(x,y,X+18,y);Q(X+25,Y-z,X+z,Y-13);Q(X+29,Y+3,X+19,Y-2);Q(x,Y-8,x,Y+10);F();B();A(X,Y+15,22);F();c[f]=q;B();A(X+2,Y+27,25);F();c[f]=w="#eee";c.fillText(S,40,60);W/=.9995;C.some(O=>{x=O.X-=W,y=O.Y;if(Math.hypot(X-x,Y-y)<40)O.X=-40,O.J?++S:S=-1;if(x<-90)O.X=640+200*R(),O.Y=R()*360,O.J=R()>.2;c[f]=O.J?w:"#222";B(),A(x-z,y,12),A(x,y,z),A(x+z,y,16),F()})}},16)
- Description
- Collect white clouds
Controls: up/down arrows
- Base64 encoded
Uj1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LmZpbGxUZXh0KFMsNDAsNjApO1cvPS45OTk1O0Muc29tZShPPT57eD1PLlgtPVcseT1PLlk7aWYoTWF0aC5oeXBvdChYLXgsWS15KTw0MClPLlg9LTQwLE8uSj8rK1M6Uz0tMTtpZih4PC05MClPLlg9NjQwKzIwMCpSKCksTy5ZPVIoKSozNjAsTy5KPVIoKT4uMjtjW2ZdPU8uSj93OiIjMjIyIjtCKCksQSh4LXoseSwxMiksQSh4LHkseiksQSh4K3oseSwxNiksRigpfSl9fSwxNik=
- Original source
R=Math.random
B=c.beginPath.bind(c)
M=c.moveTo.bind(c)
Q=c.quadraticCurveTo.bind(c)
A=(x,y,r)=>c.arc(x,y,r,0,7)
F=c.fill.bind(c)
c.lineWidth=6
c.font="55px Arial"
z=20
// pegasus
X=Y=T=P=180
U=D=V=S=0
W=2
// clouds
C=[]
for(i=7;i--;)
C[i]={X:90,Y:-90,J:1}
// controls
d.onkeydown=e=>{U=e.which==38;D=e.which==40}
d.onkeyup=e=>U=D=0
// main loop
setInterval(_=>{
if(S+1){
Y+=V+=D-U
Y=Y<z?z:Y>340?340:Y
V*=.8
// clear screen
c[f="fillStyle"]=q="#77e"
c.fillRect(0,0,640,360)
T+=(Y-T)*.05
P+=(Y-P)*.1
// draw rainbow
for(i=7;i--;)
c.strokeStyle="#"+"f00f90ff00708cf00f83d".substr(i*3,3), B(), M(-9,T+6*i-z), Q(40,P+6*i-z,X-35,Y+6*i-z), c.stroke()
// draw pegasus
c[f]="#038"
x=X+10
y=Y-15
B()
M(X-26,Y-5)
Q(X,Y-2,X-26,Y+3)
F()
M(X-3,Y-3)
Q(x,Y-z,X-25,y)
F()
M(X,Y-5)
Q(x,y,X+18,y)
Q(X+25,Y-z,X+z,Y-13)
Q(X+29,Y+3,X+19,Y-2)
Q(x,Y-8,x,Y+10)
F()
B()
A(X,Y+15,22)
F()
c[f]=q
B()
A(X+2,Y+27,25)
F()
// cloud counter
c[f]=w="#eee"
c.fillText(S,40,60)
// update and draw clouds
W/=.9995
C.some(O=>{
x=O.X-=W,y=O.Y;
if(Math.hypot(X-x,Y-y)<40)
O.X=-40,O.J?++S:S=-1;
if(x<-90)
O.X=640+200*R(),O.Y=R()*360,O.J=R()>.2;
c[f]=O.J?w:"#222";
B(),A(x-z,y,12),A(x,y,z),A(x+z,y,16),F()
})
}
}, 16)