/* SNAKE.C*/main() $(  int s,x,y,zx,zy,z,sc,hs;  slow();  printf("\fThe object of this game is to draw the\nline though as many boxes as possible\n");  printf("without touching the line or the border.\n\n\n");  printf("        Press button to start.\n");  while(strig(0));  sc=hs=0;  while(1) $(    graphics(11);    poke(710,0); /* screen black */    zx=1;    zy=0;    x=40;    y=90;    color(10); /* draw the border */    plot(0,0);    drawto(79,0);    drawto(79,191);    drawto(0,191);    drawto(0,0);    box();    while(1) $( /* while no collision with self or border */      z=locate(x,y);      if((z == 10) || (z == 5)) break; /* collision with self or border */      color(5);      plot(x,y);      if(z == 15) $( /* hit a box */        sc+=10;        box(); /* draw a new box */      $)      s=stick(0);      if(s<15) $( /* joystick was moved */        if((s == 14) && (!zy)) $(          zx=0;          zy=-1;        $)        if((s == 13) && (!zy)) $(          zx=0;          zy=1;        $)        if((s == 11) && (!zx)) $(          zx=-1;          zy=0;        $)        if((s == 7) && (!zx)) $(          zx=1;          zy=0;        $)      $)      for(z=1;z<100;++z); /* slow down! */      x+=zx;      y+=zy;      ++sc;      if(zx != 0) for(z=1;z<170;++z); /* slow down horizontal which is faster than vertical */    $)    graphics(0); /* end of the game */    poke(710,0);    position(5,7);    printf("score= %d\thighest = %d\n",sc,hs);    if(sc>hs) hs=sc;    sc=0;    printf("     Press button to play again\n");    while(strig(0));  $)$)box() $( /* draws a random box */  int a,b;  a=rnd(69-5)+5;  b=rnd(179-5)+5;  color(15);  plot(a,b);  drawto(a+2,b);  drawto(a+2,b+2);  drawto(a,b+2);  drawto(a,b);$)