Component System Example Code (from GPG6)

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Component System Example Code (from GPG6)

      I've read the Game Programming Gems 6 and found the component system extremly cool. but there were only listings without a working example. so to spread the idea a little bit here is a working (vc6) example source code. to get the full idea read the article in the book...

      the basic idea: in games it's easier to use "objects" which consist of "components" instead of inheritance. and every specific component-type (eg. render) can only exist one time in a object.

      do whatever you want with the source...

      cheers
      questor

      The post was edited 1 time, last by questor/fused ().

    • I find it intruiging, though the test that you linked breaks for me. Creating a new ObjectTemplate that's "HumanTemplate" causes the components to be cleared, where it breaks on line 33 of Object.hpp, trying to delete iter->second. I'm using Visual Studio .NET 2003, and I assume you're using VC6? I haven't seen DSW's in a while.
      Feel you safe and secure in the protection of your pants . . . but one day, one day there shall be a No Pants Day and that shall be the harbinger of your undoing . . .
    • RE: Component System Example Code (from GPG6)

      Ratrace/Barbie has what we call a property system, which is based on the same concept. Everything in the world that's useful is an Entity, which is essentially a blank template. You attach Properties to these Entities to do useful things. Some examples of Properties we have are ShadowCaster, SeClump (a "physical" representation in the world with position, model, textures, etc), Converser, Relator, AiUnit, etc.

      We can also attach sub-entities to Entities. In Barbie, everyone has a locker at school. Locker is a sub-entity that has it's own properties.

      Furthermore, most Properties and all Entities are implemented entirely in XML, with some Lua event code for certain properties (like Clickable). It's only when we need some major and generalized functionality (like ShadowCaster) that we create "hard properties" that are implemented in C++.

      Thus far, we've been very pleased with our Property system.

      -Rez
    • Is anyone still interested in this topic? I've done some reading into the matter and implemented a version of this system myself and I was going to critique a few issues of design, but no one is interested it'd save me the trouble of typing, heh. ;)
      Feel you safe and secure in the protection of your pants . . . but one day, one day there shall be a No Pants Day and that shall be the harbinger of your undoing . . .
    • I'm sorry after reopening this thread again, but I'm probably not giong to post at least for a few days. My best friend's father passed away yesterday, and I'm driving back to CA to see him. When I have some free time and access to the internet in the next week, I'll post what I was going to say.
      Feel you safe and secure in the protection of your pants . . . but one day, one day there shall be a No Pants Day and that shall be the harbinger of your undoing . . .
    • posting your comments would be cool. i've not designed it, but learning new tricks is always interesting!

      as a sidenode: in the original-article there were ideas to use xml (or whatever) to generate objects in the world via textfiles. but that was out of the scope of my simple testprogram.