Struct mold2d::viewport::Viewport
[−]
[src]
pub struct Viewport { pub x: i32, pub y: i32, pub window_dimensions: (i32, i32), pub map_dimensions: (i32, i32), }
Constrains coordinates from an open world into the current window view This allows for scrolling for levels larger than the current screen
Fields
x: i32
The x value of the center coordinate of the viewport
y: i32
The y value of the center coordinate of the viewport
window_dimensions: (i32, i32)
Width and height of the window
map_dimensions: (i32, i32)
Width and height of the map
Methods
impl Viewport
[src]
fn new(window: &Window, map_dimensions: (i32, i32)) -> Viewport
fn set_position(&mut self, new_center: (i32, i32))
fn in_viewport(&self, point: (i32, i32)) -> bool
Returns true if the point is inside the viewport, false otherwise
fn relative_point(&self, map_point: (i32, i32)) -> (i32, i32)
Returns the point in the game relative to the viewpoint
fn constrain_to_viewport(&self, rect: &Rect) -> Option<Rect>
Returns a rectangle in viewport coordinates or None if not in viewport
Trait Implementations
impl Clone for Viewport
[src]
fn clone(&self) -> Viewport
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more