• Content count

  • Joined

  • Last visited

Community Reputation

106 Neutral

About mazelle

  • Rank
  1. Quote:Original post by snake5 mazelle: Sure, I'm not asking you to argue. Looks like this is a "bitangent vs binormal" thing anyway. :D Btw, that article you gave says that an entity is one object in the game world. Actually, with real time applications, this is not always the case - for example, no one would want to store each particle as a different entity.. that would really slow everything down... of course, everyone knows that when we talk about particles but there are really more things like that which cannot be divided like that... I absolutely agree. The article I gave is just for sharing, though. It's another way of implementing the system. Actually, I was quite surprised when I read it. I haven't thought of it that way. The way they did it is just much more appropriate for MMOGs (because of the needed database backend).
  2. Quote:Original post by snake5 Quote:If a certain programmer needs to, the design of his system must be poor. Not always. Many hacks are created because programmers just think differently and one needs to make his code work with the other one's code. P.S. Why does everyone keep calling it "entity system", it's not even close to a good definition.. :D I did say (whatever you call it). I wouldn't waste time arguing what it should be called. I would use the term that which more people would attach the idea to when they see or hear the name. I guess for me, many people refer to it as entity system or entity-component system. I also find this very informative: It makes you think of the system as a relational database (data only) instead of classes (data and methods).
  3. I'll just relate to you my experiences when I introduced 'entity systems' (whatever you call it) to our new game. I was a new employee, but I already have experience working with entity systems on my personal game projects. I was tasked to do the physics management of the game and since there was no game object management system yet, it was up to me on how to make those game objects. Looking at the code of the company's previous games, I could say that they are heavy users of static hierarchy. And based on what I saw in their code, there were lots of hacks just to get a certain type to do what it's supposed to do. I'd like to avoid that so I implemented an entity system as the game object management system. At first, they were very confused. They could not comprehend how I was making unique entities. They couldn't see a MinionEntity class or a HazardEntity class which they expected. All they see are a bunch of // prepare a minion entity Entity* entity = entityManager.request(); Transform* transform = entity.addComponent<Transform>(); ... // prepare transform RigidBody* rigidBody = entity.addComponent<RigidBody>(); ... // prepare rigid body MeshRenderer* renderer = entity.addComponent<MeshRenderer>(); ... // prepare the renderer There were many questions, many objections. I got a fight with my lead. I did a lot of explaining. I gave them links to read about. Then out of the blue, someone was able to finish his task using the entity system and defended me. From then on, everyone was using the system. Eventually, they got the hang of it and they found that it's simple and flexible, too. It was smooth sailing from then on. From these experiences, I could say that using entity systems is a lot better than the traditional static hierarchy. Making changes, adding features, removing features are easier (we had a lot of changes). We could delegate tasks to someone else with less worry. For example, a certain programmer would be assigned to code a particular system. All we have to do is request a component from his system, add to our entities, make some preparations for it using its interface, and should be working fine. If that component does not work, or breaks, we knew who to ask or whom to assign for fixing. We also avoided the hack tricks (why do game programmers love them). Most of the time, there's no need to hack. If a certain programmer needs to, the design of his system must be poor.
  4. public vs private c++ questions

    That is what you call encapsulation. When you make use of member functions, you will have less trouble updating the internal implementation of your class. For example, in your current Wizard class, the mArmor member may be moved or changed (say you change the internal representation or concept of 'armor' such that it can no longer be represented by mArmor alone) but the purpose of SetArmor() will still be the same, to set an armor value.
  5. beginner project

    You should probably look into animation first then. Learn more about the game loop, timing and interpolation.
  6. Most software development companies give you a problem in which you provide a solution using code or pseudo code. What kinds of problems should I expect?
  7. But then some devs (like me) might already be using that construct and they don't know that it's harmful because the compiler didn't say so.
  8. BTW, I just had my proficiency this afternoon. They just let me code a simple game with OOP concepts and such. I think I did very well, though. I hope they call me for the tech interview. This thread has shed light to me to the inner workings of C++. I never cared before. I just use what works. This seems to be a thread ender post already, but I don't want this thread to end. I hope you could still add some mind blowing stuff that most programmers don't know. I wanted to ask this: void doSomething( SomeClass& instance ) { ... } SomeClass returnsByValue() { ... } doSomething( returnsByValue() ); This should be illegal based from C++ Primer because the parameter in doSomething() can't hold unnamed variables. But it works fine in VC9. Is this one of those undefined stuff?
  9. Quote:Original post by Washu Quote:Original post by Kwizatz Quote:Original post by Washu Uh, what on earth are you going on about? The the valid range of pointers within p is [p, p+10]. Note the brackets are "INCLUSIVE" not exclusive. Exclusive would use (). Fair enough, so do you consider k to be in range? does k point to a valid address? *** Source Snippet Removed *** Provided k is within the range of valid values for a pointer derived from p, that is [p, p+10], k is valid. You do not have to be able to DEREFERENCE a pointer for it to be valid. The pointer ONE PAST THE END is valid. Just not dereferenceable. The problem is that you've made the assumption that for a pointer to be valid it must also be dereferenceable, which it does not. I am enlightened. Thank you. Quote: Yeah, the C++ idiom of iterators is based on having a begin and an end marker. For the iterator type for an array, the "end iterator" is the "one past the end of the array pointer". Noted. C++ is hard.
  10. I see. I wish it were possible to access var args like in Java (var args are passed internally as an array). float average( float... values ) { float sum = 0; // say values is std::vector<float> int size = values.size(); for( int i = 0; i < size; ++i ) { sum += values[ i ]; } return sum / size; } Is there something like these being introduced for future C++ standards?
  11. Quote: There's no reason templates have to come into your entity class. All I'm talking about is literally a component type ID. // getComponent() definition, overloaded once per concrete component type template <typename ComponentType> ComponentType* getComponent() { // Use the class's static id value which you've defined as something unique IComponent* c = this->componentMap.get(ComponentType::id); return static_cast<ComponentType*>(c); } Why haven't I thought of that? That's a great idea. All that is left then is to generate a unique ID for every component type. That should be fairly easy to come up with.
  12. My take on this: don't use multiple inheritance to more than one concrete classes. You should only derive from at most ONE concrete class. Others should be pure virtual classes. And my other take: prefer composition over inheritance. For problems like these, inheritance shouldn't be your first solution. Consider if you could compose them. class Sprite { public: // to be maintained in your list (or whatever) of GameObject instances GameObject* getGameObject() { return &this->game; } // to be maintained in your list (or whatever) of PipelineObject instances PipelineObject* getPipelineObject() { return &this->graphics; } private: GameObject game; PipelineObject graphics; }; If you want a customized GameObject for your Sprite, you could have: class SpriteGameObject : public GameObject // inherit from one concrete class only { void update( float timeElapsed ) { // customized update() routines for sprite here } }; // then you can have class Sprite { public: // to be maintained in your list (or whatever) of GameObject instances GameObject* getGameObject() { return &this->game; } // to be maintained in your list (or whatever) of PipelineObject instances PipelineObject* getPipelineObject() { return &this->graphics; } private: SpriteGameObject game; PipelineObject graphics; }; // you could also do the same for your PipelineObject.
  13. void varargReview( int count, ... ) { va_list args; va_start( args, count ); for( int i = 0; i < count; ++i ) { std::cout << va_arg( args, int ) << std::endl; } va_end( args ); } Is there a better way of identifying the number of variable arguments or the last argument other than relying on count? I was thinking if I could do something like this: template <typename BeforeVarArgType, typename VarArgType> class VarArgs { public: VarArgs() { va_start( this->args, BeforeVarArgType ); } virtual ~VarArgs() { va_end( this->args ); } bool hasMore() { // code to identify if there are more variables here } VarArgType getNext() { return va_arg( args, VarArgType ); } private: va_list args; }; so I could do this: void varargReview( int count, ... ) { VarArgs<int, int> args; while( args.hasMore() ) { std::cout << args.getNext() << std::endl; } }
  14. I don't quite get it yet: Quote: Here is the complete list of all sequence points in C++: * at the end of a full expression * after the evaluation of all function arguments in a function call and before execution of any expressions in the function body * after copying of a returned value and before execution of any expressions outside the function * after evaluation of the first expression in a&&b, a||b, a?b:c, or a,b * after the initialization of each base and member in the constructor initialization list Quote: Function calls. The sequence points before and after a function call mean that execution of the invoked function and the calling context is not intermingled: all statements before the function call are executed, the function arguments are evaluated (in undefined order), and then the function body is executed. Similarly on return from the function: all statements of the function body are executed; the return expression is evaluated, and then control flow continues in the calling context with the statement after the function call. Is this a defined behaviour then? int i = 0; int p = i++ + f() + ++i; // sequence points before and after a function call Although, I've got a gut feeling that it is not.
  15. Quote:Original post by Fenrisulvur Quote:Original post by mazelle What do you mean undefined? It prints 0 2 And I got: 1 2 I fed it to Digital Mars C++, though not an up-to-date version. You? VC9 (VC 2008). No warnings either. Weird.