O'Reilly logo

Lua Game Development Cookbook by Mário Kašuba

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting up the orthogonal and perspective cameras

The camera view is affected by the projection matrix. The projection matrix allows you to set up the camera position, rotation and the size of visible space.

Games mostly use two modes of camera projection. The first one is the orthogonal mode, which can be used to draw 2D scenes on the screen. This mode doesn't use the perspective camera, so the object's distance doesn't affect its size. On the other hand, the perspective mode causes farther objects to be visibly smaller than the nearer objects.

Getting ready

This recipe will assume that the current screen dimensions are stored in the variables screen_width and screen_height. These variables might change their values when you resize the application ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required