class

PointClickEngine::Graphics::Core::Camera

Inherits Reference < Object

2D camera for managing the view into the game world

The Camera class provides basic 2D view management including position, bounds checking, and smooth movement. It integrates with the effects system for advanced camera behaviors.

Example

camera = Camera.new
camera.set_bounds(0, 0, 2048, 1536)     # Large scrollable area
camera.position = Vector2.new(512, 384) # Look at specific position

Constructors

new(x : Float32, y : Float32)
Source

Instance methods

apply_offset(world_x : Float32, world_y : Float32) : RL::Vector2

Apply camera offset (utility for manual calculations)

Source
center_on(x : Float32, y : Float32, viewport_width : Int32 = Display.reference_width, viewport_height : Int32 = Display.reference_height)

Center camera on a world position

Source
center_on(position : RL::Vector2)

Center camera on position vector

Source
max_x
Source
max_x=(max_x : Float32)
Source
max_y
Source
max_y=(max_y : Float32)
Source
min_x

Camera bounds (to keep camera within scene limits)

Source
min_x=(min_x : Float32)

Camera bounds (to keep camera within scene limits)

Source
min_y
Source
min_y=(min_y : Float32)
Source
move_to(x : Float32, y : Float32)

Move camera to position (instant or smooth based on settings)

Source
move_to(target : RL::Vector2)

Move camera to position vector

Source
position

Camera position in world coordinates

Source
position=(position : RL::Vector2)

Camera position in world coordinates

Source
reset

Reset camera to origin

Source
screen_to_world(screen_x : Int32, screen_y : Int32) : RL::Vector2

Convert screen coordinates to world coordinates

Source
set_bounds(scene_width : Int32, scene_height : Int32, viewport_width : Int32 = Display.reference_width, viewport_height : Int32 = Display.reference_height)

Set camera bounds based on scene size

Source
set_bounds(min_x : Float32, min_y : Float32, max_x : Float32, max_y : Float32)

Set camera bounds explicitly

Source
set_scene_size(scene_width : Int32, scene_height : Int32)

Convenience method for setting scene size (calls set_bounds)

Source
shake(intensity : Float32, duration : Float32)

Shake the camera (trigger effect through effect system) This is a convenience method that should integrate with effects

Source
smooth_enabled

Smooth movement properties

Source
smooth_enabled=(smooth_enabled : Bool)

Smooth movement properties

Source
smooth_speed
Source
smooth_speed=(smooth_speed : Float32)
Source
update(dt : Float32)

Update camera (for smooth movement)

Source
visible?(world_x : Float32, world_y : Float32, margin : Float32 = 0.0_f32, viewport_width : Int32 = Display.reference_width, viewport_height : Int32 = Display.reference_height) : Bool

Check if a world position is visible

Source
visible?(rect : RL::Rectangle, margin : Float32 = 0.0_f32) : Bool

Check if a rectangle is visible

Source
visible_area(viewport_width : Int32 = Display.reference_width, viewport_height : Int32 = Display.reference_height) : RL::Rectangle

Get the visible area in world coordinates

Source
world_to_screen(world_x : Float32, world_y : Float32) : RL::Vector2

Convert world coordinates to screen coordinates

Source