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);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on what
GameandGameObjectare responsible for. Typically, aGameObjectwould 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
Gameprobably knows a lot more than aGameObject. In particular, it might know:Of the two options presented, it probably makes more sense to put the
Drawmethod outside theGameObject.