- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
Generator.prototype.update = function () {
var t = this.timer++,
d = this.delay,
s = this.samples,
m = this.minDistance,
w = this.width,
h = this.height,
g = this.global,
c = this.cid,
ttl = this.ttl--,
l = s.length,
rand = Math.random,
floor = Math.floor,
x,
y,
r,
i,
j,
d2,
n;
if (ttl > 0) {
while (t > d) {
r = s[floor(rand() * l)].copy();
if (m) {
i = 1000;
while (i--) {
x = rand() * w - w * 0.5;
y = rand() * h - h * 0.5;
for (j in this) if (j instanceof Entity) {
n = this[i];
d2 = (x - n.x) * (x - n.x) + (y - n.y) * (y - n.y);
if (d2 * d2 > m) {
i = 0;
}
}
}
} else {
x = rand() * w - w * 0.5;
y = rand() * h - h * 0.5;
}
r.x = x;
r.y = y;
if (!g) {
r.parent = this;
}
this[c] = r;
this.cid = c += 1;
this.time = t -= d;
}
} else {
delete this.update;
}
};