1 /* 2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. 3 */ 4 5 #ifndef lint 6 static char rcsid[] = "$Id: hack.track.c,v 1.2 1993/08/02 17:19:31 mycroft Exp $"; 7 #endif /* not lint */ 8 9 #include "hack.h" 10 11 #define UTSZ 50 12 13 coord utrack[UTSZ]; 14 int utcnt = 0; 15 int utpnt = 0; 16 17 initrack(){ 18 utcnt = utpnt = 0; 19 } 20 21 /* add to track */ 22 settrack(){ 23 if(utcnt < UTSZ) utcnt++; 24 if(utpnt == UTSZ) utpnt = 0; 25 utrack[utpnt].x = u.ux; 26 utrack[utpnt].y = u.uy; 27 utpnt++; 28 } 29 30 coord * 31 gettrack(x,y) register x,y; { 32 register int i,cnt,dist; 33 coord tc; 34 cnt = utcnt; 35 for(i = utpnt-1; cnt--; i--){ 36 if(i == -1) i = UTSZ-1; 37 tc = utrack[i]; 38 dist = (x-tc.x)*(x-tc.x) + (y-tc.y)*(y-tc.y); 39 if(dist < 3) 40 return(dist ? &(utrack[i]) : 0); 41 } 42 return(0); 43 } 44