Results 1 to 5 of 5
Like Tree2Likes
  • 1 Post By gimbal2
  • 1 Post By gimbal2

Thread: More Advances Collision detection

  1. #1
    ShadowWalker is offline Senior Member
    Join Date
    Mar 2013
    Location
    Greece
    Posts
    113
    Rep Power
    0

    Default More Advances Collision detection

    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 :

    More Advances Collision detection-image1.png

    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 : More Advances Collision detection-image2.png

    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 ;)

    thx in advance!

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: More Advances Collision detection

    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 :)
    Last edited by gimbal2; 08-19-2013 at 03:31 PM.
    ShadowWalker likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    ShadowWalker is offline Senior Member
    Join Date
    Mar 2013
    Location
    Greece
    Posts
    113
    Rep Power
    0

    Default Re: More Advances Collision detection

    Remarkable Answer... Thanks for the informations!! i am going to take a look at them right now ;)

    Google is my best friend ;)

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: More Advances Collision detection

    yeah well in this case not too much, this is something that basically everyone reinvents for himself :)

    Did I ever point you to java-gaming.org? Its a website where basically all Java developers that do game development congregate (some even that SELL games they build using Java, which is quite an amazing achievement). There you can find tons and tons of questions and examples on doing not only collision detection but basically everything else too. You probably know Minecraft? It basically started there. You can still find the old thread where Notch was sharing his ideas and was asking for advice.
    ShadowWalker likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    ShadowWalker is offline Senior Member
    Join Date
    Mar 2013
    Location
    Greece
    Posts
    113
    Rep Power
    0

    Default Re: More Advances Collision detection

    Yeah i know about Minecraft ... i have spend a lot of times playing it :P hahaha
    Thx for the website i am going to check it right now :P

Similar Threads

  1. Need Help With Collision Detection
    By scotthdez in forum New To Java
    Replies: 2
    Last Post: 07-24-2013, 07:01 PM
  2. Collision Detection
    By Äppelpaj in forum Java 2D
    Replies: 1
    Last Post: 10-13-2011, 04:29 PM
  3. Collision Detection
    By sunde887 in forum Java 2D
    Replies: 2
    Last Post: 10-08-2011, 12:40 AM
  4. Collision Detection?
    By Alerhau in forum New To Java
    Replies: 39
    Last Post: 09-07-2011, 05:55 PM
  5. Collision Detection
    By dotabyss in forum Java Gaming
    Replies: 0
    Last Post: 03-14-2010, 07:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •