collision detection

Hi,
I’m searching for hints about doing pixel precise collision detection with java2d. I thought about having a second image as a kind of collision map for each sprite/tile, with just black and white pixels, and then do pixel per pixel comparisation. Or maybe I shouldn’t use an image as collision map but just a 2-dimensional array of int. Does anyone know a good tutorial about this or can give me some advice?

You can have more or less “pixel perfect” collision detection without using pixel to pixel comparisons which is by far very expensive to execute.

Can your sprites/images be represented by an arbitrary shape, say a polygon? If that’s the case, then it’s better to just compare line intersections rather than pixels.

What I’m planning to do is some kind of racing game, where you see the car you’re driving from a bird’s eye perspective. What I need to check is collisions with the “border” of the road and other cars/bikes etc. So, yes, I think I could use polygons for collision detection. This kind of racing games must have been done a hundred times before, so maybe there’s something like a best pratice guide how to do it?

A little bit off topic but anyway…

The difficult part of a game like that (especially with pure java2D) is the rotation of the images. I wanted to make a game like that a while ago, but rotating images were simply too slow, and I got lazy, so I gave up, and I was just wondering how are you planning to rotate the images? I had an algorithm that rotated triangles drawn with fillPolygon, but as soon as i started with images, I ran into said problem.