# Creating a 2D perspective in 3D game

I'm new to XNA and 3D game development in general.

I'm creating a puzzle game kind of similar to tetris, built with blocks. I decided to build the game in 3D since I can do some cool animations and transitions when using 3D blocks with physics etc.

However, I really do want the game to look "2D". My blocks are made up of 3D models, but I don't want that to be visible when they're not animating.

I have followed some XNA tutorials and set up my scene like this:

this.view = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
this.aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
this.projection = Matrix.CreatePerspectiveFieldOfView(
1.0f, 10000.0f);


... and it gives me a very 3D-ish look. For example, the blocks in the center of the screen looks exactly how I want them, but closer to the edges of the screen I can see the rotation and sides of them.

My guess is that I'm not after a perspective field of view, but any help on which field of view/settings to use to get a "flat" look when the blocks aren't rotated would be great!

• Erm, if you don't want ortographic... Can you make a sketch what you have and what do you want? – MartinTeeVarga Jun 30 '13 at 12:32
• Yes, that would help. Sorry! Not a sketch, but compare these images from a similar game: i.imgur.com/jSmoGpk.jpg and i.imgur.com/dYsZSwR.jpg. The first one is "2D" and the second one has obvious depth. What I'm after is to make a view which makes it appear like the whole thing is 2D, like the first image. – Accatyyc Jul 1 '13 at 8:20

In your supplied code, notice that you use the following to create your projection:

this.projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f);

The first value is your field of view, in this case, 45 degrees. You can modify this value to be something that gives you what you're looking for. The documentation is here.

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.matrix.createperspectivefieldofview.aspx

If you want a truly 2D effect, you'll will need to set your projection to orthographic using CreateOrthographic. You mention that you want something that still shows "some depth", in which case you might have more luck with CreateOrthographicOffCenter in which your camera is off to one side (perhaps try altering your left and right values by a 0.2 offset.)

http://msdn.microsoft.com/en-us/library/bb195659.aspx

• Thanks! Yes, I will play around with the FOV when I get home. I think this is the way to go. – Accatyyc Jul 1 '13 at 8:23

I guess you are looking for Orthographic projections. I don't know about XNA in detail, but this link could be a starting point.

• Thanks, that works kind of. Though it would be nice to have the perspective when blocks go further back in the screen, for example in falling animations. Maybe I just need perspective but a smaller field of view or something, so the frontmost blocks all appear at the same place – Accatyyc Jun 30 '13 at 11:34