Skip to content

Instantly share code, notes, and snippets.

@lewdev
Last active September 27, 2024 01:16
Show Gist options
  • Select an option

  • Save lewdev/c4081df601ce2788024a975fe695aad6 to your computer and use it in GitHub Desktop.

Select an option

Save lewdev/c4081df601ce2788024a975fe695aad6 to your computer and use it in GitHub Desktop.
πŸ¦˜πŸ‘¨β€πŸ”§ Super Mario Bros in your URL

πŸ¦˜πŸ‘¨β€πŸ”§ Super Mario Bros in your URL

This was made by xem or @MaximeEuziere on twitter.

Source

Copy-paste the code below into your address bar to run it. Unfortunately, making it compatible to the URL, the size of the app explodes to 1560 characters.

data:text/html,<canvas id=a style=width:1024><script>c=a.getContext`2d`;for(_='o=-.2NonkeyZ,1YY2XY0W=.V=1Uc.fillT][Hf[GGiHj]FTStyle=`%23E==F?(ED]=C)GMHICG10H198C1B--Afor(@;iA;)@%1F@I=i;I%1E),%1D%1Da(2Y9%1C9Y%1B,2%1A,TRect(%19`%199%2A%18])G%17,n%16~~%15,o=0%1D%14=(l,i%13%1DS(%12g(d%11%26%26%101)%0Fj=999;jA;)%0E,9%0C`%190,0%0C99%0C99%1D%0B-9%2Ae%0C%09,8%08;@i oG%07)=>%7B@MU1;MA>l;)%06HiC%05%1Da(6Y%04%10(%03G%15iH%15l]%02%18j%09%2Ai%0C%0C)%01f=[l=u=r=e=o=t=0],d=n=2,y=R=24,S%13%06GM%05GMHi%2B1C4%7D,a%13,e%06if(e)%1E<i%2BM-l;I%2B%2BB;else %1EA>i-M%2Bl;B%7D,g%13,e)=>%7Bif(G%15i])return e%10%02%102!=%02%03%02A%14%02%7D;@iU5%1FGiC[],%0EGiHjCi>10%10![69,70%086%087%088Y53Y54].includes(j)%0722%0C4W%1B2%1B30%173%053%0780%081%082%083%084%085%086%087%0C1%0C2%0C3X1X2X3X8Y31%173%051%078%1A1%1A3,78W6W%1B12Y70%177%053%0720%1A2%1A4,77,79%0C4W0Y18X%1B30%088%08%1B71%177%05G10H198C1;S(9%1A8%128,38%127,46%127,57%129%083%12%1B79%0438%0452%0453%1C0%1C1%0440Y%0455,%0F,Zdown=Zup=(l=>selG`lur`[l.which-37]Cl.type[5]%1DsetInterval("@R-V02,Math.hypot(R-dW-n)<1%03z?(R=-1,N)%3At=%0F,l%10d>e%10%11-V1%16)%03dU%2B%15d%1Dr%03g((d%2BV%0F%2B1%16)?d=%15d-.1%3Ad>e%2B7%03e%2BV%0F%1Du%10!z%03N5)%16%2B=o%2BV012,o<0%10%11%16%2B=o,%0F%7C%11%2B.9%16,%0F%03nU%2B%15n%14(n>14%7C%7Cd>198)%03t=%0F,z=u=!(%11%16%2B%0F%7C%11%2B.5%16%2B%0F%1Dz%7C%7C(n=%15n%14E59f%0BiU3%1F%0E4D8d1%01%191784%09%1A%08%0F)%3A3Df93%01)%3AF%03Ec40%01);Ea00%18R%090%0C%0C%1DEd20%18d%09%2An%0C%0C%1Dt%10top.reload(%1Dy%03E000%0ByA)"%0C)';G=/[%01-%1F@-HT-ZN]/.exec(_);)with(_.split(G))_=join(shift());eval(_)</script>

You can run through World 1-1 in the original Super Mario Bros level. There is exactly one harmless enemy and several endless pits. It's amazing how they were able to cram so much into just 1k. I'm most interested in what the code actually looks like in terms how collision detection was implemented in a scrolling screen.

<canvas id=a><script>c=a.getContext`2d`;for(_='o=-.2NonkeyZ,1YY2XY0W=.V=1Uc.fillT][Hf[GGiHj]FTStyle=`#E==F?(ED]=C)GMHICG10H198C1B--Afor(@;iA;)@@I=i;I),a(2Y99Y,2,TRect(`9*])G,n~~,o=0=(l,iS(g(d&&1)j=999;jA;),9 `0,0 99 99 -9*e ,8;@i oG)=>{@MU1;MA>l;)HiCa(6Y(GiHl]j *i )f=[l=u=r=e=o=t=0],d=n=2,y=R=24,SGMGMHi+1C4},a,eif(e)<i+M-l;I++B;else A>i-M+l;B},g,e)=>{if(Gi])return e2!=A};@iU5GiC[],GiHjCi>10![69,70678Y53Y54].includes(j)22 4W23033801234567 1 2 3X1X2X3X8Y3131813,78W6W12Y70732024,77,79 4W0Y18X308717G10H198C1;S(988,387,467,5793793852530140Y55,,Zdown=Zup=(l=>selG`lur`[l.which-37]Cl.type[5]setInterval("@R-V02,Math.hypot(R-dW-n)<1z?(R=-1,N):t=,ld>e-V1)dU+drg((d+V+1)?d=d-.1:d>e+7e+Vu!zN5)+=o+V012,o<0+=o,|+.9,nU+n(n>14||d>198)t=,z=u=!(+|+.5+z||(n=nE59f iU34D8d11784 ):3Df93):FEc40);Ea00R 0 Ed20d *n ttop.reload(yE000 yA)" )';G=/[-@-HT-ZN]/.exec(_);)with(_.split(G))_=join(shift());eval(_)</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment