15 Jan 12, 02:41AM
(This post was last modified: 15 Jan 12, 02:46AM by Felix-The-Ghost.)
If we could at least clip off the corners of the square distribution, we might not need to lower the spread. It's easy enough to distribute in a diamond pattern though circle is probably better.
Currently as I understand it,
say spread value is RANDMAX:
x -= rand() % (RANDMAX + 1)
x += rand() % (RANDMAX + 1)
then y is offset with the same possible random values:
y -= rand() % (RANDMAX + 1)
y += rand() % (RANDMAX + 1)
This results in the square pattern distribution.
If we just made it so XMAX and YMAX are less than or equal to RANDMAX, you'd have a diamond shape distribution. Roflcopter's circle shape is probably better (and probably not noticeably slower with the circle math either)
Currently as I understand it,
say spread value is RANDMAX:
x -= rand() % (RANDMAX + 1)
x += rand() % (RANDMAX + 1)
then y is offset with the same possible random values:
y -= rand() % (RANDMAX + 1)
y += rand() % (RANDMAX + 1)
This results in the square pattern distribution.
If we just made it so XMAX and YMAX are less than or equal to RANDMAX, you'd have a diamond shape distribution. Roflcopter's circle shape is probably better (and probably not noticeably slower with the circle math either)