mdavis1982
2005.01.07, 03:28 PM
Hi all...
I'm doing a game at the moment, and was wondering if any of you experienced people could help a newb out! ;-)
I'm trying to write my game to be as OO as possible. And I'm just using a custom NSView to display all of my game's graphics.
Now... I have a couple of objects that need to draw themselves in the view.
What would be the correct method of doing this, from an OOP perspective?
I've got my classes as models, my controller handles the game logic, and my custom view handles the drawing. Should I:
a) In the custom view - (void)drawRect:(NSRect)rect method do [myController drawObjectAt:position]
b) Have the view do all the drawing by getting the information it needs from the controller's accessor methods for the game objects
c) Get each object to draw itself in it's own view, and then add all the object's views as sub-views of the custom view?
I'm really at a loss here... Suppose I have 2 player objects...
Should I ask the controller to draw the players in the drawRect method by doing something like: [myController drawPlayers]? Should I just get the information about each player in the drawRect method of the custom view and have all the drawing code in there? Or should I draw the player to its own view whenever I update any information about the player, and then add the player's own views as sub-views to my Custom View?
It's totally too complicated, and I can't find any good resources out there about doing this kind of thing in an OOP fashion!
Please help me before I give myself a brain tumour!
Thanks,
Matt
I'm doing a game at the moment, and was wondering if any of you experienced people could help a newb out! ;-)
I'm trying to write my game to be as OO as possible. And I'm just using a custom NSView to display all of my game's graphics.
Now... I have a couple of objects that need to draw themselves in the view.
What would be the correct method of doing this, from an OOP perspective?
I've got my classes as models, my controller handles the game logic, and my custom view handles the drawing. Should I:
a) In the custom view - (void)drawRect:(NSRect)rect method do [myController drawObjectAt:position]
b) Have the view do all the drawing by getting the information it needs from the controller's accessor methods for the game objects
c) Get each object to draw itself in it's own view, and then add all the object's views as sub-views of the custom view?
I'm really at a loss here... Suppose I have 2 player objects...
Should I ask the controller to draw the players in the drawRect method by doing something like: [myController drawPlayers]? Should I just get the information about each player in the drawRect method of the custom view and have all the drawing code in there? Or should I draw the player to its own view whenever I update any information about the player, and then add the player's own views as sub-views to my Custom View?
It's totally too complicated, and I can't find any good resources out there about doing this kind of thing in an OOP fashion!
Please help me before I give myself a brain tumour!
Thanks,
Matt