Thursday, October 13, 2022
HomeGame Developmentxna - Rotate and Zoom a gaggle of tiles

xna – Rotate and Zoom a gaggle of tiles


I am engaged on a tile-based recreation and I am attempting to rotate my tiles as a gaggle across the heart of the display screen and wish to have the power to zoom out and in. Right here my code:

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

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

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

Someway, this rotates my tiles across the decrease proper nook of the display screen. 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 screen is seen.

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

Thanks very a lot!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments