]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hunt/huntd/draw.c
1 /* $NetBSD: draw.c,v 1.3 2003/06/11 12:00:22 wiz Exp $ */
3 * Copyright (c) 1983-2003, Regents of the University of California.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * + Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * + Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * + Neither the name of the University of California, San Francisco nor
16 * the names of its contributors may be used to endorse or promote
17 * products derived from this software without specific prior written
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
35 __RCSID("$NetBSD: draw.c,v 1.3 2003/06/11 12:00:22 wiz Exp $");
50 outstr(pp
, pp
->p_maze
[0], WIDTH
);
51 for (y
= 1; y
< HEIGHT
- 1; y
++) {
52 endp
= &pp
->p_maze
[y
][WIDTH
];
53 for (x
= 0, sp
= pp
->p_maze
[y
]; sp
< endp
; x
++, sp
++)
56 if (pp
->p_x
== x
&& pp
->p_y
== y
)
57 outch(pp
, translate(*sp
));
58 else if (isplayer(*sp
))
59 outch(pp
, player_sym(pp
, y
, x
));
64 cgoto(pp
, HEIGHT
- 1, 0);
65 outstr(pp
, pp
->p_maze
[HEIGHT
- 1], WIDTH
);
70 * drawstatus - put up the status lines (this assumes the screen
71 * size is 80x24 with the maze being 64x24)
80 cgoto(pp
, STAT_AMMO_ROW
, STAT_LABEL_COL
);
81 outstr(pp
, "Ammo:", 5);
82 (void) sprintf(Buf
, "%3d", pp
->p_ammo
);
83 cgoto(pp
, STAT_AMMO_ROW
, STAT_VALUE_COL
);
86 cgoto(pp
, STAT_GUN_ROW
, STAT_LABEL_COL
);
87 outstr(pp
, "Gun:", 4);
88 cgoto(pp
, STAT_GUN_ROW
, STAT_VALUE_COL
);
89 outstr(pp
, (pp
->p_ncshot
< MAXNCSHOT
) ? " ok" : " ", 3);
91 cgoto(pp
, STAT_DAM_ROW
, STAT_LABEL_COL
);
92 outstr(pp
, "Damage:", 7);
93 (void) sprintf(Buf
, "%2d/%2d", pp
->p_damage
, pp
->p_damcap
);
94 cgoto(pp
, STAT_DAM_ROW
, STAT_VALUE_COL
);
97 cgoto(pp
, STAT_KILL_ROW
, STAT_LABEL_COL
);
98 outstr(pp
, "Kills:", 6);
99 (void) sprintf(Buf
, "%3d", (pp
->p_damcap
- MAXDAM
) / 2);
100 cgoto(pp
, STAT_KILL_ROW
, STAT_VALUE_COL
);
103 cgoto(pp
, STAT_PLAY_ROW
, STAT_LABEL_COL
);
104 outstr(pp
, "Player:", 7);
105 for (i
= STAT_PLAY_ROW
+ 1, np
= Player
; np
< End_player
; np
++) {
106 (void) sprintf(Buf
, "%5.2f%c%-10.10s %c", np
->p_ident
->i_score
,
107 stat_char(np
), np
->p_ident
->i_name
,
108 np
->p_ident
->i_team
);
109 cgoto(pp
, i
++, STAT_NAME_COL
);
110 outstr(pp
, Buf
, STAT_NAME_LEN
);
114 cgoto(pp
, STAT_MON_ROW
, STAT_LABEL_COL
);
115 outstr(pp
, "Monitor:", 8);
116 for (i
= STAT_MON_ROW
+ 1, np
= Monitor
; np
< End_monitor
; np
++) {
117 (void) sprintf(Buf
, "%5.5s %-10.10s %c", " ",
118 np
->p_ident
->i_name
, np
->p_ident
->i_team
);
119 cgoto(pp
, i
++, STAT_NAME_COL
);
120 outstr(pp
, Buf
, STAT_NAME_LEN
);
134 check(pp
, y
- 1, x
- 1);
135 check(pp
, y
- 1, x
);
136 check(pp
, y
- 1, x
+ 1);
137 check(pp
, y
, x
- 1);
139 check(pp
, y
, x
+ 1);
140 check(pp
, y
+ 1, x
- 1);
141 check(pp
, y
+ 1, x
);
142 check(pp
, y
+ 1, x
+ 1);
144 switch (pp
->p_face
) {
187 for (i
= 0; See_over
[(int)*--sp
]; i
++)
211 for (i
= 0; See_over
[(int)*sp
++]; i
++)
235 if (!See_over
[(int)*sp
])
239 sp
-= sizeof Maze
[0];
243 } while (See_over
[(int)*sp
]);
247 if (!See_over
[(int)*sp
])
251 sp
+= sizeof Maze
[0];
255 } while (See_over
[(int)*sp
]);
269 index
= y
* sizeof Maze
[0] + x
;
270 ch
= ((char *) Maze
)[index
];
271 if (ch
!= ((char *) pp
->p_maze
)[index
]) {
274 if (x
== rpp
->p_x
&& y
== rpp
->p_y
)
275 outch(rpp
, translate(ch
));
276 else if (isplayer(ch
))
277 outch(rpp
, player_sym(rpp
, y
, x
));
280 ((char *) rpp
->p_maze
)[index
] = ch
;
286 * Update the status of players
296 y
= STAT_PLAY_ROW
+ 1 + (pp
- Player
);
299 for (np
= Monitor
; np
< End_monitor
; np
++) {
300 cgoto(np
, y
, STAT_SCAN_COL
);
304 for (np
= Player
; np
< End_player
; np
++) {
305 cgoto(np
, y
, STAT_SCAN_COL
);
312 * Draw the player on the screen and show him to everyone who's scanning
313 * unless he is cloaked.
325 Maze
[y
][x
] = draw
? pp
->p_face
: pp
->p_over
;
328 for (newp
= Monitor
; newp
< End_monitor
; newp
++)
332 for (newp
= Player
; newp
< End_player
; newp
++) {
333 if (!draw
|| newp
== pp
) {
337 if (newp
->p_scan
== 0) {
341 else if (newp
->p_scan
> 0) {
347 if (!draw
|| pp
->p_cloak
< 0)
349 if (pp
->p_cloak
-- == 0)
358 cgoto(pp
, HEIGHT
, 0);
359 outstr(pp
, s
, strlen(s
));
365 * Turn a character into the right direction character if we are
366 * looking at the current player.
387 * Return the player symbol
397 if (npp
->p_ident
->i_team
== ' ')
400 if (pp
->p_ident
->i_team
== '*')
401 return npp
->p_ident
->i_team
;
403 if (pp
->p_ident
->i_team
!= npp
->p_ident
->i_team
)
405 return pp
->p_ident
->i_team
;