public void checkCollisions() { for (int i = 0; i < 20; i++) { if (hast.getBounds().intersects(box[i].getBounds())) { hast.collision = true; traff = true; } else if (traff == false) { hast.collision = false; } } }