BSD 4_2 release
[unix-history] / usr / src / games / trek / visual.c
CommitLineData
13afb696 1#ifndef lint
0f4556f1 2static char sccsid[] = "@(#)visual.c 4.2 (Berkeley) 5/27/83";
13afb696
KM
3#endif not lint
4
5# include "trek.h"
6
7/*
8** VISUAL SCAN
9**
10** A visual scan is made in a particular direction of three sectors
11** in the general direction specified. This takes time, and
12** Klingons can attack you, so it should be done only when sensors
13** are out.
14*/
15
16/* This struct[] has the delta x, delta y for particular directions */
06d69904 17struct xy Visdelta[11] =
13afb696
KM
18{
19 -1, -1,
20 -1, 0,
21 -1, 1,
22 0, 1,
23 1, 1,
24 1, 0,
25 1, -1,
26 0, -1,
27 -1, -1,
28 -1, 0,
29 -1, 1
30};
31
32visual()
33{
34 register int ix, iy;
35 int co;
36 register struct xy *v;
37
38 co = getintpar("direction");
39 if (co < 0 || co > 360)
40 return;
41 co = (co + 22) / 45;
42 v = &Visdelta[co];
43 ix = Ship.sectx + v->x;
44 iy = Ship.secty + v->y;
45 if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS)
46 co = '?';
47 else
48 co = Sect[ix][iy];
49 printf("%d,%d %c ", ix, iy, co);
50 v++;
51 ix = Ship.sectx + v->x;
52 iy = Ship.secty + v->y;
53 if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS)
54 co = '?';
55 else
56 co = Sect[ix][iy];
57 printf("%c ", co);
58 v++;
59 ix = Ship.sectx + v->x;
60 iy = Ship.secty + v->y;
61 if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS)
62 co = '?';
63 else
64 co = Sect[ix][iy];
65 printf("%c %d,%d\n", co, ix, iy);
66 Move.time = 0.05;
67 Move.free = 0;
68}