java - Collision detection inside the same ArrayList -


After searching a few days, I have not found any solutions I have an ArrayList of collision elements < / Code>, which I want to intersect and calculate the collision. I have made many efforts, but I am currently stumped.

Collision method (called once in game-tick)

  public zero iterative () (if (iterbox) {If (iterateBoxes) {for (int I = 0; i & lt; boxPool.size (); i ++) {for (int j = i + 1; j & lt; boxPool.size (); j ++) {if (! (BoxPool (I ) .equals (boxPool.get (j))) & amp; amp; amp; & amp; amp; and investigate; test (boxPool.get (i), boxPool.get (j)) {boxPool.get (i). Colliding = true; BoxPool.get (j) .colliding = true;}}}}}}  

For those of you to detect a conflict that is reviewing it Wanted:

  Public Boolean Check Exams (BASAB B-1 box, BASABB box 2) {// This is just to get the center vector of the bounding box: Vector 2 FC1 = AAABBCeter (box 1); Vector 2 FC2 = AABBBC (Box 2); if (Mathematics .bas (c1.x - c2.x)> (box1.width + box2.width)) returned incorrect; if (math.bas (c1.y - c2.y)> (box1.height + box2.height  

  1. Forgot to add that I suspect you should change the following condition:


        boxPool.get (i)! = BoxPool.get (j)  with 

    :

     ! BoxPool.get (i) .equals (BoxPool.get (j))  

    Forward, there is not a double requirement of loop on all elements; Always start with j = I + 1 and then you i! = J :

     For  (int i = 0; i   

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -