Gondwana Game Engine
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop, mobile, and web platforms using SkiaSharp for graphics and NAudio for sound.
Loading...
Searching...
No Matches
Gondwana.Rendering.Views.Camera Class Referencesealed

Represents a world-space camera for a Scene. The camera tracks a world-space upper-left position in pixels and is used by Views to determine which part of the Scene is visible. It supports snapping, smooth follow, dead zones, and clamping to world bounds. More...

Public Member Functions

void SnapTo (PointF worldUpperLeftPx)
 Instantly moves the camera to the specified world-space position, interpreted as the upper-left corner of the visible region. Any active smooth follow or pan continues from this new position.
void CenterOn (PointF worldCenterPx)
 Instantly repositions the camera so that the given world-space point appears at the center of the view. Uses the current visible world size to compute the appropriate camera upper-left position.
void CenterOnGrid (SceneLayer layer, int col, int row)
 Instantly centers the camera on the specified tile in the given SceneLayer. The tile's visual center is placed at the center of the view.
void PanCenterTo (PointF worldCenterPx, float speed)
 Smoothly pans the camera so that the given world-space point ends up at the center of the visible view, using the given follow speed.
void AnimateCenterOnGrid (SceneLayer layer, int col, int row, float speed)
 Smoothly pans the camera until the specified grid tile is centered in the view. Uses the given follow speed for the motion.
void PanTo (PointF worldTopLeftPx, float speed)
 Smoothly pans the camera toward a world-space top-left position for the view, using the given follow speed. This interprets the input as the desired camera upper-left, not a center point.
void PanCenterToOnce (PointF worldCenterPx, float speed)
 Smoothly pans the camera so that the specified world-space point becomes the visual center of the view, then stops. Unlike PanCenterTo, this is a one-shot cinematic pan and does not continue tracking the point after the camera arrives.
void PanToOverDuration (PointF worldTopLeftPx, float durationSeconds)
 Smoothly pans the camera so that its upper-left pixel reaches the specified world-space target over approximately the given duration. This uses the same exponential smoothing model as PanTo, but computes an appropriate lerp rate so the camera covers ~99% of the distance in the requested time.
void PanCenterToOverDuration (PointF worldCenterPx, float durationSeconds)
 Smoothly pans the camera so that the specified world-space point becomes the visual center of the view over approximately the given duration, then stops. Unlike PanCenterTo, this is a one-shot cinematic pan and does not continue tracking the point afterward.
void PanToGridOverDuration (SceneLayer layer, int col, int row, float durationSeconds)
 Smoothly pans the camera so that the specified grid tile becomes the visual center of the view over approximately the given duration. This is a one-shot cinematic pan to a tile, not a continuous follow.
void PanBy (PointF deltaPx)
 Instantly pans the camera by the given offset in world-space pixels. This adds the offset to the current camera position without changing any follow or pan targets.
void Follow (Func< PointF > getWorldPixel, bool hardFollow=false)
 Configures the camera to follow a dynamically supplied world-space target position. Each update, the supplier is called to get the desired target "point of interest" in world pixels (typically a character center), and the camera moves so that point stays visible, honoring dead-zones and clamping.
void FollowTo (PointF worldPointOfInterestPx)
 Starts smooth camera movement toward a fixed world-space "point of interest" (typically a center point). Uses the same follow logic as Follow(Func<PointF>, bool) but with a constant target.
void FollowCentered (IMovableOnSceneLayer target, float speed=-1f, bool hard=false)
 Makes the camera follow an IMovable-on-SceneLayer so that the object stays centered in the view. Supports both grid-space and pixel-space movement, using the current coordinate system for the layer.
void FollowCenteredX (IMovableOnSceneLayer target, float speed=-1f, bool hard=false)
 Smoothly follows an IMovable target, centering it horizontally only. Vertical camera position is left unchanged.
void FollowCenteredY (IMovableOnSceneLayer target, float speed=-1f, bool hard=false)
 Smoothly follows an IMovable target, centering it vertically only. Horizontal camera position is left unchanged.
void ClearFollow ()
 Clears any active follow or pan targets; the camera remains at its current position until moved again.

Properties

PointF PositionPx [get]
 Gets or sets the camera's world-space position in pixels, interpreted as the upper-left corner of the visible region. All world-to-screen projections for this camera are based on this position.
