eval("eval(\"n=document;C=n.body.children[0].getContext('2d'EM=Math;k=[r=Ap=At=AS=0];m=255;u=(h=100D2;T=j){a-=p;return(M.cos(a/96O139))O512D8D30O8Y5};R=jPw,c,g,bZ){FStyle='rgb('+[c,gHc,bHgHc]+')';FRect(aPwZH1)};Qdown=Qup=j){(b=a.keyCode-37)W2H(Xb]=a.type[5]?.5:0)};I=setKj){S=q-qAX3]-X1]+1/4NM.abs(r)>(a=56)VSE8Eb=(p+=S|Y0/3W13;r=q-q((o=_85)V(x=X2]-X0]V_85-SV(o-_35)DS/5Y-rZEhB60;U-;)JAi,30Af,f*2G-35,uG-bEi>40HJmN_4*U75Vo)/1AL3,4,mEJ140-(c=zM.acos(1G/40)D60Vo/2AUb+6Acvm,fB9;h-1>L+;)JAd=L5A30Ac=h+bGZ+b,aG|1EJ(e=150+_iVo)GPiv(Up)%8192?c:fEzhNi/h-2DLp%10)>0HJeG/32Pi/16,fB-3;29>L+;)i>27&&JrNU26Da,12A8,X3]*mv1,A2EJc=112Ng=(g=20GDg/12D(.5+x/3)+r,Lh,64-g,U1W3&&i<29?f:a,i<1?120:(U9W3?-5:5DLaEi>19HJg/2-(o+u)/1ALhW1Z-gv150-bGEi>18HJ275,39Gv2AL3>S*2.8?1:m);FText(q3,1Nb=p-aW13))+'/3    'Nt++/20|0Em-7,aEb<3HclearKI)},50)\"!_T(!Z,h!Y0D4!Xk[!W>>!V)-!Ui-!Qn.onkey!P,d,!O+za/!N+(!Li+!v*2,!KInterval(!JR(!H||!G-i!fu+b!FC.fill!E),!D)*!B);for(i=!A0,!zM.sin(!qM.min(!jfunction(a)".replace(/!(\w)([^!]*)(?!$)/g,".replace(/$1/g,\"$2\")"))
          // 1k Turismo - arcade racer in 1k
// See http://games.23inch.de/1kturismo/ for converter scripts
n = document;
context = n.body.children[0].getContext('2d'),
M = Math;
// keys pressed, x position, y(track) position, elapsed time, speed
keys = [car=0,pos=0,time=0,speed=0];
// some frequently used numbers
m = 255;
u = (h=100)*2;
/// procedurally generated track following ideas from @unconed's js1k demo #171
track=function(a)
{
  a -= pos;
  return(M.cos(a/96+M.sin(a/139))+M.sin(a/512)*8)*30+M.sin(a/80)*45
};
/// draws a rectangle, height, blue and green colors can be omitted
rect=function(a,d,w,c,g,b,h)
{
  context.fillStyle = 'rgb('+[c,g||c,b||g||c]+')';
  context.fillRect(a,d,w,h||1)
};
/// de-/activates keys
// up/down check lifted from @marijnjh's js1k demo #635
n.onkeydown = n.onkeyup = function(a)
{
  (b = a.keyCode-37) >> 2 || (keys[b] = a.type[5]?.5:0)
};
/// main
I=setInterval(function(a)
{
  // change speed, check if 0 <= speed <= 8
  // every step: -0.25, accelerate/break: +/- 0.25, off-track penalty: -2
  speed = M.min(-M.min(0,keys[3]-keys[1]+1/4+(M.abs(car)>(a=56))-speed),8),
  // move car forward and get current step(0-40) in sunrise animation
  b = (pos+=speed|0)*40/3 >> 13;
  /// change horizontal position, check if -100 <= car <= 100.
  // - turns are detected by assuming a linear track (only the visible part) and
  // calculating the difference between expected and actual mid-track position
  // - to avoid using max(), min() is called with inverted inputs and outputs
  car = M.min(-M.min(((offset=track(85))-(x=keys[2]-keys[0])-track(85-speed)-(offset-track(35))*speed/50)*4-car,h),h);
  /// draw environment
  for(i=60; i--;)
    // sky
    rect(0,i,300,u+b,u+b*2-i-35,u-i-b),
    // mini map
    i>40 || rect(m+(track(4*i-75)-offset)/10,i+3,4,m),
    // rising sun
    rect(140-(c=M.sin(M.acos(1-i/40))*60)-offset/20,i-b+60,c*2,m,u+b);
  /// draw track
  for(i=9; h-1>i++;)
    // ground
    rect(0,d=i+50,300,c=h+b-i,h+b,a-i|1),
    // street and lap start painting
    rect((e=150+track(i)-offset)-i,d,i*2,(i-pos)%8192?c:u+b),
    // middle painting
    M.sin(h+(i/h-2)*i+pos%10)>0 || rect(e-i/32,d,i/16,u+b);
  /// draw car
  for(i=-3; 29>i++;)
    // stop lights
    i>27 && rect(car+(i-26)*a,120,8,keys[3]*m*2,1,0,2),
    // car body  ↓ shape         ↓ perspective         ↓ colors
    rect(c=112+(g=(g=20-i)*g/12)*(.5+x/3)+car,i+h,64-g,i-1>>3&&i<29?u+b:a,i<1?120:(i-9>>3?-5:5)*i+a),
    // mountain (reuses the shape of the car)
    i>19 || rect(g/2-(offset+u)/10,i+h>>1,h-g*2,150-b-i),
    // speed bars
    i>18 || rect(275,39-i*2,20,i+3>speed*2.8?1:m);
  // print stats
  context.fillText(M.min(3,1+(b = pos-a>>13))+'/3    '+(time++/20|0),m-7,a),
  // stop after third lap
  b<3 || clearInterval(I)
},50)