![]() |
|
Is component-based design sutiable for action game like lf2? |
davidcorns
Member #11,644
January 2010
|
Hi, every one. I am a newbie of game programming. I have read many articles about game development, and many of the authors suggest using component-based programming to development a (big?) game, compare to Object Oriented Programming. May I ask is it still true for a mini-size action game, which is similar to little fighter 2(lf2.net)? I guess OOP may have better performance(in terms of speed). Thanks! |
GullRaDriel
Member #3,861
September 2003
![]() |
davidcorns said: I guess OOP may have better performance That point really need to be proved. "Code is like shit - it only smells if it is not yours" |
Audric
Member #907
January 2001
|
I would hardly call LF2 a mini-game. |
davidcorns
Member #11,644
January 2010
|
Thanks a lot for you help. |
axilmar
Member #1,204
April 2001
|
davidcorns said: I have read many articles about game development, and many of the authors suggest using component-based programming to development a (big?) game, compare to Object Oriented Programming. Before going the component-based design route, you should get familiar with modularization. I suggest you first design your code in paper: separate functions in modules, based in related functionality. It's a good exercise to get you familiar with modularization. |
Tobias Dammers
Member #2,604
August 2002
![]() |
davidcorns said: I have read many articles about game development, and many of the authors suggest using component-based programming to development a (big?) game, compare to Object Oriented Programming. Component-based and Object-oriented aren't mutually exclusive. Many component-based designs implement their component model within a strong OOP framework. Don't confuse OOP with polymorphism - although polymorphic objects are one of the big things in OOP, they are not the only one, not even the most important one if you ask me. Quote: I guess OOP may have better performance(in terms of speed).
OOP has little or nothing to do with runtime performance. GullRaDriel said: That point really need to be proved.
No. It is obvious that a blank statement like this is neither true nor false. OOP does not produce faster or slower code than any other programming paradigm. Runtime performance is meaningless on this level, though, what you need is maintainability to keep you from abandoning the project long before finishing simply because you don't understand what you did months ago, or because changing something that absolutely needs to be changed would be so tedious that you never do it, or because you hit some other kind of roadblock that a convoluted design prevents you from clearing in a simple, efficient way. --- |
davidcorns
Member #11,644
January 2010
|
Thanks a lot for your help. I do think OOP has better performance because I need to use C++ to write the game, which is a OOP language, and I have to implement the component as object, and it seems that more pointer access is needed for component-based system. Of coz, I am not sure if I am correct. Thanks a lot. |
SiegeLord
Member #7,827
October 2006
![]() |
davidcorns said: I do think OOP has better performance because I need to use C++ to write the game, which is a OOP language, and I have to implement the component as object, and it seems that more pointer access is needed for component-based system. Of coz, I am not sure if I am correct. I don't think you are... not that what you said made any sense... ^_^ Tobias Dammers said: OOP has little or nothing to do with runtime performance. Not entirely true. OOP programs have poor cache performance. E.g. see this and this. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
davidcorns
Member #11,644
January 2010
|
Again, thanks to all of you. To implement the component-based design, I use the following idea: Core Engine : ....... //code to parse the script //main game loop foreach entity { entity.update() } entity: class entity { private: vector<component*> m_com; public: void addComponent(component*); void update() { foreach com in m_com { com.execute(); } } }; and the execute function in the component do all the things, by different component. Can anyone give me some adive?? Thanks a lot. |
axilmar
Member #1,204
April 2001
|
SiegeLord said: Not entirely true. OOP programs have poor cache performance. E.g. see this [gamesfromwithin.com] and this [research.scee.net]. After reading the presentations I think its more about organizing your objects in such a way that cache misses are minimized than OOP itself. |
blargmob
Member #8,356
February 2007
![]() |
I wouldn't use a "foreach" loop because then entities and components can't remove themselves from the list. A standard "for" loop solves this problem. Also, if you haven't done so yet, you should probably think about how components and entites talk to eachother. --- |
|