2
\$\begingroup\$

I understand that camera and viewport are important to keep virtual measurement units and handle different aspect ratios and resolutions when building games with worlds bigger than the screen (e.g. side-scrollers / map based games).

I am not sure whether it is the proper way to go for a simple game that fits on the screen entirely - like a puzzle or card game for example.

Is it still better to use camera and viewport in this case, or is it more simple, effective (and hence better) to use directly screen absolute coordinates for these types of games?

Or to put it in other way - what are the advantages to use camera and viewport for games that fit on the screen entirely?

\$\endgroup\$
3
\$\begingroup\$

With a camera you separate your game measurements from the screen size and ratio.

It is not always better. If you make a board game for example, you can just fit it to the width of the screen, the view will never move anyway.

When using pixels to measure, you have no floating point positions.

By the way i made a full pong like game without a camera. I just used precents of screen width. For example: platforms are 1/4 screen width, ball is 1/8 screen width

\$\endgroup\$
2
\$\begingroup\$

Adding to what Erez said, you can make any game without using a Viewport and just scaling your textures to a fraction of the screen size, but most of the time using a Viewport is a better option because it scales everything for you.

Although you can use any measurement for the game width and height, I like to choose a target resolution for my game measurements (say 1920 x 1080), then just design all the assets for that target resolution. The Viewport and camera will then scale them to look good on most screens. This might not be a good option for all games but it has worked well for the games I have made.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.