Register Calendar Members List Administrators and Moderators Search Frequently Asked Questions Home

Game Coding Complete Programming Forum Toolbox Component System Example Code (from GPG6) Hello Guest [login|register]
Last Post | First Unread Post Print Page | Recommend to Friend | Add Thread to Favorites
Post New ThreadPost Reply
Author
Post Previous Thread | Next Thread
questor/fused questor/fused is a Male
Cool Newbie




Registration Date: 09-04-2005
Posts: 42
Location: Karlsruhe, Germany

Text Component System Example Code (from GPG6) Reply to this Post Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information Go to the top of this page

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

This post has been edited 1 time(s), it was last edited by questor/fused on 07-09-2006 at 13:36.

07-08-2006 09:31 questor/fused is offline Homepage of questor/fused Search for Posts by questor/fused Add questor/fused to your Buddy List
Tarviathun Tarviathun is a Male


Registration Date: 11-25-2005
Posts: 190
Location: Redmond, WA

Reply to this Post Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information Go to the top of this page

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 . . .

07-08-2006 15:01 Tarviathun is offline Send an Email to Tarviathun Search for Posts by Tarviathun Add Tarviathun to your Buddy List AIM Screenname: The Tarviathun
questor/fused questor/fused is a Male
Cool Newbie




Registration Date: 09-04-2005
Posts: 42
Location: Karlsruhe, Germany

Reply to this Post Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information Go to the top of this page

dammit, I've found the error, the map should be cleared in "clearComponents", too.... and there were some other errors, too. here is the updated version:

Attachment:
ComponentTest.zip (11 KB, 2822 downloads)
07-09-2006 13:35 questor/fused is offline Homepage of questor/fused Search for Posts by questor/fused Add questor/fused to your Buddy List
rezination rezination is a Male
Administrator




Registration Date: 05-03-2005
Posts: 1491
Location: San Francisco Bay Area

RE: Component System Example Code (from GPG6) Reply to this Post Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information Go to the top of this page

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

07-11-2006 13:24 rezination is offline Homepage of rezination Search for Posts by rezination Add rezination to your Buddy List
Tarviathun Tarviathun is a Male


Registration Date: 11-25-2005
Posts: 190
Location: Redmond, WA

Reply to this Post Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information Go to the top of this page

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. Wink

__________________
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 . . .

07-27-2006 18:55 Tarviathun is offline Send an Email to Tarviathun Search for Posts by Tarviathun Add Tarviathun to your Buddy List AIM Screenname: The Tarviathun
rezination rezination is a Male
Administrator




Registration Date: 05-03-2005
Posts: 1491
Location: San Francisco Bay Area

Reply to this Post Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information Go to the top of this page

Go for it.

-Rez

07-28-2006 13:09 rezination is offline Homepage of rezination Search for Posts by rezination Add rezination to your Buddy List
Tarviathun Tarviathun is a Male


Registration Date: 11-25-2005
Posts: 190
Location: Redmond, WA

Reply to this Post Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information Go to the top of this page

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 . . .

07-28-2006 15:28 Tarviathun is offline Send an Email to Tarviathun Search for Posts by Tarviathun Add Tarviathun to your Buddy List AIM Screenname: The Tarviathun
questor/fused questor/fused is a Male
Cool Newbie




Registration Date: 09-04-2005
Posts: 42
Location: Karlsruhe, Germany

Reply to this Post Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information Go to the top of this page

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.

08-02-2006 02:26 questor/fused is offline Homepage of questor/fused Search for Posts by questor/fused Add questor/fused to your Buddy List
Tree Structure | Board Structure
Post New Thread Post Reply
Go to:

Powered by Berning Bored 3.1.4 2007
Content Copyright 2002-2009 (C) by Mike McShaffry