#include <tb_camera.hpp>
Public Types | |
| enum | IntensityLevel { kNoShaking , kLightShaking , kMediumShaking , kHeavyShaking } |
Public Member Functions | |
| Camera (void) | |
| virtual | ~Camera (void) |
| void | SetPosition (const float positionX, const float positionY) |
| void | SetPosition (const tbMath::Vector2 &cameraPosition) |
| const tbMath::Vector2 & | GetPosition (void) const |
| tbMath::Vector2 | GetPositionWithShake (void) const |
| void | Update (const float deltaTime) |
| void | ShakeCamera (const IntensityLevel &shakeIntensity, const float shakeDuration=-1.0f) |
| void | SetRotation (const tbMath::Angle &cameraRotation) |
| const tbMath::Angle & | GetRotation (void) const |
Defines what the camera object can do and how it does it. The camera can move around in the world by using SetPosition(), and CameraShake can be applied using ShakeCamera().
Provides different camera shaking intensity levels.
| TurtleBrains::Graphics::Camera::Camera | ( | void | ) |
Creates a camera object that places the top-left of the screen at 0,0 with no shake started.
|
virtual |
Cleans up after the camera object, which doesn't actually have any resources to clean.
| const tbMath::Vector2& TurtleBrains::Graphics::Camera::GetPosition | ( | void | ) | const |
Returns the current position of the camera in world-space coordinates, representing the top-left (0,0) position of the screen if there is no shake, but if there is shake the screen (0,0) will move around slightly based on shake intensity.
| tbMath::Vector2 TurtleBrains::Graphics::Camera::GetPositionWithShake | ( | void | ) | const |
Returns the current position of the camera in world-space coordinates, representing the top-left (0,0) position of the screen including the added shake offset which gets randomly set each frame. This is the position of the screen (0,0) if the camera is shaking or not.
| const tbMath::Angle& TurtleBrains::Graphics::Camera::GetRotation | ( | void | ) | const |
Retrieves the current rotation value of the camera. This is completely experimental and may be removed from the interface completely.
| void TurtleBrains::Graphics::Camera::SetPosition | ( | const float | positionX, |
| const float | positionY | ||
| ) |
Change the position of the camera, which moves the top-left (0,0) of the screen, to some other coordinate in the world based on the supplied parameters.
| positionX | The world-space position where the left of the screen will be placed. |
| positionY | The world-space position where the top of the screen will be placed. |
| void TurtleBrains::Graphics::Camera::SetPosition | ( | const tbMath::Vector2 & | cameraPosition | ) |
Change the position of the camera, which moves the top-left (0,0) of the screen, to some other coordinate in the world based on the supplied cameraPosition parameter.
| cameraPosition | The world-space position where the top-left of the screen will be placed. |
| void TurtleBrains::Graphics::Camera::SetRotation | ( | const tbMath::Angle & | cameraRotation | ) |
Sets the rotation value of the camera so that the scene can rotate. This is completely experimental and may be removed from the interface completely. The camera will rotate the screen around the center of the screen, useful if you want the player to always face a single direction.
| cameraRotation | The amount of rotation to apply, in degrees. Positive values spins the camera clockwise, this will cause the screen to spin counter clockwise. |
| void TurtleBrains::Graphics::Camera::ShakeCamera | ( | const IntensityLevel & | shakeIntensity, |
| const float | shakeDuration = -1.0f |
||
| ) |
Based on the shakeIntensity supplied the camera will start shaking various amounts and for different durations. Light and quick, to heavy and long.
| shakeIntensity | How vigorously the camera is shaking, slight rumble to earthquake rumbles. |
| shakeDuration | How long the camera will shake for, if less-than or equal-to 0, a default internal value will be used for duration. If shakeIntensity is kNoShaking the shakeDuration will have no effect. |
| void TurtleBrains::Graphics::Camera::Update | ( | const float | deltaTime | ) |
This must be called once per frame, every frame, and only once during the frame to update the camera shake and other camera features. When using tbGame::GameScene this is automatically called by the game scene loop update.