xref: /original-bsd/games/trek/visual.c (revision d10933c5)
1 /*
2  * Copyright (c) 1980, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)visual.c	8.1 (Berkeley) 05/31/93";
10 #endif /* not lint */
11 
12 # include	"trek.h"
13 
14 /*
15 **  VISUAL SCAN
16 **
17 **	A visual scan is made in a particular direction of three sectors
18 **	in the general direction specified.  This takes time, and
19 **	Klingons can attack you, so it should be done only when sensors
20 **	are out.
21 */
22 
23 /* This struct[] has the delta x, delta y for particular directions */
24 struct xy	Visdelta[11] =
25 {
26 	-1,	-1,
27 	-1,	 0,
28 	-1,	 1,
29 	 0,	 1,
30 	 1,	 1,
31 	 1,	 0,
32 	 1,	-1,
33 	 0,	-1,
34 	-1,	-1,
35 	-1,	 0,
36 	-1,	 1
37 };
38 
39 visual()
40 {
41 	register int		ix, iy;
42 	int			co;
43 	register struct xy	*v;
44 
45 	co = getintpar("direction");
46 	if (co < 0 || co > 360)
47 		return;
48 	co = (co + 22) / 45;
49 	v = &Visdelta[co];
50 	ix = Ship.sectx + v->x;
51 	iy = Ship.secty + v->y;
52 	if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS)
53 		co = '?';
54 	else
55 		co = Sect[ix][iy];
56 	printf("%d,%d %c ", ix, iy, co);
57 	v++;
58 	ix = Ship.sectx + v->x;
59 	iy = Ship.secty + v->y;
60 	if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS)
61 		co = '?';
62 	else
63 		co = Sect[ix][iy];
64 	printf("%c ", co);
65 	v++;
66 	ix = Ship.sectx + v->x;
67 	iy = Ship.secty + v->y;
68 	if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS)
69 		co = '?';
70 	else
71 		co = Sect[ix][iy];
72 	printf("%c %d,%d\n", co, ix, iy);
73 	Move.time = 0.05;
74 	Move.free = 0;
75 }
76