Skip to content

Struct Engine::CameraComponent

ClassList > Engine > CameraComponent

2D camera that decides which part of the world is shown on screen. More...

  • #include <CameraComponent.hpp>

Public Attributes

Type Name
Rectangle bounds
World-space rectangle the view is kept inside when clampToBounds is set.
bool clampToBounds
When true, the view never shows anything outside bounds .
float followSpeed
How fast the camera catches up with followTarget , per second. 0 snaps instantly to the target.
std::optional< Entity > followTarget
Entity whosePosition the camera follows. No follow when empty.
bool primary
When true, this camera is a candidate for rendering.
float shakeDecay
Trauma lost per second.
float shakeMagnitude
Maximum shake offset in world units, reached when trauma is 1.
float shakeOffsetX = 0.0f
Shake offset of the current frame, written by CameraSystem .
float shakeOffsetY = 0.0f
Shake offset of the current frame, written by CameraSystem .
float shakeTrauma
Current shake intensity in [0, 1]. Set it to 1 to trigger a full shake.
float zoom
Zoom factor (1 = no zoom, 2 = everything twice as big).

Public Functions

Type Name
CameraComponent (float zoom=1.0f, bool primary=true)
Constructs a camera with explicit settings and defaults.

Detailed Description

The camera reuses the transform of its entity: * Position is the world point drawn at the center of the viewport. * Rotation is the rotation of the view, in degrees.

Only one camera is used for rendering: the primary camera with the lowest entity id. Entities tagged with ScreenSpace ignore the camera (HUD, menus...).

Public Attributes Documentation

variable bounds

World-space rectangle the view is kept inside when clampToBounds is set.

Rectangle Engine::CameraComponent::bounds;


variable clampToBounds

When true, the view never shows anything outside bounds .

bool Engine::CameraComponent::clampToBounds;


variable followSpeed

How fast the camera catches up with followTarget , per second. 0 snaps instantly to the target.

float Engine::CameraComponent::followSpeed;


variable followTarget

Entity whosePosition the camera follows. No follow when empty.

std::optional<Entity> Engine::CameraComponent::followTarget;


variable primary

When true, this camera is a candidate for rendering.

bool Engine::CameraComponent::primary;


variable shakeDecay

Trauma lost per second.

float Engine::CameraComponent::shakeDecay;


variable shakeMagnitude

Maximum shake offset in world units, reached when trauma is 1.

float Engine::CameraComponent::shakeMagnitude;


variable shakeOffsetX

Shake offset of the current frame, written by CameraSystem .

float Engine::CameraComponent::shakeOffsetX;


variable shakeOffsetY

Shake offset of the current frame, written by CameraSystem .

float Engine::CameraComponent::shakeOffsetY;


variable shakeTrauma

Current shake intensity in [0, 1]. Set it to 1 to trigger a full shake.

float Engine::CameraComponent::shakeTrauma;


variable zoom

Zoom factor (1 = no zoom, 2 = everything twice as big).

float Engine::CameraComponent::zoom;


Public Functions Documentation

function CameraComponent

Constructs a camera with explicit settings and defaults.

inline Engine::CameraComponent::CameraComponent (
    float zoom=1.0f,
    bool primary=true
) 

Parameters:

  • zoom Zoom factor.
  • primary Whether this camera can be used for rendering.


The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/Components/CameraComponent.hpp