Play game
Labyrinth's itch.io pageHow many characters of code did you use?
551
Include your code here, if you'd like to show it off!
<canvas id=c><script>r=Math.random;k=e=>{if(e){g[b][a]=W;e=e.key;x=a;y=b;e=='w'?y--:e=='s'?y++:e=='a'?x--:e=='d'?x++:s;if(g[y][x]==R)location.reload();if(g[y][x]==W)b=y,a=x}g[b][a]='#0f0';for(y=b-1;y<b+2;y++){for(x=a-1;x<a+2;x++){c.fillStyle=g[y][x];c.fillRect(x*9,y*9,9,9)}}};W='#888';R='#f00';d=a=b=1;c=c.getContext('2d');g=[];for(y=0;y<15;y++){g[y]=Array(29).fill('#000')};for(y=1;y<15;y+=2){for(x=1;x<29;x+=2){g[y][x]=W;r()>.5&&y<13||x>26?g[y+1][x]=W:x<27?g[y][x+1]=W:s;if(y>1&&r()>.9&&d)d=0,g[y][x]=R}}g[14][27]='#000';onkeypress=k;k();</script>
Leave a comment
Log in with itch.io to leave a comment.
Comments
Very good skills! Also, didn`t know you could use 3-byte color, this is real game changer!
Thanks! Also the with(object) is pretty good, you can omit the object in object.method() [you can save like 5/7 byte in your setinterval if you start it with(c) and then omit all c. ]
Thank you a lot , you are really boosting me up :) most of my help procedures were just to omit Math or c. Now it`s time for smething bigger :)
Nifty! Thanks for a pure JavaScript example! I was wondering what could tiny games might be done with JS.
JS is quite good to write spaghetti code 8) Also you can use online tools to shrink your code, i don't like them because they remove all the fun but they are quite good.