]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.track.c
Clean this up, and be more consistent:
[bsdgames-darwin.git] / hack / hack.track.c
1 /*
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
3 */
4
5 #ifndef lint
6 static char rcsid[] = "$NetBSD: hack.track.c,v 1.3 1995/03/23 08:31:42 cgd 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 }