If this is not the right place for this question, could you please direct me to a more suitable site/forum?
I'm a beginner in game development (and in the use of this site). I've worked with C++ only for rather small scientific simulations, so I can "code" but I've never done a full-blown design of an OO program, much less of a game. You can tell from what I'll write next :P
I've decided to write an open source educational game that simulates accurately the motion of the Sun, the planets and of one or more spacecraft controlled by the player. By "simulates accurately" I mean that I want to use a scientifically valid and precise algorithm to obtain the forces and thus the motions of the bodies.
The game will be in 3D and will use the Ogre3D engine for the graphics. Graphically it will look similar to Celestia.
The first difficulty is that I've never designed the structure and the classes of any game. By reading a few references and guides I think I have a vague idea of how the dynamics could work, but it's vague: each entity (planet or spacecraft) could store its own state information and then have an "update" function that updates the state based on some input (like user commands). There are probably many other ways to do this, I guess.
The main problem, however, comes from the particular needs of this project:
- my objects must not only respond to user input, but also obey accurate physical laws, and the algorithm that computes them must be centralized. This is because it needs to know the positions of all the bodies at the same time to perform its computations;
- I plan to add different kinds of spacecraft with different types of propulsion, and some of them would react to the other bodies in special ways (think antigravity).
The Question
Is there a design pattern or architecture suitable for this problem?
The best I can think of is to have a singleton Universe class containing the central algorithm for the dynamics. The various objects of the solar system then communicate with Universe. They would contain basic parameters like mass and size, and they would listen to Universe telling them where to stand.
However this doesn't sound right. Where do I put the ever-changing trajectory data of all the bodies, in Universe? What's the point of having all those objects then? Only for the graphical part of the game?
And what about the special dynamical properties of some spacecraft? I can't possibly include them all in the central algorithm from the beginning.
Ok, I think you can tell how confused I am about the matter much better than me. I would be grateful for any kind of input.