Java IndexOutOfBoundsException

Posted by Meko on Stack Overflow See other posts from Stack Overflow or by Meko
Published on 2010-03-17T09:52:15Z Indexed on 2010/03/17 10:11 UTC
Read the original article Hit count: 457

Filed under:
|

Hi all ... I made an little shoot em up game..It works normal but I want also implement if fires intersects they will disappear. I have two list for Player bullets and for computer bullets ...But if I have more bullets from computer or reverse .Here my loop

     for (int i = 0; i < cb.size(); i++) {
        for (int j = 0; j < b.size(); j++) {
            if (b.get(j).rect.intersects(cb.get(i).rect)) {

                cb.remove(i);
                b.remove(j);


                continue;

            }
            if (cb.get(i).rect.intersects(b.get(j).rect)) {


                b.remove(j);
                cb.remove(i);

                continue;

            }

        }

    }

© Stack Overflow or respective owner

Related posts about java

Related posts about game