RectangleF WorldBoundsPx = RectangleF.Empty [get, set]
 World-space rectangle (in pixels) that the camera is allowed to move within. Clamping logic uses this to prevent the view from scrolling past the edges of the world or map.
Rectangle DeadZonePx = Rectangle.Empty [get, set]
 Size of the dead zone, in pixels, around the center of the view where the follow target is allowed to move without forcing the camera to track it. A larger dead zone produces a looser, less reactive camera.
float FollowLerpPerSecond = 8f [get, set]
 Controls how quickly the camera moves toward its follow target when smooth follow is enabled. Interpreted as a lerp factor per second: higher values feel snappier, lower values feel more floaty.

Detailed Description

Represents a world-space camera for a Scene. The camera tracks a world-space upper-left position in pixels and is used by Views to determine which part of the Scene is visible. It supports snapping, smooth follow, dead zones, and clamping to world bounds.

Member Function Documentation

◆ AnimateCenterOnGrid()

void Gondwana.Rendering.Views.Camera.AnimateCenterOnGrid ( SceneLayer layer,
int col,
int row,
float speed )

Smoothly pans the camera until the specified grid tile is centered in the view. Uses the given follow speed for the motion.

◆ CenterOn()

void Gondwana.Rendering.Views.Camera.CenterOn ( PointF worldCenterPx)

Instantly repositions the camera so that the given world-space point appears at the center of the view. Uses the current visible world size to compute the appropriate camera upper-left position.

Parameters
worldCenterPxWorld-space pixel position that should be centered on screen.

◆ CenterOnGrid()

void Gondwana.Rendering.Views.Camera.CenterOnGrid ( SceneLayer layer,
int col,
int row )

Instantly centers the camera on the specified tile in the given SceneLayer. The tile's visual center is placed at the center of the view.

◆ ClearFollow()

void Gondwana.Rendering.Views.Camera.ClearFollow ( )

Clears any active follow or pan targets; the camera remains at its current position until moved again.

◆ Follow()

void Gondwana.Rendering.Views.Camera.Follow ( Func< PointF > getWorldPixel,
bool hardFollow = false )

Configures the camera to follow a dynamically supplied world-space target position. Each update, the supplier is called to get the desired target "point of interest" in world pixels (typically a character center), and the camera moves so that point stays visible, honoring dead-zones and clamping.

Parameters
getWorldPixelFunction that returns the target world-space point of interest each frame.
hardFollowIf true, the camera snaps directly to the desired position (no smoothing). If false, the camera smoothly lerps toward the target using FollowLerpPerSecond.

◆ FollowCentered()

void Gondwana.Rendering.Views.Camera.FollowCentered ( IMovableOnSceneLayer target,
float speed = -1f,
bool hard = false )

Makes the camera follow an IMovable-on-SceneLayer so that the object stays centered in the view. Supports both grid-space and pixel-space movement, using the current coordinate system for the layer.

◆ FollowCenteredX()

void Gondwana.Rendering.Views.Camera.FollowCenteredX ( IMovableOnSceneLayer target,
float speed = -1f,
bool hard = false )

Smoothly follows an IMovable target, centering it horizontally only. Vertical camera position is left unchanged.

◆ FollowCenteredY()

void Gondwana.Rendering.Views.Camera.FollowCenteredY ( IMovableOnSceneLayer target,
float speed = -1f,
bool hard = false )

Smoothly follows an IMovable target, centering it vertically only. Horizontal camera position is left unchanged.

◆ FollowTo()

void Gondwana.Rendering.Views.Camera.FollowTo ( PointF worldPointOfInterestPx)

Starts smooth camera movement toward a fixed world-space "point of interest" (typically a center point). Uses the same follow logic as Follow(Func<PointF>, bool) but with a constant target.

Parameters
worldPointOfInterestPxWorld-space pixel position of the target point of interest.

◆ PanBy()

void Gondwana.Rendering.Views.Camera.PanBy ( PointF deltaPx)

Instantly pans the camera by the given offset in world-space pixels. This adds the offset to the current camera position without changing any follow or pan targets.

◆ PanCenterTo()

void Gondwana.Rendering.Views.Camera.PanCenterTo ( PointF worldCenterPx,
float speed )

Smoothly pans the camera so that the given world-space point ends up at the center of the visible view, using the given follow speed.

Parameters
worldCenterPxWorld-space pixel position that should appear in the center of the view.
speedFollow speed in lerp-units per second. Higher values feel snappier, lower values feel more floaty.

