pub struct Camera {
pub origin: Pos,
}Expand description
The map tile shown in the viewport’s top-left corner. It can be negative (or run past the map) when the map is smaller than the viewport: the map is then centred and the cells around it are left blank.
Fields§
§origin: PosTop-left tile of the viewport.
Implementations§
Source§impl Camera
impl Camera
Sourcepub fn centred_on(target: Pos, map_w: u16, map_h: u16, view: (i32, i32)) -> Self
pub fn centred_on(target: Pos, map_w: u16, map_h: u16, view: (i32, i32)) -> Self
A camera with target as near the centre of a viewport of view
tiles (across, down) as the map allows, on a map_w × map_h map.
Sourcepub fn follow(
&mut self,
target: Pos,
map_w: u16,
map_h: u16,
view: (i32, i32),
margin: i32,
)
pub fn follow( &mut self, target: Pos, map_w: u16, map_h: u16, view: (i32, i32), margin: i32, )
Scrolls as little as possible so target is at least margin tiles
from each edge of a viewport of view tiles (across, down), without
showing past the map’s edges. On an axis where the map is smaller
than the viewport, the map is centred. A margin over half the
viewport is treated as half.
Trait Implementations§
impl Copy for Camera
impl Eq for Camera
impl StructuralPartialEq for Camera
Auto Trait Implementations§
impl Freeze for Camera
impl RefUnwindSafe for Camera
impl Send for Camera
impl Sync for Camera
impl Unpin for Camera
impl UnsafeUnpin for Camera
impl UnwindSafe for Camera
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more