   [c++]the game world and mvc
  Hy.I'm still reading this article:http://www.gamasutra.com/features/20050414/rouwe_01.shtmlon the mvc applyed to the game design.I'm not understand:1)Quote:The Controller can't directly change the state of the Entity. Every update the Controller is polled by the Entity and the Entity tries to follow the Controllers instructions.For example, the Controller would never call a MoveTo() function on a Humanoid but instead the Humanoid would poll the Controller's GetDesiredSpeed() function and then try to reach this speed while performing collision detection to make sure not to clip through walls.Isn't simple that the controller call methods on entity?why this design implementation?3)how the controller change the return of this methods ?It must have access to the world game for do that!?How the world is rappresented and how the controller have access to it and then change for each entity the result of these methods?4)how the entities are updated?and how a entity influence other entities?thanks.   
  I hope I can help:1) Think of a controller as a steering-wheel in your vehicle. You can surely pull it to the left, but it there's a wall then your car won't move to the left, although the controller wants it.I think the basic though is that what CAN be done should be kept inside the entities, instead of the controller.2) I'm not sure what your question is. The controller doesn't need to change anything. You can pull the steering-wheel to the left for a long time, even though there's a wall. The same applies to you pressing a key: You can even press it if your character can't go further to the left.3) A simple thing would be to call update() on each entity. The entities would then try to do what the controllers want, like calling GetDesiredSpeed().Influencing is very general and I think there is not only one solution to it, because there are a lot of ways entities can influence other entities. Like in a physical way, where one entity pushes the other one around, or one entity telling another entity that it should go away.   ;  very thanks SiS-Shadowman.Quote:Original post by SiS-ShadowmanI hope I can help:1) Think of a controller as a steering-wheel in your vehicle. You can surely pull it to the left, but it there's a wall then your car won't move to the left, although the controller wants it.I think the basic though is that what CAN be done should be kept inside the entities, instead of the controller.I'm understand ,then these function :getDesiredSpeed(),getSteeringWheel() ecc.. are polled by entities  for centralize every command to the entity(the model)and for do only that what can do!Quote:2) I'm not sure what your question is. The controller doesn't need to change anything. You can pull the steering-wheel to the left for a long time, even though there's a wall. The same applies to you pressing a key: You can even press it if your character can't go further to the left.ok.....Quote:3) A simple thing would be to call update() on each entity. The entities would then try to do what the controllers want, like calling GetDesiredSpeed().Influencing is very general and I think there is not only one solution to it, because there are a lot of ways entities can influence other entities. Like in a physical way, where one entity pushes the other one around, or one entity telling another entity that it should go away.I'm not understand,but How for example an entities know if there is a collision ?It must know the world , but there isn't a world rappresentation in the examples.And...Each entity is changed by all other entities?Is not more simple that each entities update a world and each entities is updated by the world?You what design implementation should advice to me?Thanks.ps. but there is a controller object for each entity?How preserve the state of an entities to another?   ;Quote:Original post by giugioQuote:3) A simple thing would be to call update() on each entity. The entities would then try to do what the controllers want, like calling GetDesiredSpeed().Influencing is very general and I think there is not only one solution to it, because there are a lot of ways entities can influence other entities. Like in a physical way, where one entity pushes the other one around, or one entity telling another entity that it should go away.I'm not understand,but How for example an entities know if there is a collision ?It must know the world , but there isn't a world rappresentation in the examples.I think in this case you will need to split things up even further:An entity is something like a character. He can move to certain positions, can shoot people, and stuff like that. That character is visually represented by some sort of model, so the entity could hold a reference (pointer) to that model as a class member. Additionally to represent the character in a physics simulation (google that keyword, you should be able to find good tutorials) it will hold a reference (again a pointer for example) to its physical representation:class Entity{    Model   *m_pVisualModel;    PhysicsModel *m_pPhysicalModel;};This is a very basic example, but it should convey what I meant. The entity simple holds references to its various representations. You can put it like this:An entity represents a certain "thing" in the game logic. A Model visually represents one entity and a PhysicalModel represents a certain entity in a physical simulation.Quote:Each entity is changed by all other entities?That's not exactly what I meant. An entity can be changed by other entities, but that really depends on the relationship of those entities. A car that has a character sitting in a chair certainly controls that character to a certain degree.Quote:Is not more simple that each entities update a world and each entities is updated by the world?What do you mean by that? I can't follow.Quote:ps. but there is a controller object for each entity?How preserve the state of an entities to another?Well, I think so. There should be a controller for each entity. But maybe an entity can also exist without a controller (for example when an entity is literally dead, it will still persist in the world visually and physically, but it wouldn't do that much, unless it's a zombie :)).What do you mean about the state of one entity to another (entity?) ? Do you mean it's logical relationship or something else?   ;  Thanks a lot you are very kind.then :1)the entities have this pointer: Model   *m_pVisualModel;and can entity find collision with this(the model)?2)How i can create relations between entities?For example in a rts game two entities that fighting are relationed , but two entities that are in the opposite site of the screen not are relationed !.Quote:What do you mean about the state of one entity to another (entity?) ? Do you mean it's logical relationship or something else?I think that each entity have a state that is the current responce to the input of what the controller would do.I think my IA controller as a automata state machine (http://en.wikipedia.org/wiki/Automata-Based_Programming ) that get in input all the entities  that are related to entity and create a custom responce that is polled(as function return value) by the entities.The problem is that the controller can't have a state ,because is the entity that know how it was do in the previews update , then the state must be in the model and is that that the entity currently be.But how i can create this programmable automata?Thanks.   ;  upup   ;Quote:class Entity{    Model   *m_pVisualModel;    PhysicsModel *m_pPhysicalModel;};1)so for example the collision detection is in the class entity , but how and where are rappresented the other meshes and static entities for test the collision?are in the *m_pPhysicalModel or *m_pVisualModel?also isn't correct to iterate all the other entities(static and no) for test the bounding volumes?2)Is correct to create relations from meshes?for example two fighting character are relationed ,what is a good method for create in the code a relation between two or more character?and how traverse all the relations for do operations(visual and non) on characters?THanks;  Everything that can be seen and should interact with the world is an entity. If it's physical body remains static or not is not a question here.The bounding volumes can be created from either of the two, however since the physical model usually tends to be less complex than the graphical model, you want to use the physical model.I can't really figure your second questions, but you should really look up "Physical Simulation" on google and read that stuff.You should also start with a real small game and then work your way up. The questions you ask should be answered quickly once you reach that point in development.   ;Quote:Original post by giugioI'm still reading this article:http://www.gamasutra.com/features/20050414/rouwe_01.shtmlon the mvc applyed to the game design.I'm not understand:1)Quote:The Controller can't directly change the state of the Entity. Every update the Controller is polled by the Entity and the Entity tries to follow the Controllers instructions.For example, the Controller would never call a MoveTo() function on a Humanoid but instead the Humanoid would poll the Controller's GetDesiredSpeed() function and then try to reach this speed while performing collision detection to make sure not to clip through walls.Isn't simple that the controller call methods on entity?why this design implementation?Personally I think MVC is completely pointless if you're going to invert the control flow and have the Model querying the Controller. The example given is a false one, as there's no reason the controller can't call a SetDesiredSpeed function on the Model. I've no idea why the writer suggests his method but I think it's a bad suggestion.   ;  thanks   