-Once a particle exits the frame of the snapshot, it loses its contribution to the center of mass of the "galaxy" and once it reenters the frame, it returns its contribution to the center of mass back.
---------
We recommend using VS_code, Spyder, or Jupyter notebook editiors to run this simulation. Enjoy :)