mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-25 11:37:56 +00:00
554eb505f8
of the x11 based games. I'm not going to tag the originals with bsd_44_lite and do this in two stages since it's just not worth it for this collection, and I've got directory renames to deal with that way. Bleah. Submitted by: jkh
39 lines
656 B
C
39 lines
656 B
C
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
|
/* hack.track.c - version 1.0.2 */
|
|
|
|
#include "hack.h"
|
|
|
|
#define UTSZ 50
|
|
|
|
coord utrack[UTSZ];
|
|
int utcnt = 0;
|
|
int utpnt = 0;
|
|
|
|
initrack(){
|
|
utcnt = utpnt = 0;
|
|
}
|
|
|
|
/* add to track */
|
|
settrack(){
|
|
if(utcnt < UTSZ) utcnt++;
|
|
if(utpnt == UTSZ) utpnt = 0;
|
|
utrack[utpnt].x = u.ux;
|
|
utrack[utpnt].y = u.uy;
|
|
utpnt++;
|
|
}
|
|
|
|
coord *
|
|
gettrack(x,y) register x,y; {
|
|
register int i,cnt,dist;
|
|
coord tc;
|
|
cnt = utcnt;
|
|
for(i = utpnt-1; cnt--; i--){
|
|
if(i == -1) i = UTSZ-1;
|
|
tc = utrack[i];
|
|
dist = (x-tc.x)*(x-tc.x) + (y-tc.y)*(y-tc.y);
|
|
if(dist < 3)
|
|
return(dist ? &(utrack[i]) : 0);
|
|
}
|
|
return(0);
|
|
}
|