#include #include #include long h[4]; int s,c; timer() { setitimer(0,h,0); } sigtab[] = {(int)timer, 0, 2}; main () { char piste[80][25]; FILE *fp; int x=5,y=5,xold,yold; char * a; char c; fp=fopen("piste","r"); while (!feof(fp)) { for(y=1;y<10;y++) { for(x=1;x<81;x++) { fscanf(fp,"%c",&c); piste [x][y]=c; printf("%c",c); } } } h[3]=250000; a="opazxq"; sigvec(14,sigtab,0); test(); timer(); x=y=5; for(;;) { printf("\033[u\033[1D "); printf("\033[%d;%dH\033[7m \033[0m",y,x); printf("\033[s"); pause(); printf("\033[0;0H%d",rand()); c=getchar(); /*xold=x;yold=y; */ if(c==*a)x--; if(c==a[1])x++; if(c==a[2])y--; if(c==a[3])y++; /*if (piste[x][y]==1) {x=xold;y=yold;}*/ if(c==a[4]||c==a[5]) /* if q pressed */ { s=sigblock(8192); if(c==a[5])break; while(getchar()-a[4]); sigsetmask(s); } } } test() { int fd , i; struct termio test; /* Remember to substitute the terminal's name */ fd=open(ttyname(0),O_WRONLY); ioctl(fd, TCGETA, &test); /* Put all the changes in here */ test.c_cc[VMIN]=1; test.c_cc[VTIME]=1; test.c_lflag &= (!ICANON); ioctl(fd, TCSETA, &test); close(fd); }