Hello all,
This is my first post here, just started using consctruct. Im trying to make objects spawn but still check for collision.
I seem to get everything working except the spawn collision.
Example:
So i have for instance a rock with solid and collision enabled.
And every 10seconds this rock spawns a new rock.
The rock is spawned on a image point to the right of the original rock outside of the collision area.
It is then given a new set position to a random spot Random(-20,20) away from this spot.
The trouble is that each rock does this and the rocks start to randomly overlap.
So i do a check for collision after the move and if it has collision it moves again. However this is verry ineffective because say i do it with Rock{1} (so i only remove the 2e rock of the collision) i see the rocks moving around on the screen to slowly form a non overlaping pattern, but everything jumps and does things... i dont really want that.
What i would have liked is calling Move(true) or spawn(true) or something similar to explain to the spawn or move function that it needs adhere the collision and move or spawn to a new spot but adhere to collision (perhaps do a collision check before moving and getting new coords if the collision is true).
Now i did manage to get this working someway or another (but not like i want it) by adding physics and not setting the position of the rocks but by actually moving them a giving amount of px/pt in a random(0/360) angle. This will make sure i get 0 overlap however everything ofcourse moves abit and its also extremely slow if i for instance generate 10000 rocks...
So thats a whole bunch of string:), i hope its clear, if not i can post a file here tonight to show what i mean. However perhaps somebody understood what i want and knows a easy way to do this.
Regards,
Jasper