Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 26 Nov 2010
Offline Last Active Jun 21 2013 08:54 PM

Topics I've Started

Ternary Operator and Polymorphism

23 April 2013 - 10:24 PM

Simplified question : Can I use the ternary operator in a new object declaration.
For example, if I have a two player game, and depending on whose turn it is:


classA { ... }

classB : classA {...}

classC : classA {...}


classA _Object = ((_turn % 2 == 0) ? new classB : new classC);


When I do this, I'm told that the operands are incompatible.  I could have sworn that I've seen this working before, but I can't seem to get it to work.  I tried restructuring and had the same results with this:



classA { ... }

classB : classA {...}

classC : classA {...}


classB cb;

classC cc;


classA _Object = ((_turn % 2 == 0) ? cb : cc);


Any insight would be appreciated.  Thanks!


C++ Entity/Component System Setup Assistance

09 April 2013 - 08:02 PM

First, I feel necessary to state that I have done extensive reading and searching for my answers before posting - in fact, I rarely post asking questions that I know I can find answers for.  However, I seem to be stuck with what should be an easy hurdle.
I'm trying to write a c++ entity/component system, and I'm wanting to make it as "true" as I can, meaning that I'd like as much as possible to be abstracted.  I know there are as many variations to the E/C system as there are programmers, but my goal is to make this as open-ended as possible.
Having not programmed in several years, I've recently (last 3 months) read several C++ books, and many of them touched on this topic (Game Coding Complete, Game Programming Gems 5 & 6, etc.), but while I have an understanding of the concepts, I can't seem to get code to work.  I've gone through several code sources available (Artemis-CPP, noah, entityx, Cistron, Skald, ...), and while I can get them to work from these already designed bases, when it comes down to modifying the code, I just seem to have a block.  I follow it a certain amount, then get lost.  I've also read through seemingly all the links similar posts have suggested, from t-machine.org, to Richard Lord's blog, to countless others.  This concept just seems to not stick for me.
At the risk of being flamed, would someone be able to point me to a step-by-step tutorial to write the basics of this system, or maybe post some stripped down code.  By stripped down, I mean no error checking, no superfluous code - just the Entity/Component/System/Manager structures.
I suppose the last thing I should post is my understanding of how this works, in case that's where my problem lies:
An Entity is represented by simply an unsigned int, possibly having a friendly string name variable for easy debugging.
A Component is represented by a series of POD variables, just holding information relating to that single attribute/purpose
A System fires event messages when things happen in the game/app, such as collision, etc.
A Manager acts as middle ground between levels, linking Components to Entities, reacting to events and modifying Component data appropriately, etc.
I would truly appreciate it if someone could assist me, or even provide me with skeleton code, which I can then build on.  It frustrates me that I've been unable to get past this, when it seems like a straight-forward implementation.

"Farmville"-like Game Design

26 November 2010 - 07:44 AM

I use Farmville as a structural example, simply because it's widely known, but the game that I'm working on isn't that similar. I've got the isometric map working, and the part that I'm having problems with is the part that I thought would be easy.

Basically, I'm making a game where a character can walk around a map and collect items that they find laying around. These items would then be added to the player's inventory. (To compare to FarmVille again, consider all the objects a player has in their inventory) Should be simple enough. However, since each item has particular statistics (ie. quality), I was trying to store these items in an array of objects (so each object can hold it's own qualities) as opposed to just an array of unique identifiers for, say, an item table in the database.

Just for syntax, I'm programming in Actionscript 3.0 (Flash CS5).

I may just have my scope messed up, but at this point I've looked at it so much, I'm not getting anywhere. How can I store items that the character picks up in an array, keeping all the additional values that each object contains?

If you can supply a coded example, that would be great, but if not I'm sure I can put it together.

Thanks in advance for any insight. I'm growing frustrated at the simple things stumping me. Hopefully I just need an outside brain to think about it. :)