• Content count

  • Joined

  • Last visited

Community Reputation

119 Neutral

About taurusrow

  • Rank
  1. Ternary Operator and Polymorphism

    Thanks for your replies.   @Phil - it wasn't my actual code, I simplified, but it was the basic idea that I couldn't get to work.  The second attempt was based on something I read in another forum and didn't think would work as it was (turns out I was right).   @Alvaro - thanks for the sample code.  At first I wasn't getting it to work, then realized that I wasn't static casting to a pointer of the base class.   Sometimes one needs to really stop looking at code, then come back with a fresh mind.  Appreciate the help!  Thanks.
  2. 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!  
  3. C++ Entity/Component System Setup Assistance

    @Kristoffer:  Thanks for the reply and further explanation.  I will look for your streaming to see if I can pick anything up @Juliean:  I appreciate your input as well   I'm going to keep trying to work at it, or find some sort of step by step tutorial to get the first parts set up and functional.  The Interfaces to create the components and systems, using the correct smart pointers for references, etc.  I really like the idea of the design, and Kristoffer, I agree - it seems like it is really fun to work with.  Especially once you get into it and can create editors and such which just tag on components to entities.
  4. 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.
  5. "Farmville"-like Game Design

    klefebz, Thank you for your reply. The objects do it fact have behaviour methods that I didn't go into, however I may be able to work with that concept you suggested and expand it. For example, one method that an object could have would be a Deconstruct method, which essentially pulls the items apart. If, let's say, you had a bicycle object, you could choose to 'Deconstruct' it and create several other items instead (a seat object, 2 pedal objects, etc.). My idea was going to be to open up an inventory screen, then when you click on the individual items, depending on what methods were present for that object, a dynamic list of options would be created. Thanks for your input, though. I'm going to work with that idea and see where it gets me. Grats!
  6. 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. :)