2D pixel collision detection

Started by
6 comments, last by TinyGameDev 17 years, 5 months ago
so I'm trying to play around with some small game thingy in OpenGL in 2D and I was wondering how can one do pixel-sensitive collision detection? I was thinking of having two layers, one for the background of the scene and one for the foreground with the objects that should collide. What's the best way of doing this? Is it by having multiple quads with a texture each or is it multi-texturing? Can you still do pixel-collision if you use multi-textures? Thanx

Making Terralysia, wishlist now on Steam <3!

Advertisement
I guess I am lost by what do you mean by pixel collision? If you mean that you want a object e.g. ship to collide with a wall? If so use a 2D array that holds all the objects locations and then you just test the current object's location to see if it hit with the other objects locations. But like I said I am unsure if thats what you are asking. HTH
Well I'm using sprites so I'd like to test the pixels and not the bounding box/sphere. The alpha part of the texture should not be consider when doing the detection.

Making Terralysia, wishlist now on Steam <3!

Not sure if its possible or not, but why not split the sprites up into multiple bounding boxes, or any other way (there are more).

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

I guess that's one way of doing it. Won't it be hard to keep track of the bounding boxes if I have complex animations which need that bounding boxes to move around a lot?

What other options do I have? Haven't done this sort of thing before so I'm greatfully for any ideas.

Making Terralysia, wishlist now on Steam <3!

.

Plenty of information out there about this, [google] "pixel-perfect collision detection" and you'll get more than enough articles.

But, it's generally not necessary. You could use the 80% rule, where you just use a bounding box that is 80% of the size of actual image. It works pretty darn well, and is much easier. And note that this also has the advantage that you can now resolve the collision, where as with pixel-perfect collision, you don't actually have any information with which to bounce objects around, or even to push them apart so that they don't collide anymore.
Ok ok, you've convinced me. I'm gonna try the 80% rule see how it goes =)

Thanx all

Making Terralysia, wishlist now on Steam <3!

.

I think so too :D

Making Terralysia, wishlist now on Steam <3!

This topic is closed to new replies.

Advertisement