Move sprites or move camera...

Started by
3 comments, last by Lowspeed 18 years, 7 months ago
Hi all, I have lots of 2d sprites on screen (tiles) and I am currently moving the character by moving all of the tiles. Would it be more efficient to move the camera instead? I was just curious as I stumbled upon that implementation on a website, and the author claimed it to be faster. Any thoughts on the matter?
Advertisement
I would imagine that moving the camera would be less CPU intensive. By moving every tile you have to apply calculations and matrix transforms, etc to every tile being moved. Alternatively, if you just move the camera you only need to do one set of matrix transforms each frame.
Move the camera! Take advantage of 2d-in-3d.
Thanks for your replys!

Would I still be able to use coordinates if I move the camera?

As of now I am positioning the camera and setting it so the upper left is 0, 0 and all the coordinates are positive.

Thanks,
BTW, this is how I am setting up my camera...

// get camera vectors
float width = (float)_targetControl.ClientSize.Width;
float height = (float)_targetControl.ClientSize.Height;
float centerX = width / 2.0f;
float centerY = height / 2.0f;
Vector3 cameraPosition = new Vector3(centerX, centerY, -5.0f);
Vector3 cameraTarget = new Vector3(centerX, centerY, 0.0f);

// create our transforms
newDevice.Transform.View = Matrix.LookAtLH(cameraPosition, cameraTarget, new Vector3(0.0f, 1.0f, 0.0f));

newDevice.Transform.Projection = Matrix.OrthoLH(width, height, 1.0f, 10.0f);

This topic is closed to new replies.

Advertisement