One thing I like to do when I'm using per-pixel collision detection is to have MyBitMask1: array[1..sprite.width, 1..sprite.height] of boolean for all sprites. You can fill these arrays programatically like this:
if sprite.pixels[I, J] = MyColorKey then
MyBitMask1[I, J] := true;
obviously you wouldn't use the pixels property because that would be way too slow. But speed doesn't matter all that much as the arrays are only filled once upon program initialization.
Then use bounding-box collision to see if two sprites collide, get the overlapping-rect and do this:
Code:
CollisionTest: Boolean;
..
begin
CollisionTest := false;
for J := OverlapRect.Top to OverlapRect.Bottom do
begin
for I := OverlapRect.Left to OverlapRect.Right do
begin
if MyBitMask1[I, J] and MyBitMask2[I, J] then
begin
CollisionTest := true;
Break;
end;
end;
end;
if CollisionTest then
...
end;
obviously that code would have to be adjusted...
Hope that helps.
Bookmarks