I've got my 2D scene setup using Direct3D 9. I'm using an orthographic view. I've got my sprite displaying on screen. The question is, how do I move the camera in the x and y directions?
Here's a snippet from my game loop:
if (d3ddev->BeginScene())
{
// Black background
d3ddev->ColorFill(backbuffer, NULL, D3DCOLOR_XRGB(0, 0, 0));
sprite->Begin(D3DXSPRITE_ALPHABLEND);
D3DXVECTOR3 pos;
pos.x = 10.0f;
pos.y = 20.0f;
pos.z = 0.0f;
RECT srcRect;
srcRect.left = 1;
srcRect.right = 32;
srcRect.top = 1;
srcRect.bottom = 32;
sprite->Draw(spriteTexture, &srcRect, NULL, &pos, D3DCOLOR_XRGB(255, 255, 255));
sprite->End();
d3ddev->EndScene();
}
d3ddev->Present(NULL, NULL, NULL, NULL);
I'm not trying to do anything fancy right now... Just display a sprite and move the camera. I've got no camera movement code in there right now... So how would I have it automatically scroll right?
Beforehand, in my Direct3D init code, I'm doing this, if it makes a difference.
D3DXMatrixOrthoLH(&Ortho2D, 800.0, 600.0, 0.0f, 1.0f);
D3DXMatrixIdentity(&Identity);
d3ddev->SetTransform(D3DTS_PROJECTION, &Ortho2D);
d3ddev->SetTransform(D3DTS_WORLD, &Identity);
d3ddev->SetTransform(D3DTS_VIEW, &Identity);
So how can I get that camera moving? :)
[Edited by - Gary the Llama on September 18, 2007 8:50:31 PM]