Sign in to follow this  
deathtrap

Moving multiple objects

Recommended Posts

Hi, I have an Entity class, and every object in my game is instantiated as an object of that class. Now in my Move method, do i store a matrix for each object, reset the matrix after each render call, and then set the next objects matrix? this is a 2d, top down asteroids game i'm doing to learn, and all my previous games used window coordinates which meant i didnt have to use matrices. Also, which matrix would i use? i would think the world matrix to move each object, but i could be wrong(MDX documentation is good but its still abit lacking). if anyone could clear this up for me i'd be grateful.

Share this post


Link to post
Share on other sites
That's a very good way to learn...
As for your question it depends on how you would like to approach it. You could use a scene graph which is basically a hierarchial ordering of your objects, or you could opt to go with your own scene manager.

Your entity class is fine and each entity should have it's own world transformation matrix if you are starting off. It makes it simpler to understand and to learn.

What you could do is have an entity manager that will manage your entities. It will update your entities and send it to the renderer to be rendered.

So just to give you a Pseudo idea of what i'm talking about.

Entity class

Matrix entityMatrix;
Mesh entityMesh;
Texture entityTexture;


Entity Manager

AddEntity(Entity entity)
{
AddEntity To a List
}
UpdateEntities()
{
foreach(entity in entityList)
{
update all the entities in the list. Updating their movement etc,(matrices)
}
}


You could then expose the entity list to the renderer and let your renderer render the entities in the list

I hope this helps,
and if you need any more help do not hestitate to ask.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this