Currently, I am in the process of developing a 2D gravity simulation game and I am faced with the challenge of implementing save/load functionality. The game involves storing all current planets in an array format. Each planet is depicted by a Body object which includes essential details such as coordinates, mass, and motion vector. Additionally, it maintains a record of the last 100 coordinates to produce a visual trail on the screen.
My objective is to utilize JSON.stringify() for serializing the planets array. However, my intention is to exclude the storage of the last 100 coordinates (trail array) and solely focus on saving the fundamental attributes of each planet (mass, location, motion). Is there a method to stringify only a portion of each object? If not, should I explore the option of eliminating that segment from the encoded JSON string afterwards? Alternatively, would it be more efficient to transfer the coordinate data elsewhere during the saving process and reinstate it into each planet upon completion of the save operation?