Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
Flint::Camera Class Reference
+ Collaboration diagram for Flint::Camera:

Public Member Functions

FLINT_API Camera (Vec2f viewSize, Vec2f worldSize)
 
FLINT_API void setTargetCenter (Vec2f center)
 Soft-lock camera center on a target (uses current smoothing).
 
FLINT_API void setViewSize (Vec2f size)
 
FLINT_API void setWorldSize (Vec2f size)
 
FLINT_API void update (float smoothing=0.25f)
 Adjust smoothing factor (lerp) used by future setTargetCenter.
 
FLINT_API FloatRect getViewRect () const
 
FLINT_API Vec2f getCenter () const
 
FLINT_API Vec2f screenToWorld (const Vec2f &sp, const Vec2i &screen) const
 Transform screen‑space point back to world‑space.
 
FLINT_API void setZoom (float zoom)
 
FLINT_API float getZoom () const
 
FLINT_API void followClamped (const Vec2f &targetPos, const Vec2i &bufferSize, const Vec2i &mapPixelSize, float smoothing=0.2f)
 Follow a target but clamp so that the view never leaves map.
 

Detailed Description

Definition at line 10 of file camera.h.

Member Function Documentation

◆ followClamped()

FLINT_API void Flint::Camera::followClamped ( const Vec2f & targetPos,
const Vec2i & bufferSize,
const Vec2i & mapPixelSize,
float smoothing = 0.2f )

Follow a target but clamp so that the view never leaves map.

Parameters
targetPostarget world pos (e.g. player centre).
bufferSizeview size in pixels (logical, not world units).
mapPixelSizeworld/map size in pixels.
smoothinglerp factor applied this call (0..1).

◆ getCenter()

FLINT_API Vec2f Flint::Camera::getCenter ( ) const

Center of the current view in world units.

◆ getViewRect()

FLINT_API FloatRect Flint::Camera::getViewRect ( ) const

Current view rectangle in world units.

◆ getZoom()

FLINT_API float Flint::Camera::getZoom ( ) const

Current zoom factor.

◆ screenToWorld()

FLINT_API Vec2f Flint::Camera::screenToWorld ( const Vec2f & sp,
const Vec2i & screen ) const

Transform screen‑space point back to world‑space.

Parameters
splogical renderer pixel coords (after zoom).
screenlogical size; unused but keeps API parity.

◆ setTargetCenter()

FLINT_API void Flint::Camera::setTargetCenter ( Vec2f center)

Soft-lock camera center on a target (uses current smoothing).

Parameters
centerTarget center in world coordinates.

Call once per frame with your player/target center in world coords.

◆ setViewSize()

FLINT_API void Flint::Camera::setViewSize ( Vec2f size)

Update logical view size (e.g. after window resize).

◆ setWorldSize()

FLINT_API void Flint::Camera::setWorldSize ( Vec2f size)

Update world bounds rectangle.

◆ setZoom()

FLINT_API void Flint::Camera::setZoom ( float zoom)

Set zoom (clamped to >=0.01 to avoid division‑by‑zero).

◆ update()

FLINT_API void Flint::Camera::update ( float smoothing = 0.25f)

Adjust smoothing factor (lerp) used by future setTargetCenter.

Parameters
smoothing0 = no movement, 1 = instant snap (default 0.25f).

The documentation for this class was generated from the following file: