Skip to content

Instantly share code, notes, and snippets.

@farteryhr
Last active January 31, 2019 19:42
Show Gist options
  • Save farteryhr/54e9bac8f24754e8b5b3299afdfe34de to your computer and use it in GitHub Desktop.
Save farteryhr/54e9bac8f24754e8b5b3299afdfe34de to your computer and use it in GitHub Desktop.
SCRIPT-8
const
{sin,cos,round,floor,PI}=Math,
xyadd=(a,b)=>[a[0]+b[0],a[1]+b[1]],
xysub=(a,b)=>[a[0]-b[0],a[1]-b[1]],
xyscl=(a,k)=>[a[0]*k,a[1]*k],
xyneg=(a)=>[-a[0],-a[1]],
xyrot=(a,b)=>[a[0]*b[0]-a[1]*b[1],a[1]*b[0]+a[0]*b[1]],
xyofrot=(t)=>[cos(t),sin(t)],
_=0;
initialState={
sfela:0,
siela:0,
fela:0,
iela:0,
dif:0,
shit:[30,0],
};
update=(s,inp,ela)=>{
s.fela=ela;
s.sfela+=ela;
s.iela=round(ela*10);
s.siela+=s.iela;
s.shit=xyrot(s.shit,xyofrot(ela/(1000/60)*2*PI));
s.dung=(s.sfela*10-s.siela);
}
draw=(s)=>{
clear(5);
print(50,48,s.fela,0);
print(50,54,s.iela,0);
print(50,60,s.sfela,0);
print(50,66,s.siela,0);
print(...xyadd([50,60],s.shit), "60fps", 0);
print(...xyadd([48,66],xyscl([4,0],(""+s.siela).length+7-(s.dung<0?1:0))),~~(s.dung*1e9), 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment