What would be a better parctice, writing the drawing method inside the GameObject class or in the Game class?
GameObject obj = new GameObject();
obj.Draw();
Or
GameObject obj = new GameObject();
DrawGameObject(obj);
What would be a better parctice, writing the drawing method inside the GameObject class or in the Game class?
GameObject obj = new GameObject();
obj.Draw();
Or
GameObject obj = new GameObject();
DrawGameObject(obj);
It depends on what Game
and GameObject
are responsible for. Typically, a GameObject
would contain all the information about what to draw -- it'd have a model, for instance. But objects aren't independent of each other -- knowing what to draw isn't sufficient to know how to draw it.
So a Game
probably knows a lot more than a GameObject
. In particular, it might know:
Of the two options presented, it probably makes more sense to put the Draw
method outside the GameObject
.