Skip to main content
gamedev.net
🔒 Locked

Moving multiple objects

Started by deathtrap 1 reply 650+ views
Original Post
deathtrap
deathtrap
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.
Armadon
Armadon
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.