Home Game Development xna – Rotate and Zoom a bunch of tiles

xna – Rotate and Zoom a bunch of tiles

0
xna – Rotate and Zoom a bunch of tiles

[ad_1]

I’m engaged on a tile-based recreation and I’m making an attempt to rotate my tiles as a bunch across the heart of the display and wish to have the flexibility to zoom out and in. Here my code:

        Matrix rework = Matrix.CreateTranslation(new Vector3(-origin.X, -origin.Y, 0f)) *
                           Matrix.CreateRotationZ(rotation) *
                           Matrix.CreateScale(new Vector3(zoomFactor, zoomFactor, 0)) *
                           Matrix.CreateTranslation(new Vector3(Basic.width, Basic.peak, 0));

        Vector2 pos = new Vector2(r.X, r.Y);
        pos = Vector2.Transform(pos, rework);
        r.X = (int)pos.X;
        r.Y = (int)pos.Y;
        angle += rotation;

        Draw(r, origin, angle, zoomFactor, Color.White);

Somehow, this rotates my tiles across the decrease proper nook of the display. The zooming level can also be there.

When setting the second CreateTranslation to

        Matrix.CreateTranslation(new Vector3(origin.X, origin.Y, 0))

only one/4 of the display is seen.

Can somebody assist me with this? I simply wish to let the tiles rotate as a bunch across the heart of the display. Zomming also needs to be centered. How to attain this with out utilizing a 2D digital camera?

Thank you very a lot!

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here