Continuously, not discreetly.
Suppose I want to spawn 10 circles on a 500x500 map without any intersection. I can do this...
array of circles
for(i to 10){
x and y random 0-499
for(c in circles){
while (x, y) lies within circle c
x and y random 0-499
}
create circle at point (x, y)
push circle to array
}
However, this doesn't seem optimal. At high numbers of circles or on small map sizes there's a risk of an infinite loop, or at the very least unnecessary computation. That said, it's also a bad idea to create a 500x500 array of pixels and mark them off as available or taken because we're looking at a huge amount of memory (which is also being accessed repeatedly.) Is there a better method?
If I offer to help you in a post, PM me to get it. I often forget to revisit threads.
Want 180+ free PSP games? Try these links! - Flash - Homebrew (OFW)