I have a dynamic list of objects and need to place them around a centre object without overlapping. They are all rectangle shapes. I am using Java FX text objects.
If I place the first object in the centre with
int x =(int)(scene.getWidth() /2);
int y =(int)(scene.getHeight() /2);
How do I position the others around it without overlapping.There are n amount of objects.
I am not sure how to detect the collision and then move them once the collision has been detected.
if collision = true {
translate x 30 px{
if still true {
translate y 30{
if still true{
translate x -30
if still true{
translate y -30{
if still true {
start again but increase movement size by 20 each iteration
until collision free placement occurs.
x----->----x
| |
^ |
| |
| |
x----<-----x
Thanks