I plan to check overlaps via Pythagoras.
The part I'm struggling with is the table like this. Basically I have added a static growth speed that increments the r (radius value).
I need to test each circle against all others in the array and destroy any two or more that touch as they grow. I'm not sure how to loop through this as it needs to go forward and backwards. Do I need to extract the one I'm looking at then compare it to all others and place it back at the end if not touching any of the others then start with the next one? some sort of reordering? or is there a cleaner way to do this.
Code: Select all
table = {}
table[1] = {x=10,y=10,r=10}
table[2] = {x=100,y=150,r=10}
table[3] = {x=200,y=200,r=10}
table[4] = {x=400,y=400,r=10}
compare table[1] to all others in the table then table[2] to all others in table eventually destroying them as the collide. is fine just cant seem to work the comparisons through the table.
Code: Select all
local dx = rX - v.x
local dy = rY - v.y
local distCalc = dx * dx + dy * dy
if distCalc <= ((v.r ) + (rR ))^2 then
collides = true
--remove from table
regards