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