Skip to main content

Module camera

Module camera 

Source
Expand description

Camera system — viewport positioning with smooth follow, zoom, and boundary clamping.

A general-purpose camera that supports arbitrary world sizes, fractional pixel positions, smooth interpolation, and zoom. It supersedes the older fixed Game Boy-style scroll/viewport approach.

§Usage

use dotzuki_engine::camera::{Camera, Vec2, Rect};

let mut cam = Camera::new(160.0, 144.0);
cam.clamp_to_bounds(Rect::new(0.0, 0.0, 2048.0, 2048.0));
cam.follow_target(Vec2::new(player_x, player_y));

// Every frame:
cam.update(dt);
let screen_pos = cam.world_to_screen(Vec2::new(npc_x, npc_y));

Structs§

Camera
Camera controlling which portion of the world is visible on screen.
Rect
Axis-aligned rectangle with floating-point coordinates.
Vec2
Two-dimensional vector (floating-point).