by fzammetti » Mar 24, 2003 @ 8:02pm
Ah, your right, forgot it's 565... Argh.
Anyway... I know there are a number of different collision detection methods... I'm actually not familiar with the binary mask method, could you elaborate?
The way I've always done it, in the instances where pixel-level detection is required (I tend to use bounding circles alone most of the time), is to look for specific RGB values... for instance, a space ship colliding with an asteroid, I would have an outline of one or both of them be a specific color (assuming a black background for space, maybe I'd make the outline RGB 1/1/1), then just check for that in the pixels where the movement will be (i.e., ship moving to the right I'd check the pixels at shipX + shipWidth + 1 for my 1/1/1 RGB values before I actually do the move, going along the right edge of my ship so I'm only testing a single column of pixels). It's easy enough to code and relatively efficient when moving in the four cardinal directions, diagonals tends to be just a bit more difficult to code, but not terribly so.
I'm absolutely certain that's not the best way efficiency-wise, but depending on the sizes of the graphics and other factors it may not hurt your performance to a degree that matters.
But I'm interested in other techniques for sure...
...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"