4 ms·
This is written using an OOP language - C++ I was always fascinated at games like this one as to how perfectly they are a use case to OOP paradigm. All objects
by gprasanth 13y ago
This is written using an OOP language - C++
I was always fascinated at games like this one as to how perfectly they are a use case to OOP paradigm. All objects are sharing a common object, and the player can create, destroy objects, do stuff on the objects ( call their methods ). Objects can upgrade to different versions. Objects exchange information with themselves or even battle among themselves! Really cool perspective, isn't it?
- maaku 13y agoYes, but to really exploit that perspective you need the features of dynamic languages which C++ is lacking. Which is why it's not uncommon that the actual game objects are represented in a dynamic scripting language, Javascript in this case.
- wereHamster 13y agoMany games use Entity-Component-System pattern, which doesn't necessarily require an OOP language. https://en.wikipedia.org/wiki/Entity_component_system https://en.wikipedia.org/wiki/Entity_component_system
- copx 13y agoThat is a new trend though, primarily pushed by the fact that the popular Unity game engine uses this model I think. OOP is a perfectly serviceable model for developing games like this, especially if you use modern OOP i.e. heavy on composition and interfaces as opposed to the byzantine inheritance hierarchies of the 1990s. The pro-ECS propaganda always contrasts ECS with said 1990s Java style OO, correctly pointing out that inheritance (alone) does not allow clean modelling of certain game world entities.
- tinco 13y agoNo, it's primarily pushed by the complexity of modern games. The game industry is notoriously introvert about their development practices, but the popularity of ECS surely precedes the popularity of Unity. (i.e. games like Tony Hawk Pro Skater and World of Warcraft use ECS architecture). Its use is obfuscated further because the architecture is called many different names, and is implemented in many different ways (i.e. I think many programmers find the 'systems' part weird and mix parts into components and other parts into 'engines' and such) That being said, I think it's hard/unproductive/awkward to implement ECS in a non-OOP language. ECS is basically composition taken to the max, OOP languages give it much needed structure.
- ijk 13y agoEntity based design goes back to at _least_ late-90's Looking Glass; for example, Thief: The Dark Project (1998) used "a set of appropriately abstract reusable game components designed for creating object-rich, data-driven games" and "In _Thief_ there was no code-based game object hierarchy of any kind."[1] It's used in Unity because it's a flexible approach to developing games. [1] http://www.gamasutra.com/view/feature/3355/postmortem_thief_the_dark_project.php?print=1 http://www.gamasutra.com/view/feature/3355/postmortem_thief_...
- frik 13y agoOne of the Thief game devs wrote the book Game Coding Complete, 4th Ed. it mentions Thief game several times and it has some code and explanation about component-entity system. Also 3 articles about this topic: http://www.reddit.com/r/gamedev/comments/1f83c5/3_articles_about_component_entity_systems/ http://www.reddit.com/r/gamedev/comments/1f83c5/3_articles_a...
- frik 13y agoBtw. 0 A.D. uses the Entity-Component-System pattern too. Search for "optimized the entity-component system, a core part of the engine" on this page: http://play0ad.com/0-a-d-development-report-13/#more-3342 http://play0ad.com/0-a-d-development-report-13/#more-3342
- wereHamster 13y agoThe page doesn't provide any info about how 0ad uses ECS.
- frik 13y agoIn 0 A.D., entities (units and buildings and other world objects) consist of a collection of components, each of which determines part of the entity's behaviour. Entity template XML files specify the list of components that are loaded for each entity type, plus initialization data for the components. -- http://svn.wildfiregames.com/public/ps/trunk/source/tools/entdocs/convertrng.xsl http://svn.wildfiregames.com/public/ps/trunk/source/tools/en... Have a look at the source code: http://svn.wildfiregames.com/public/ps/trunk/source/simulation2/system/ComponentManager.cpp http://svn.wildfiregames.com/public/ps/trunk/source/simulati... and other code there: http://svn.wildfiregames.com/public/ps/trunk/source/simulation2/system/ http://svn.wildfiregames.com/public/ps/trunk/source/simulati... and there: http://svn.wildfiregames.com/public/ps/trunk/source/simulation2/components/ http://svn.wildfiregames.com/public/ps/trunk/source/simulati... (I used Google to find the related code)