Camera Class

The Camera class is used to allow the screen to scroll, zoom, rotate, or shake. This class can be used to make the screen follow the player as in the example provided. Move and rotate the ship using the arrow keys. The camera will move and rotate with the ship so that the ship appears to stay in one spot while the scenery scrolls and rotates instead.

Have a look at Camera.h. The camera has a position and rotation, to move and rotate the camera. It also has zoom which can be used to change the magnification of everything on screen!(use + and - to zoom in and out in the demo)  The offset tells the camera where its center should be on screen. Notice that the ship is not centered vertically on screen yet if you rotate the screen, the rotation is centered on the ship, this is because the offset is a little lower than the center of the screen. The camera class also has wobble and vibration effects which you can use to simulate everything from explosions to earthquakes. Take the time to play around with the settings and see what they do. The camera only effects objects that are rendered after you call the camera’s activate function. You can also deactivate the camera to go back to rendering objects normally (in screen-space).

Camera.zip  3.6MB