emojysics

febuary 2019

A tiny 2D physics engine made in JS then golfed (with circles only) in 1Kb for JS1K 2019.

Click to add a new emoji, double-click to add a fixed disc.

- Original Mini2DPhysics project

- Github

- Demo

- Commented source code

- making-of

<body id=b>
<canvas id=a></canvas>
<script>
c = a.getContext('2d')
a.width = innerWidth;
a.height = innerHeight;
for(_='-1!o(@z(@O&&(Qa.widthUU/We(_=_qb.~,~$at#d.HHD*m.GV,@!FHpageLd,Ky(l,J--;)for(HtHbV(b,0,,~dq~d=C()**~):c.fillHd),c.=!.5*g(n,=f.length;)t,HD+=y(m,*2*t=	*2t+y(m,M#h.random(69|0+12a.heightOLX,LY/(~t+~V~Vt$tHVqHVt,~D-=J=(Kb=W50+9,t=1/b)=>zf.push({KV:@0t,B:t?:D:Z:String.fromCodePoint(8512)}o({Kb}rg(Kd*.5,e@+~K+~bC_d!V@**bgd+yb-KRK1/(r(d)||1f=[];OW2,+W4W2,0i=99;iOW2+W4,-));onclicketail>1?,0):setInterval(\'U^=ii{jjb=f[i],d=f[j],M$dr(M)<~b+QD=~b+-r(MN=R(MSqR(M,!EqSN,D(~t||)Qh=N,D.8h,-~tqh,pqS,E$t)lp$dmp,n_HF*GGd_~FD*l.~D*l.d)sN)+JNN	N,sNsNs*,u=R(C(nN,g(n,N))!xu.5+Juu	u,xuxux*));~tQ~V.b++$B+=.02D,~V,.02)c.sav_beginP#h(transl#_~$rot#_~Barc(~7lineT@0font=11.5b+"% a",f[i].t?navig#or.userAgent.m#ch`Ma`?c.strok_Text(~Z,1.3*-~.65b(restor_)}\',16)';G=/[-J-LF-H#$~q_WUQO@!]/.exec(_);)with(_.split(G))_=join(shift());eval(_)
</script>