public void checkCollisions() { Rectangle r3 = craft.getBounds(); for (int j = 0; j < aliens.size(); j++) { Alien a = (Alien) aliens.get(j); Rectangle r2 = a.getBounds(); if (r3.intersects(r2)) { craft.setVisible(false); a.setVisible(false); ingame = false; } } ArrayList ms = craft.getMissiles(); for (int i = 0; i < ms.size(); i++) { Missile m = (Missile) ms.get(i); Rectangle r1 = m.getBounds(); for (int j = 0; j < aliens.size(); j++) { Alien a = (Alien) aliens.get(j); Rectangle r2 = a.getBounds(); if (r1.intersects(r2)) { m.setVisible(false); a.setVisible(false); } } } }