Annotation of 43BSDTahoe/games/trek/visual.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted
                      6:  * provided that the above copyright notice and this paragraph are
                      7:  * duplicated in all such forms and that any documentation,
                      8:  * advertising materials, and other materials related to such
                      9:  * distribution and use acknowledge that the software was developed
                     10:  * by the University of California, Berkeley.  The name of the
                     11:  * University may not be used to endorse or promote products derived
                     12:  * from this software without specific prior written permission.
                     13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     16:  */
                     17: 
                     18: #ifndef lint
                     19: static char sccsid[] = "@(#)visual.c   5.3 (Berkeley) 6/18/88";
                     20: #endif /* not lint */
                     21: 
                     22: # include      "trek.h"
                     23: 
                     24: /*
                     25: **  VISUAL SCAN
                     26: **
                     27: **     A visual scan is made in a particular direction of three sectors
                     28: **     in the general direction specified.  This takes time, and
                     29: **     Klingons can attack you, so it should be done only when sensors
                     30: **     are out.
                     31: */
                     32: 
                     33: /* This struct[] has the delta x, delta y for particular directions */
                     34: struct xy      Visdelta[11] =
                     35: {
                     36:        -1,     -1,
                     37:        -1,      0,
                     38:        -1,      1,
                     39:         0,      1,
                     40:         1,      1,
                     41:         1,      0,
                     42:         1,     -1,
                     43:         0,     -1,
                     44:        -1,     -1,
                     45:        -1,      0,
                     46:        -1,      1
                     47: };
                     48: 
                     49: visual()
                     50: {
                     51:        register int            ix, iy;
                     52:        int                     co;
                     53:        register struct xy      *v;
                     54: 
                     55:        co = getintpar("direction");
                     56:        if (co < 0 || co > 360)
                     57:                return;
                     58:        co = (co + 22) / 45;
                     59:        v = &Visdelta[co];
                     60:        ix = Ship.sectx + v->x;
                     61:        iy = Ship.secty + v->y;
                     62:        if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS)
                     63:                co = '?';
                     64:        else
                     65:                co = Sect[ix][iy];
                     66:        printf("%d,%d %c ", ix, iy, co);
                     67:        v++;
                     68:        ix = Ship.sectx + v->x;
                     69:        iy = Ship.secty + v->y;
                     70:        if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS)
                     71:                co = '?';
                     72:        else
                     73:                co = Sect[ix][iy];
                     74:        printf("%c ", co);
                     75:        v++;
                     76:        ix = Ship.sectx + v->x;
                     77:        iy = Ship.secty + v->y;
                     78:        if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS)
                     79:                co = '?';
                     80:        else
                     81:                co = Sect[ix][iy];
                     82:        printf("%c %d,%d\n", co, ix, iy);
                     83:        Move.time = 0.05;
                     84:        Move.free = 0;
                     85: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.