Game Development Community

Help with ScriptObjects / inheritence

by Matt Grosse · in Torque Game Builder · 07/12/2005 (11:38 am) · 3 replies

I thought i knew how i wanted to implement this, but i figured i would ask the community who has some more experience than me.

i'm working on a game similar to football, and i would like to define various attributes for each of the players on the field. the attributes will be common to all players on the field, just their values will vary by type of player (blocker, catcher, passer, etc). so my question is, whats the best way to add these added vars to my objects? the players will be represented in the game by animated sprites. so my immediate thought was to subclass the animated sprites and add my additional data to it. but i also saw that it would be possible to define most of my methods for my players in the script, and just attach them to whatever object they end up being.

hopefully i'm being clear in what i'm asking. basically, my players will be animated sprites running around - but i need to add additional data/methods to that object. is this something best done in the source, the script, or both? and by best, i mean the most proper / least hackish.

thanks in advance!

edit: changed the topic name to make it more relevant

#1
07/12/2005 (1:13 pm)
After some more searching i found the following threads:

www.garagegames.com/mg/forums/result.thread.php?qt=31719
www.garagegames.com/mg/forums/result.thread.php?qt=27384

which have shed some light on this for me. i'll need to go back a read them again when i get home for complete understanding (at work now.. don't tell!). but please, if anyone has anything to add/comment on this topic please let me hear it.
#2
07/12/2005 (1:36 pm)
Good resource Matt, thanks for posting it :)
#3
07/12/2005 (9:13 pm)
Ok after reading numerous threads, here is my understanding of inheritance with torque script currently. ScriptObjects can be in up to 3 namespaces at once.. this confused me at first, thinking that meant i could combine a ScriptObject with say a fxAnimatedSprite2D object. from what i can tell, this is not the case. you can only inherit among ScriptObjects. so you can create a ScriptObject, then create another and inherit from the first, etc.

so now, if i want to associate a sprite with my custom ScriptObject i add member vars in each, that point to eachother. then using appropriate methods i can access each as needed.

the following resource adds full object orientation to the torque script however. i have not added it to my source yet, but i believe it would allow me to do what i originally intended. (please correct me if i'm wrong)

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=8216