Hi everyone,
I'm working on building a physics engine for a ship to ship combat game as a way to learn C++ and give some very rusty physics and math skills a workout.
As a general design/best practice, do you normally create more complex objects by adding simpler ones to them or is it better to have simpler standalone objects do work on a more complex Object's data outside that object?
I don't think I'm saying that very well, so here's an example.
I've got 2 classes:
- Point - takes x,y coordinates and can calculate distance between 2 points
- Ship - Holds damage levels, firepower, armor, etc...
would you usually have a ship class instantiate a private Point object and use it internally to calculate the distance between itself and another ship. Or would you wait until you needed to calculate distance and use the 2 Ship object's public methods to get their current positions and feed it into a separate Point object?