Heelp

Members
  • Content count

    341
  • Joined

  • Last visited

Community Reputation

1688 Excellent

About Heelp

  • Rank
    Member
  1. Okay, got it. Thank you again.
  2. Kylotan, I looked at one GDC presentation and there was mentioned that writing if-statements like if( someComponent != null ) in a component is wrong because it makes code not generic. And if i hold a reference to other components, I always need to check if it's not null, in case it gets destroyed. ( enemy following player - this will crash when player is dead). How do i handle that?
  3. Thanks for the explanation, Kylotan. But what happens when I want some component to have multiple different configurations, depending on how many  of its required components currently exist in the game object? q2: So you say that Unity doesn't use messaging, and it's enough to handle all communication by just keeping pointers?
  4. Hello all, I'm currently making a 2D game using libgdx. I have only one GameObject class that is used to instantiate every object in the game, it is kind of like entity component system, but components have variables as well as functions in them, so it's not 100% ECS.   My PlayerStateBehaviour class works okay but it is getting too fat because I handle all state changes as well as animation logic in there. That's why I want to decouple some stuff just for clarity of code. But of course the components and connected so they have to communicate in some way. I've read a lot of articles online and there are two widely used ways for small games. One is to just hold a pointer to the other component I need - I can put it as an argument to the constructor. I tried that way but I think it sucks because I can't figure out a way to sort all the dependencies automatically and the other reason is that I need multiple constructors for every different combination that I want. (am I missing something here?)   The other way is messaging. The simplest pattern that is already in java is Observer and this is what I decided to use. 1. I made every single behaviour/component an Observer as well as an Observable. (Is this ok?) 2.My idea is that I want every component to be able to exist on its own, without being dependent on another component. (I know messaging is still a sort of coupling, but at least every object can exist on its own.) So what I want to do is just limit the PlayerStateComponent to transitioning between different states and sending messages about every state change, nothing else. And then the AnimationBehaviour will catch the message (STATE_CHANGE_ATTACK or something like that) and change the proper animation. (is it cool?) 3. Should I handle every single thing only by messages, or is it okay to sometimes hold pointers to other components, I really like the components to be directly referring to each other but the problem is that I can't automate the process because I don't know how to sort the dependencies.... 4. How exactly should I automate the process of finding observers. Should add every component as an observer to everyone else, or just add observer when it's actually needed? The first one is easy to code, the second one, I can't come up with a way of doing it, so I chose the first way.   Can you give me some ideas, or at least tell me if I'm on the right track?
  5. What do you mean,  with everyone? Even with bogo????     bogo so happy. truleeluleelul
  6. Sharing ideas

      I had the exact same problem as you with my MMORPG last year. The best place to start is here.
  7.   Frob, of course you are right. Draw calls are expensive. But I'm far behind this. My only concern for now is to make my code easy to read so I can upload less code to my brain before making a change. Everything else is not a priority. Maybe I will start to get performance issues after a few years, and I will have your advice in mind. And even then I would use a profiler first before touching anything because everybody says different things. :)
  8. ECS design

      This is just API stuff. If you don't know how to wrap it, the best tutorial I know is www.learnopengl.com. I don't say the code is perfectly optimized, but it's great for starters, you can optimize it on your own. And maybe you can get some ideas from there. I'm sorry that I can't help you in a more specific way, but I've never encountered your problem.
  9. ECS design

      Yes, but this is not entirely an entity-system approach, because when one component has a reference to another, they are tightly coupled, and it is a step backwards, because you are using ECS to decouple stuff in order to have more flexible code, why coupling it again?   The other reason is that the update order becomes less obvious and you need to be more careful.   And also if you want to multithread, having independent systems is better because you can use a separate thread for a system.   And you need to create a reference for every possible interaction between components, and most of the time you don't need all the interactions and the pointers stay empty, which is a waste of space, but it's not a big deal. The best way is a messaging system.   Although I don't like it, it's too much. What I end up doing is a little bit of everything.
  10.   Oh, I got it. So the bigger the difference between the lowest and highest point on my map is, the bigger the jump is.    You sold me interpolation, guys. I'll do it. :lol:  I'll do the simplest one.
  11. deftware, haven't seen you in a long time. Thanks for posting. :rolleyes:   Why do I need to interpolate? You mean that my movement can be smoother?   Can't I just use a ultra high resolution heightmap or something? My movement seems fine for now, although I noticed it could be smoother. Can you elaborate more on this, more on the "why" part, I mean? :huh:
  12. Okay, frob, I decided to spend 2 weeks on unity. Thanks for the suggestion, again.  :)   Sean, I'm SUPER stupid, I made a mistake when posting my code, really sorry. :(  I don't put the objects(Monster, Missile) in the vector, of course, I just put the objects' _renderable_ components in the vector of renderables. Subclassing like crazy is stupid, of course it is, I'm stupid but not that stupid.   //Original post deleted.   EDIT: Sean, I think I FINALLY got the idea. You mean that I should have only one class that represents the blueprint for _all_ entities, and a class for each component. And my GameObject should have two functions there, addComponent() and removeComponent() (for starters). And every time I want to add a new Monster, Player or Bunker, I just create a new GameObject object and add whatever components I need without making another class for player/monster/whatever, right?   EDIT 2: In order to add a component, I need to have a pointer to that component in the GameObject. So you say that if I have 58 possible components, I need to create 58 empty pointers in my GameObject class, just in case it needs it? :huh:   EDIT 3: The other way people do it is to _not_ create an object for the entity, just store an ID that is based on bitmasking component IDs, but I'm going into Entity/Systems there... I really like the empty pointers design, the only thing is that it wastes memory. But one pointer is 4-6 bytes, my ram is 8 gigs, it's not a big deal, right? :huh:   EDIT 4: And if stuffing all references into GameObject is what you meant, then what's the difference between that and the update pattern I posted earlier?
  13.   Sean, I did the Renderable component, but I don't know why I can't understand that sentence........   Okay, imagine I have classes Monster, Missile and Castle.  And they all have a Renderable component in them. Now I want to push them into a vector in order to draw them at once. //Create and fill vector. std::vector<std::unique_ptr<Renderable>> renderables; renderables.push_back( make_unique<Monster>( glm::vec3( 3.0f, 0.0f, 3.0f ), myResources.monsterAnims, myResources.objectShaders, myResources.getHeightMap() ) ); renderables.push_back( make_unique<Missile>( glm::vec3( 3.0f, 0.0f, 3.0f ), myResources.missileAnims, myResources.objectShaders ) ); //And so on.... Is this what you mean? And one more question, if you have the time.   Imagine I want to create a MegaFatMissile that is kind of really like a normal Missile but it's fat and does a lot of damage, but it recharges slower. And I feel kind of lazy and I want to inherit the MegaFatMissile from the normal Missile instead of copy pasting a few components. Is it ok to inherit just once? I wont make deep hierarchies or stuff, I mean just once or twice? :huh:   And if I don't want to inherit at all and want to create a new class that will be really like some previous class of mine, is it ok to add the same components again and just add 1-2 more additional components that are specific to the new class. It's not a problem to me, I'm just wondering if it's bad practice to copy/paste components like that? :huh:  
  14. This is a great moment for our planet. A legendary journal is born. :o But the problem is I'm the only one who thinks it's legendary.
  15. They just wanted me to attach a resume and I posted my CV.   But man, you are right, there are tens of different ways for something to go wrong, something happened, I just don't know what.   EDIT: and maybe my CV was bad, who knows, seems good to me. :lol:   EDIT2: yaustar, you have shipped very cool games. Good job, man. :o