Rotational Collsion Detection

(1/3) > >>

Androider:
I am working on a game in Android and I currently have pixel perfect collision detection working. It first checks bounding boxes and if that returns true then checks the overlap of pixels. All works great except when I rotate my image. The collision detection is still using the old un-rotated 2d pixel array. So my question is how I should go about rotating the indexes of the pixels to match that of the current rotation of the image?

Thanks in advance, I find this subject very interesting to work on!

pitbuller:
Ask your self a question do you really need pixel perfect collision detection. Actual device screen is usually so small that its just not worth it. Pixel perfect collision detection is performance is really bad and the gains are usually neglible. Just compose your game objects from primitives: circles, rectangles, maybe even polygons. Then math is lot more robust and more performant.
Also keep in mind that there is ton of difference size screens in Android scene. How you deal with that if your game logic is based on pixels? What happen when you want animated characters? Do collision events based on current animation state and cause jerky movement.

I desing all my game sizes on meters, this is just lot more natural and work perfectly well on every screen size and every scenario. If I decide that I need more accurate graphics and I double all picture sizes that do not cause any changes on logic layer.

Androider:
I do realize that the collision detection like this is going to hinder the performance a bit. But it only needs to occur if there is a bounding box collision so I really don't think that it will be that bad. And I have seen many android games that have implemented it and it works/looks great. I currently am not worried about animated sprites at all, that will be next.

Currently my game has some collisions that do not look good at all because it is not pixel perfect. I don't necessarily need it on all of the images either. Just one because it has a pointy edge with a lot of transparent pixels around it. It is quite obvious when a collision occurs that shouldn't.

I appreciate your thoughts @pitbuller I need to keep a lot of things in mind when doing this for sure.

pjt33:
How are you rendering the rotated images? In particular:

1. Are you using anti-aliasing? If so, you're going to need to define how pixel-perfect collision should work...
2. Is the angle quantised?
3. Do you pre-render anything to a back-buffer? If not, is the memory vs performance tradeoff the reason why not?

Androider:
I am not using any anti-aliasing to do the rendering. When I display an image on screen it is using the Android Bitmap object(which is very similar to the standard Image class when doing Java Graphics). The rendering is done via a Canvas object which in turn is basically the same as the Graphics2D class in standard Java Graphics. I am not doing anything other than calling a draw method on the Bitmap object via the Canvas. I currently have a 2D array of pixels that I retrieved from the Bitmap and what I am looking to do is as the image is rotated, I need to rotate the pixels in the 2D array to match the specific rotation.

I don't know if this helps at all. What do you mean by "Is the angle quantised?" Thanks! I appreciate your thoughts on this!

Navigation

[0] Message Index

[#] Next page