Commit | Line | Data |
---|---|---|
dc63b842 KM |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
4cd7a139 KB |
3 | * All rights reserved. |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
b7647a4b KB |
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. | |
dc63b842 KM |
16 | */ |
17 | ||
18 | #ifndef lint | |
b7647a4b | 19 | static char sccsid[] = "@(#)make_level.c 5.3 (Berkeley) %G%"; |
4cd7a139 | 20 | #endif /* not lint */ |
dc63b842 KM |
21 | |
22 | # include "robots.h" | |
23 | ||
24 | /* | |
25 | * make_level: | |
26 | * Make the current level | |
27 | */ | |
28 | make_level() | |
29 | { | |
30 | register int i; | |
31 | register COORD *cp; | |
32 | register WINDOW *wp; | |
33 | register int x, *endp; | |
34 | ||
35 | reset_count(); | |
36 | for (i = 1; i < Y_FIELDSIZE; i++) | |
37 | for (x = 1; x < X_FIELDSIZE; x++) | |
38 | if (Field[i][x] != 0) | |
39 | mvaddch(i, x, ' '); | |
40 | if (My_pos.y > 0) | |
41 | mvaddch(My_pos.y, My_pos.x, ' '); | |
42 | ||
43 | Waiting = FALSE; | |
44 | Wait_bonus = 0; | |
45 | leaveok(stdscr, FALSE); | |
46 | for (cp = Robots; cp < &Robots[MAXROBOTS]; cp++) | |
47 | cp->y = -1; | |
48 | My_pos.y = -1; | |
49 | ||
50 | bzero(Field, sizeof Field); | |
51 | Min.y = Y_FIELDSIZE; | |
52 | Min.x = X_FIELDSIZE; | |
53 | Max.y = 0; | |
54 | Max.x = 0; | |
55 | if ((i = Level * 10) > MAXROBOTS) | |
56 | i = MAXROBOTS; | |
57 | Num_robots = i; | |
58 | while (i-- > 0) { | |
59 | cp = rnd_pos(); | |
60 | Robots[i] = *cp; | |
61 | Field[cp->y][cp->x]++; | |
62 | if (cp->y < Min.y) | |
63 | Min.y = cp->y; | |
64 | if (cp->x < Min.x) | |
65 | Min.x = cp->x; | |
66 | if (cp->y > Max.y) | |
67 | Max.y = cp->y; | |
68 | if (cp->x > Max.x) | |
69 | Max.x = cp->x; | |
70 | } | |
71 | My_pos = *rnd_pos(); | |
72 | refresh(); | |
73 | } |