Read this first.
The only way to do this “right” is to turn the process upside down. Create an engine after you use it in the game.
Secondly. C ++ is not Java. C ++ does not have the base class Object , and it is not needed either. Do not try to fit everything into an inheritance hierarchy. If each object is polymorphic, you swear (everything should be selected in the form of a heap and passed by reference or pointer, for example, to avoid slicing, and does not even make the code more understandable)
The object in the world has a position . He is not alone . Therefore, do not inherit the x, y, z coordinates. Put them in a coordinate class that can be added as a member in the classes that need it.
Finding strings is slow, and you need to handle the case where strings are not unique. (What if I accidentally add two objects named "cube".
Why not rely on simple links or pointers as much as possible?
Why can't I just do Engine->Draw(c) to make the engine draw a cube?
But in fact, the most important tip is not to try to write a shrink game engine for later use. You will end up in exactly where you are now: you need to "rewrite it, and this time do it right." If you want to get something from this that works, you need to start with its use case. First write a game. When you do this, you can start refactoring the code to separate it. Thus, you get an engine that works.
source share