Basic game design question
Let''s say in a game, there''s an Environment, and there are Entities that populate this environment. The Entities Move around the environment: how do I design these two objects to allow this movement. Let''s say I give the Entity a Move function. Does each Entity keep track of its own position in the environment, does the environment keep track of each entitiy''s position, or should they both keep track of the position? If the environment keeps track of the entity''s position, how does the entity let the environment know that it wants to move?
Does anyone have any suggestions for me? Are there any articles or tutorials that cover these problems? I''m having some difficulty wrapping my mind around these issues and coming up with the best solution, so I''d appreciate any help you could give me.
They should both track the position.
The objects should store its x,y,z position and then update it''s position to the enviroment so the enviroment can handle things like collision detection.
The objects should store its x,y,z position and then update it''s position to the enviroment so the enviroment can handle things like collision detection.
Have your base class CEntity hold the position as a public member. That way, each position is still tied to it''s entity, but the environment can still access it.
I''d have CEntity::Move(), yes. I''d also have bool CEntity::TestCollide(CEntity &otherEntity), because that allows better for entities having different collision methods (for example, you could collide a sphere and a cube that way, without the environment needing to know that you''ve got a sphere and a cube).
I''d have CEntity::Move(), yes. I''d also have bool CEntity::TestCollide(CEntity &otherEntity), because that allows better for entities having different collision methods (for example, you could collide a sphere and a cube that way, without the environment needing to know that you''ve got a sphere and a cube).
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement