Camera Frustum in a 2D Game

Hello community,

I created a very simple game field out of cubes for a simple 2D application. Because it should “be” 2D, I set parallelProjection to true, to simulate a 2D screen. But to make the camera show the whole game field I have to change some frustum settings. Unfortunatly, depending on the screen resoltion the single cubes appear in a (more or less)streched way. Have a look at the following screenshot (Resolution is 1280x720)

I define the frustum as follows.

    float frustumHeight = 2.0f * distance * FastMath.tan(angleDegrees * 0.5f * FastMath.DEG_TO_RAD);
    cam.setFrustumTop(frustumHeight);
    cam.setFrustumBottom(-frustumHeight);

    float width = frustumHeight * (float) (cam.getWidth() / cam.getHeight());
    cam.setFrustumLeft(-width);
    cam.setFrustumRight(width);

I don’t know what I am doing wrong here. Help is really appreciated!

Greetings,
Domenic

Why don’t you simply use Quads and the GuiNode?

You might also want to have a look at GitHub - Pesegato/MonkeySheet: Spritesheet library for jMonkeyEngine
Some stuff is already set up for you…

1 Like

Thanks for your reply. I will read this up!