Game Development Reference
In-Depth Information
What is a camera?
The chance that you've not come across cameras in games development is quite slim. They
are an essential part of any game. Essentially, a camera is that point in space through which
you can look at the game world. There are more parameters associated with cameras, both
in 2D and 3D space, but in this chapter, we will only focus on what SFML has to offer.
Before we jump to the code, let's get some facts straight. Since SFML is used mainly with
2D games, the camera class exclusively uses an orthographic projection. In this projec-
tion, every object appears as if it has no perspective augmentations. The alternative, as you
might have guessed, is a perspective projection, which actually changes how objects appear
on the screen based on the physics of the human eye (object appear smaller in the distance,
and so on). However, this projection is used mainly in 3D games, and it does not belong in
the world of 2D. Here is a little comparison:
Using a perspective projection for a game which relies on two dimensions does not make
much sense because the image of the sprites gets distorted. This is why SFML does not
even offer the choice to use one. We can always create a custom camera with OpenGL
though, a topic which we will discuss later in this chapter.
Search WWH ::




Custom Search