◆ PanCenterToOnce()

void Gondwana.Rendering.Views.Camera.PanCenterToOnce ( PointF worldCenterPx,
float speed )

Smoothly pans the camera so that the specified world-space point becomes the visual center of the view, then stops. Unlike PanCenterTo, this is a one-shot cinematic pan and does not continue tracking the point after the camera arrives.

Parameters
worldCenterPxWorld-space pixel position that should end up at the center of the view.
speedPan speed in lerp-units per second. Higher values feel snappier, lower values feel more floaty. If <= 0, the camera snaps immediately to the target center.

◆ PanCenterToOverDuration()

void Gondwana.Rendering.Views.Camera.PanCenterToOverDuration ( PointF worldCenterPx,
float durationSeconds )

Smoothly pans the camera so that the specified world-space point becomes the visual center of the view over approximately the given duration, then stops. Unlike PanCenterTo, this is a one-shot cinematic pan and does not continue tracking the point afterward.

Parameters
worldCenterPxWorld-space pixel position that should end up at the center of the view.
durationSecondsApproximate time (in seconds) for the camera to reach the target center. Values <= 0 cause an immediate snap to the destination.

◆ PanTo()

void Gondwana.Rendering.Views.Camera.PanTo ( PointF worldTopLeftPx,
float speed )

Smoothly pans the camera toward a world-space top-left position for the view, using the given follow speed. This interprets the input as the desired camera upper-left, not a center point.

Parameters
worldTopLeftPxWorld-space pixel position for the camera's upper-left corner.
speedPan speed in lerp-units per second. Higher values feel snappier, lower values feel more floaty. If <= 0, the camera snaps.

◆ PanToGridOverDuration()

void Gondwana.Rendering.Views.Camera.PanToGridOverDuration ( SceneLayer layer,
int col,
int row,
float durationSeconds )

Smoothly pans the camera so that the specified grid tile becomes the visual center of the view over approximately the given duration. This is a one-shot cinematic pan to a tile, not a continuous follow.

Parameters
layerScene layer the grid position belongs to.
colGrid column of the tile to center on.
rowGrid row of the tile to center on.
durationSecondsApproximate time (in seconds) for the camera to reach the target cell. Values <= 0 cause an immediate snap to the destination.

◆ PanToOverDuration()

void Gondwana.Rendering.Views.Camera.PanToOverDuration ( PointF worldTopLeftPx,
float durationSeconds )

Smoothly pans the camera so that its upper-left pixel reaches the specified world-space target over approximately the given duration. This uses the same exponential smoothing model as PanTo, but computes an appropriate lerp rate so the camera covers ~99% of the distance in the requested time.

Parameters
worldTopLeftPxDesired world-space pixel position for the camera's upper-left corner.
durationSecondsApproximate time (in seconds) for the camera to reach the target. Values <= 0 cause an immediate snap to the destination.

◆ SnapTo()

void Gondwana.Rendering.Views.Camera.SnapTo ( PointF worldUpperLeftPx)

Instantly moves the camera to the specified world-space position, interpreted as the upper-left corner of the visible region. Any active smooth follow or pan continues from this new position.

Parameters
worldUpperLeftPxWorld-space pixel position for the camera's upper-left corner.

Property Documentation

◆ DeadZonePx

Rectangle Gondwana.Rendering.Views.Camera.DeadZonePx = Rectangle.Empty
getset

Size of the dead zone, in pixels, around the center of the view where the follow target is allowed to move without forcing the camera to track it. A larger dead zone produces a looser, less reactive camera.

◆ FollowLerpPerSecond

float Gondwana.Rendering.Views.Camera.FollowLerpPerSecond = 8f
getset

Controls how quickly the camera moves toward its follow target when smooth follow is enabled. Interpreted as a lerp factor per second: higher values feel snappier, lower values feel more floaty.

◆ PositionPx

PointF Gondwana.Rendering.Views.Camera.PositionPx
get

Gets or sets the camera's world-space position in pixels, interpreted as the upper-left corner of the visible region. All world-to-screen projections for this camera are based on this position.

◆ WorldBoundsPx

RectangleF Gondwana.Rendering.Views.Camera.WorldBoundsPx = RectangleF.Empty
getset

World-space rectangle (in pixels) that the camera is allowed to move within. Clamping logic uses this to prevent the view from scrolling past the edges of the world or map.