public class Particles extends Vector { private SpaceGrid spaceGrid; Particles() { super(); spaceGrid = new SpaceGrid(width,height,Particle.MAX_INFLUENCE_RANGE); } void addParticle(Particle p) { if (p.pos.X>=0&&p.pos.X=0&&p.pos.Y=width||p.newPos.Y<0||p.newPos.Y>=height) { remove(p); i--; } } // clear spacGrid; spaceGrid.clear(); // update new positions (also in spacegrid) for (int i=0;i