#include <tb_camera.h>
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.
Enumerator |
---|
kNoShaking |
A shake intensity level that cancels out any current shaking effects.
|
kLightShaking |
A shake intensity level like some slight vibration from movement.
|
kMediumShaking |
A shake intensity level like a small explosion.
|
kHeavyShaking |
A shake intensity level like an earthquake is happening.
|
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 TurtleBrains::Graphics::Camera::~Camera |
( |
void |
| ) |
|
|
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.
float 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.
- Note
- : Use this at your own risk, as it is not fully supported and may get removed from future versions.
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.
- Parameters
-
cameraPosition | The world-space position where the top-left of the screen will be placed. |
void TurtleBrains::Graphics::Camera::SetRotation |
( |
const float |
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.
- Parameters
-
cameraRotation | The amount of rotation to apply, in degrees. Positive values spins the camera clockwise, this will cause the screen to spin counter clockwise. |
- Note
- : Use this at your own risk, as it is not fully supported and may get removed from future versions.
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.
- Parameters
-
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.