1 /* Written by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
2 * Understanding is not required. Only obedience.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import arsd
.simpledisplay
;
27 // ////////////////////////////////////////////////////////////////////////// //
32 __gshared Interference
[] ifs
;
35 // ////////////////////////////////////////////////////////////////////////// //
38 foreach (ref l
; ifs
) {
39 if (l
.speed
== 0) continue;
43 if (l
.y
< l
.ey
) l
.speed
= 0;
45 if (l
.y
> l
.ey
) l
.speed
= 0;
52 void drawIfs (NVGContext vg
) {
53 if (vg
is null) return;
54 foreach (ref l
; ifs
) {
55 if (l
.speed
== 0) continue;
57 vg
.fillColor(nvgRGB(0, 40, 0));
58 vg
.rect(0, l
.y
-1, GWidth
, 3);
65 import std
.random
: uniform
;
68 while (idx
< ifs
.length
&& ifs
[idx
].speed
!= 0) ++idx
;
69 if (idx
>= ifs
.length
) {
70 if (ifs
.length
> 10) return false;
71 ifs
~= Interference();
73 if (uniform
!"[]"(0, 1) == 0) {
75 ifs
[idx
].y
= GHeight
/2+uniform
!"[]"(50, GHeight
/2-100);
76 int ty
= ifs
[idx
].y
-40;
77 if (ty
< 0) return false;
78 ifs
[idx
].ey
= uniform
!"[]"(0, ty
);
79 ifs
[idx
].speed
= -uniform
!"[]"(1, 25);
82 ifs
[idx
].y
= GHeight
/2-uniform
!"[]"(50, GHeight
/2-100);
83 int ty
= ifs
[idx
].y
+40;
84 if (ty
>= GHeight
) return false;
85 ifs
[idx
].ey
= uniform
!"[]"(ty
, GHeight
);
86 ifs
[idx
].speed
= uniform
!"[]"(1, 25);