In this article, we introduce the concept of the camera and describe how you can make games scroll using the camera.
Scrolling
Although some games exist entirely on a single screen, many extend beyond that. For example, think about a game similar to Super Mario Bros. Levels extend beyond a single screen.
In games like these, when the player walks to the right, the game “scrolls” to the right.
How does this “scrolling” work? In simple terms, scrolling is the act of changing what part of the scene is visible.
One can draw a connection to something we’re familiar with - peering through the viewfinder (or screen) of a camera to compose a photograph.
The “camera” in our engine is the exact same concept - it’s the “thing” that controls what part of the scene is visible.
Note: In fact, the “camera” is an actor! It’s an invisible, non-physical actor, but like any kind of actor, it has a position and it can be moved around.
Example: Making the Camera Follow the Player
In many games, the camera follows the player, so that the player is always on screen.