OOP question

Get answers to all your basic programming questions. No Ogre questions, please!
Post Reply
cengkarim
Halfling
Posts: 47
Joined: Mon May 21, 2007 4:22 pm
Location: Alexandria, Egypt
x 5

OOP question

Post by cengkarim »

Hi all,

I'm designing the classes of an application and I have a question. I made an "ApplicationController" that would control and coordinate interactions between input, camera, main objects ... etc. I made an interface "IDrawable", which apparently represents any class that needs to be drawn every frame which method "draw(void)". "ApplicationCotroller" will have an array of "IDrawable" and will "draw(void)" each one per frame. Now, my question, I have special classes (lets say, main character) which needs other special operations, like move, jump, fire, die, explode and more importantly draw. Shall that main character implements "IDrawable"? And if it implements it, how "ApplicationController" holds it? Would it hold 2 references for it, one in the array of "IDrawable" and one reference for "MainCharacter" for other special operations? I'm a bit rusty about OOP and I appreciate your help, thanks :)
Thanks
User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
x 94
Contact:

Re: OOP question

Post by tod »

For my game I kept the main character completely separated. Not sure if it's ok or not, but the main character code in my case is pretty different from other entities. I'm making a first person game thought. I think you should try to think ahead a little and decide if integrating your character with the other entities is worth the effort. If there are many cases that are specific to the main character the integration may be a burden.

About your IDrawable interface, I see it working when you have ogre entities, but once you get into batching it may be unnecessary, because the entities will be rendered by someone else, so no need for 1 million calls to draw functions that will do nothing. :)
cengkarim
Halfling
Posts: 47
Joined: Mon May 21, 2007 4:22 pm
Location: Alexandria, Egypt
x 5

Re: OOP question

Post by cengkarim »

Yup, I guess it makes sense to separate. I forgot that ogre will draw the entity automatically :) , I think the interface would be better to be "IUpdateable". Each frame I'll call "update()" for each IUpdataeable in the list and I'll keep my main character separated with its special update. Thanks :)
Thanks
Post Reply