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