37 lines
1.2 KiB
Markdown
37 lines
1.2 KiB
Markdown
# Darklord.js — addBloodSpreadBranches() (satır 1366)
|
||
|
||
[← Darklord.js](index.md) · [← Master](../../wiki.md)
|
||
|
||
```javascript
|
||
function addBloodSpreadBranches(pool, x, z, cx, cz, radiusSq)
|
||
{
|
||
var dirs = [
|
||
[1, 0], [-1, 0], [0, 1], [0, -1],
|
||
[1, 1], [1, -1], [-1, 1], [-1, -1]
|
||
];
|
||
|
||
var count = 2 + Math.floor(Math.random() * 4);
|
||
for (var i = 0; i < count; i++)
|
||
{
|
||
var d = dirs[Math.floor(Math.random() * dirs.length)];
|
||
var step = Math.random() < 0.22 ? 2 : 1;
|
||
var nx = x + d[0] * step;
|
||
var nz = z + d[1] * step;
|
||
var dx = nx - cx;
|
||
var dz = nz - cz;
|
||
if (dx * dx + dz * dz <= radiusSq) addBloodSpreadLine(pool, x, z, nx, nz, cx, cz, radiusSq);
|
||
}
|
||
|
||
if (Math.random() < 0.28)
|
||
{
|
||
var a = Math.random() * Math.PI * 2.0;
|
||
var jump = 2 + Math.floor(Math.random() * 4);
|
||
var jx = x + Math.round(Math.cos(a) * jump);
|
||
var jz = z + Math.round(Math.sin(a) * jump);
|
||
var jdx = jx - cx;
|
||
var jdz = jz - cz;
|
||
if (jdx * jdx + jdz * jdz <= radiusSq) addBloodSpreadLine(pool, x, z, jx, jz, cx, cz, radiusSq);
|
||
}
|
||
}
|
||
```
|