• 08-19-2013, 02:17 PM
Hello Guys... i Hope this time i make the post in the right section :P
i need to know if there are more advances ways to chech about the collision between two bufferedImages For example.... in my project to chech about the Collision i use the ordinary way with creating two Rectangles and then just check if one intersect in other..

but there are some problems one like this :

Attachment 5424

by Creating two Rectangles is really hard to understand from what side the images collides
then i try to Create a 2D line for each side (Left , Right , up ,down) then to check which one of the collides first then do what i want.. but if you chech the image above what will happen if the image collides with the up left corner ? it depends of that line will collide first..

to solve this problem (with my low knowledge) i do something like that : Attachment 5425

but this is very bad idea.. i have a lot of enemies characters.. so this is very confusing...

then i read something about Per Pixel based collision detection and XNA but i don't really understand what is going on.. so i need help .. :P
every info will be useful ;)

• 08-19-2013, 02:26 PM
gimbal2
The way I deal with the bounding box problem is to add pixel perfect collision detection. So collision detection is a two-phase check:

1) do the bounding boxes overlap?
2) when they do, do any actual pixels of the entities overlap?

Step 2 is the one that makes programming difficult, how the heck do you do that?

I did it by creating a dumb array of booleans for each frame of each bob (bob = an animating sprite) where each index represents a single pixel in the image; it would be true if the pixel is opaque and false if it is transparent. Then all I needed to do was compare the parts of the array where the bounding boxes overlap (again: very much not easy) to see if one of the cells that are on top of each other both contain the value true. If so: DEATH!

EDIT: eh its a bit confusing what you're after actually. You are also talking about a direction. But depending on the location of the pixels that touch each other, you should be able to work out a rudimentary collision location too. I take it you want to be able to check if it is death for you or death for the enemy because you jumped on its head :)
• 08-19-2013, 07:47 PM
Remarkable Answer... Thanks for the informations!! i am going to take a look at them right now ;)

Google is my best friend ;)
• 08-19-2013, 11:23 PM
gimbal2