|
13 | 13 | void stat_inicjuj(STATEK* sta, KAPSULA* kaps) |
14 | 14 | { |
15 | 15 | int i, j; |
16 | | - if (!random(2)) |
17 | | - sta->x = random(30); |
18 | | - else |
19 | | - sta->x = random(30) + 269; |
20 | | - sta->y = random(79); |
| 16 | + |
| 17 | + if ((rand() % 2) == 0) { |
| 18 | + sta->x = rand() % 30; |
| 19 | + } |
| 20 | + else { |
| 21 | + sta->x = (rand() % 30) + 269; |
| 22 | + } |
| 23 | + sta->y = rand() % 79; |
| 24 | + |
21 | 25 | sta->zm_x = 0; |
22 | 26 | sta->zm_y = 0; |
23 | 27 | sta->aktywny = 1; |
24 | | - sta->xs_min = random(319); |
25 | | - sta->xs_max = sta->xs_min + random(319 - sta->xs_min); |
26 | | - for (i = 0; i < 3; i++) |
27 | | - sta->poc_x[i] = random(319); |
| 28 | + |
| 29 | + sta->xs_min = rand() % 319; |
| 30 | + sta->xs_max = sta->xs_min + rand() % (319 - sta->xs_min); |
| 31 | + |
| 32 | + for (i = 0; i < 3; i++) { |
| 33 | + sta->poc_x[i] = rand() % 319; |
| 34 | + } |
| 35 | + |
28 | 36 | sta->licznik = 0; |
29 | 37 | sta->k = 0; |
30 | 38 | sta->laser_pom = 0; |
31 | 39 | if (kaps->punkty < 20) |
32 | 40 | sta->giwera = 0; |
33 | 41 | else if (kaps->punkty >= 20 && kaps->punkty < 40) |
34 | | - sta->giwera = random(2); |
| 42 | + sta->giwera = rand() % 2; |
35 | 43 | else if (kaps->punkty >= 40 && kaps->punkty < 60) |
36 | | - sta->giwera = random(3); |
| 44 | + sta->giwera = rand() % 3; |
37 | 45 | else if (kaps->punkty >= 60 && kaps->punkty < 80) |
38 | | - sta->giwera = random(4); |
| 46 | + sta->giwera = rand() % 4; |
39 | 47 | else if (kaps->punkty >= 80 && kaps->punkty < 100) |
40 | | - sta->giwera = random(5); |
| 48 | + sta->giwera = rand() % 5; |
41 | 49 | else |
42 | | - sta->giwera = random(6); |
| 50 | + sta->giwera = rand() % 6; |
43 | 51 | if (sta->giwera != 5) { |
44 | | - sta->ruch = random(2); |
45 | | - sta->v = random(2); |
| 52 | + sta->ruch = rand() % 2; |
| 53 | + sta->v = rand() % 2; |
46 | 54 | } else { |
47 | 55 | sta->ruch = 2; |
48 | 56 | sta->v = 1; |
@@ -209,8 +217,8 @@ void stat_ruch2(STATEK* statek) |
209 | 217 | } |
210 | 218 | } |
211 | 219 | if (!statek->zm_x && !statek->zm_y) { |
212 | | - statek->kx = random(299); |
213 | | - statek->ky = random(100); |
| 220 | + statek->kx = rand() % 299; |
| 221 | + statek->ky = rand() % 100; |
214 | 222 | statek->zm_x = 1; |
215 | 223 | statek->zm_y = 1; |
216 | 224 | } |
|
0 commit comments