Struct Tilemap

Source
pub struct Tilemap<Image>
where Image: Debug + Clone,
{ /* private fields */ }

Implementations§

Source§

impl<Image> Tilemap<Image>
where Image: Debug + Clone,

Source

pub fn new( tiles: Vec<usize>, flags: Vec<u32>, size: MapSize, tile_idx_image_name: Vec<String>, tileset: Tileset<Image>, render_size: (u32, u32), default_start: MapPosition, exits: Vec<MapExit>, ) -> Result<Tilemap<Image>, GameUtilError>

Source§

impl<Image> Tilemap<Image>
where Image: Debug + Clone,

Source

pub fn px_for_tile<P>(&self, tile: P) -> (isize, isize)
where P: Into<MapPosition>,

Pixel coord for tile Result may be offscreen, before or after

Source

pub fn orig_px_for_tile<P>(&self, tile: P) -> (isize, isize)
where P: Into<MapPosition>,

Pixel coord for tile, ignoring subtile offset Result may be offscreen, before or after

Source

pub fn first_visible_tile(&self) -> MapPosition

Returns the pos of the first tile with at least one pixel visible

Will match Tilemap::first_visible_tile unless a subtile offset is set

Source

pub fn first_fully_visible_tile(&self) -> MapPosition

Returns the pos of the first fully visible tile

See Tilemap::first_visible_tile

Source

pub fn last_visible_tile(&self) -> MapPosition

Returns the pos of the last tile with at least one pixel visible

Will match Tilemap::last_visible_tile unless a subtile offset is set

Source

pub fn last_fully_visible_tile(&self) -> MapPosition

Returns the pos of the last fully visible tile

See Tilemap::last_visible_tile

Source

pub fn is_inside<P>(&self, tile: P) -> bool
where P: Into<MapPosition>,

Returns true if tile is inside the map

Source

pub fn draw<F>(&self, render: F)
where F: FnMut(&Image, (isize, isize)),

Loops through all visible tiles calling render with the image and px coord

Source

pub fn update_pos_with_offset(&self, pos: (isize, isize)) -> (isize, isize)

Source

pub fn center_on<P>(&mut self, pos: P)
where P: Into<MapPosition>,

Moves center of visible map to pos

Source

pub fn all_tiles_with_flag(&self, flag: u32) -> Vec<MapPosition>

Returns a list of tiles matching flag

Source

pub fn tile_has_flag<P>(&self, tile: P, value: u32) -> bool
where P: Into<MapPosition>,

Returns true if tile has a flag of value

Source

pub fn flags_for_tile<P>(&self, tile: P) -> u32
where P: Into<MapPosition>,

Returns flag value for tile

Source

pub fn set_flag<P>(&mut self, tile: P, value: u32)
where P: Into<MapPosition>,

Sets the flag value for tile

Source

pub fn clear_flag<P>(&mut self, tile: P, value: u32)
where P: Into<MapPosition>,

Removes specified flags for tile

Source

pub fn default_start(&self) -> MapPosition

The default, safe start position on the map

Source

pub fn exits(&self) -> &Vec<MapExit>

All exits to other maps

Source

pub fn tile_size(&self) -> (u32, u32)

Source

pub fn size(&self) -> MapSize

Source

pub fn set_subtile_offset(&mut self, subtile_offset: (i16, i16))

Sets a pixel offset for drawing Primarily designed for smoothing animation the map when a character or camera is moving

Source

pub fn subtile_offset(&self) -> (i16, i16)

Returns a pixel offset for drawing

Trait Implementations§

Source§

impl<Image> Clone for Tilemap<Image>
where Image: Clone + Debug,

Source§

fn clone(&self) -> Tilemap<Image>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Image> Debug for Tilemap<Image>
where Image: Debug + Clone,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Image> Freeze for Tilemap<Image>

§

impl<Image> RefUnwindSafe for Tilemap<Image>
where Image: RefUnwindSafe,

§

impl<Image> !Send for Tilemap<Image>

§

impl<Image> !Sync for Tilemap<Image>

§

impl<Image> Unpin for Tilemap<Image>

§

impl<Image> UnwindSafe for Tilemap<Image>
where Image: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyToAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more