Struct simple_tilemap::Tile

source ·
pub struct Tile {
    pub id: TileId,
    pub color: Color,
    pub solid: bool,
    pub opaque: bool,
    pub opts: BlitOptions,
}
Expand description

Tile in a Tilemap.

Fields§

§id: TileId

Id of the tile.

§color: Color

Color of the tile. Will be multiplied by the tile’s ‘original’ color (the one in the tileset).

§solid: bool

Whether the tile is solid or not. This isn’t used in any way by this library, but can be generally useful.

§opaque: bool

Whether the tile is opaque or not. This isn’t used in any way by this library, but can be generally useful.

§opts: BlitOptions

Blit options.

Implementations§

source§

impl Tile

source

pub const fn new(id: TileId) -> Self

Contruct a new tile.

source

pub const fn with_color(self, color: Color) -> Self

Specify tile color.

Allows for chaining tile creation like Tile::new(4).with_color(Color::new(255, 0, 255, 255)).solid() etc.

source

pub fn set_color(&mut self, color: Color) -> &mut Self

Set the tile’s color.

Allows for chaining tile modifying like tilemap.get_mut_tile(1, 1).unwrap().set_color(Color::new(255, 0, 255, 255)).set_solid(false) etc.

source

pub const fn solid(self) -> Self

Specify that the tile is solid.

Allows for chaining tile creation like Tile::new(4).with_color(Color::new(255, 0, 255, 255)).solid() etc.

source

pub fn set_solid(&mut self, solid: bool) -> &mut Self

Set the tile’s solidness.

Allows for chaining tile modifying like tilemap.get_mut_tile(1, 1).unwrap().set_color(Color::new(255, 0, 255, 255)).set_solid(false) etc.

source

pub const fn opaque(self) -> Self

Specify that the tile is opaque.

Allows for chaining tile creation like Tile::new(4).with_color(Color::new(255, 0, 255, 255)).solid() etc.

source

pub fn set_opaque(&mut self, opaque: bool) -> &mut Self

Set the tile’s opacity.

Allows for chaining tile modifying like tilemap.get_mut_tile(1, 1).unwrap().set_color(Color::new(255, 0, 255, 255)).set_solid(false) etc.

source

pub const fn with_blit_options(self, opts: BlitOptions) -> Self

Specify the blit options.

Allows for chaining tile creation like Tile::new(4).with_color(Color::new(255, 0, 255, 255)).solid() etc.

source

pub fn set_blit_options(&mut self, opts: BlitOptions) -> &mut Self

Set the tile’s blit options.

Allows for chaining tile modifying like tilemap.get_mut_tile(1, 1).unwrap().set_color(Color::new(255, 0, 255, 255)).set_solid(false) etc.

Trait Implementations§

source§

impl<C> Buffer<Tile> for Tilemap<C>

source§

fn width(&self) -> u32

Buffer width
source§

fn height(&self) -> u32

Buffer height
source§

fn get(&self, x: u32, y: u32) -> &Tile

Get a value at (x, y). This function must not panic when x < self.width() && y < self.height() (unless you want blit functions to panic). It will not be called with values outside of that range.
source§

impl<C> BufferMut<Tile> for Tilemap<C>

source§

fn get_mut(&mut self, x: u32, y: u32) -> &mut Tile

Get a mutable value at (x, y). This function must not panic when x < self.width() && y < self.height() (unless you want blit functions to panic). It will not be called with values outside of that range.
source§

impl Clone for Tile

source§

fn clone(&self) -> Tile

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 Debug for Tile

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Tile

source§

fn default() -> Tile

Returns the “default value” for a type. Read more
source§

impl PartialEq for Tile

source§

fn eq(&self, other: &Tile) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Tile

source§

impl Eq for Tile

source§

impl StructuralEq for Tile

source§

impl StructuralPartialEq for Tile

Auto Trait Implementations§

§

impl RefUnwindSafe for Tile

§

impl Send for Tile

§

impl Sync for Tile

§

impl Unpin for Tile

§

impl UnwindSafe for Tile

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> 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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,

§

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>,

§

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>,

§

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.