Game Development Community

Data objects (not datablocks) and TorqueScript

by Jason Maskell · in Torque Game Engine · 07/12/2006 (3:04 pm) · 2 replies

I've been messing about with TGB to see whether it's suitable for a board/card game I am working on.

The prototype has been going pretty well, but I've run into a wall.

I need to have reusable objects that are the cards. Basically a card will be one of several classes that has attributes, and I need to have a list of them that's both the hand, and the deck.

In C++ this'd be a doddle - two STL lists and some classes. Done. In TorqueScript this doesn't appear to be easy, or even possible.

Can I make an object that's not a SimObject and still have the nifty auto dynamic fields? When I tried to instatiate an object like so:

$blah=new playerHandObject()
{
foo="Bar";
};

I got a "can't instantiate non con_object" message, which gives me some pause.

Anyone give me a hand here, or is it back to C++? :)

#1
07/18/2006 (8:18 am)
Would this help?

I use it for similar things in my game.
#2
07/18/2006 (9:01 am)
I ran into similar issues with a card game I've been working on, and finally decided to do the 'wrong' thing (from my C++ point of view) and just put all the card logic into a t2dStaticSprite 'class'. I'd initially thought it would be best to create an abstract representation of the card, then have these representations create the sprites.

So far, it works fine, and made it really easy to display a visible deal from a deck of card sprites, and have the cards 'gathered' into the middle after a hand for another deal. I also reuse the sprites from hand to hand.