[quote]I'm going to have a lot of these sprites in my game at once, so it'd be nice if I didn't have to compute distance between all of them each tick. I thought the overlaps on offset was perfect, but I guess not?[/quote]
I'm honestly not sure that overlap is less expensive than distance checking.
To check the distance between two points, the formula is (and it's what c2 use):[code]distance(xa,ya,xb,yb) = sqrt((xa-xb)^2 + (ya-yb)^2)[/code]
basically you have 4 multiplications, 1 addition and one square root operation.
The square root operation is known to be a bit slow
Now for an overlap check, depending on the complexity of the shapes and the fact that they are rotated or not, it can be easy, or less easy.
But the basic "quad is overlapping quad" function more or less check if one is contained inside the other, and then if not, it checks if there's an interesection between each segments.
The operations used are fairly simple but it something of the order of
"number of vertices of object A TIMES number of vertices of object B"
So it can get pretty iffy.
Now, the only thing that is a bit unknown here is the speed of a square root operation. But you know, you don't even have to use a square root, you can yourself check if:[code](xa-xb)^2 + (ya-yb)^2 < someDistance^2[/code]Then you have your cheap distance check.Yann2013-07-14 23:07:23