Play lazer beam
Try not to pop balloon's itch.io pageHow many characters of code did you use?
553
Include your code here, if you'd like to show it off!
<p id=p></p><canvas id=a><script>c=a.getContext`2d`;Z=a.height=a.width=800;z=x=y=Z/2;u=10+Math.random()*280;v=10+Math.random()*280;s=n=undefined;t=e=>{c.fillStyle=e};onload=c.fillRect(0,0,Z,Z);I=setInterval(e=>{if(n!=undefined){x+=5*Math.cos(n);y+=5*Math.sin(n)}t`blue`;c.beginPath();c.arc(v,u,10,0,0.1,1);c.fill();t`red`;c.fillRect(x-2,y-2,4,4);if(x<0||x>Z)n=3.14-n;if(y<0||y>Z)n=6.28-n;if(s!=undefined)p.innerHTML=s++;if((x-v)*(x-v)+(y-u)*(y-u)<100)clearInterval(I)},1);onclick=e=>{if(n==undefined){n=Math.atan2(e.clientY-z,e.clientX-z);s=0}}</script>
Leave a comment
Log in with itch.io to leave a comment.
Comments
No one has posted a comment yet