/* Ants, C code by Nava Whiteford */
/* This code should compile using EasyC */
/* If you don't have easy C then a DeskLib version is also inclosed */
/* Please note this is vastly over commented. Just so nothing remains
   unexplained */

/* For Frobnicate */

#include <stdio.h>
#include "roslib.h"
#define s 10       /* defines the size of each cell */
#define halfs 5    /* defines half the size of each cell */
/* BTW, if you make the size of the cell to small it messes up something to do with os_point */


int colour, end, done, key;
int antx=70, anty=70, head=3;

main()
{

  os_mode(29);

  for(;end==0;)
  {
    colour=os_point(antx*s+halfs,anty*s+halfs);

    if(colour==0){os_gcol(0,1); head++; if(head== 4) head=0;}
    if(colour==1){os_gcol(0,0); head--; if(head==-1) head=3;}
    /* ^^^ changes ants direction, says what the new color will be ^^^ */
    os_rectanglefill(antx*s, anty*s, s, s); /* This draws the ants trail */

    /* This bit moves the ant around */
    if(head==0) anty++;
    if(head==1) antx++;
    if(head==2) anty--;
    if(head==3) antx--;

    key=os_inkey(0);
    if(key==113) end=1;  /* press "q" to stop */
  }
}
