xref: /csrg-svn/games/robots/make_level.c (revision 21467)
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[] = "@(#)make_level.c	5.1 (Berkeley) 05/30/85";
9 #endif not lint
10 
11 # include	"robots.h"
12 
13 /*
14  * make_level:
15  *	Make the current level
16  */
17 make_level()
18 {
19 	register int	i;
20 	register COORD	*cp;
21 	register WINDOW	*wp;
22 	register int	x, *endp;
23 
24 	reset_count();
25 	for (i = 1; i < Y_FIELDSIZE; i++)
26 		for (x = 1; x < X_FIELDSIZE; x++)
27 			if (Field[i][x] != 0)
28 				mvaddch(i, x, ' ');
29 	if (My_pos.y > 0)
30 		mvaddch(My_pos.y, My_pos.x, ' ');
31 
32 	Waiting = FALSE;
33 	Wait_bonus = 0;
34 	leaveok(stdscr, FALSE);
35 	for (cp = Robots; cp < &Robots[MAXROBOTS]; cp++)
36 		cp->y = -1;
37 	My_pos.y = -1;
38 
39 	bzero(Field, sizeof Field);
40 	Min.y = Y_FIELDSIZE;
41 	Min.x = X_FIELDSIZE;
42 	Max.y = 0;
43 	Max.x = 0;
44 	if ((i = Level * 10) > MAXROBOTS)
45 		i = MAXROBOTS;
46 	Num_robots = i;
47 	while (i-- > 0) {
48 		cp = rnd_pos();
49 		Robots[i] = *cp;
50 		Field[cp->y][cp->x]++;
51 		if (cp->y < Min.y)
52 			Min.y = cp->y;
53 		if (cp->x < Min.x)
54 			Min.x = cp->x;
55 		if (cp->y > Max.y)
56 			Max.y = cp->y;
57 		if (cp->x > Max.x)
58 			Max.x = cp->x;
59 	}
60 	My_pos = *rnd_pos();
61 	refresh();
62 }
63