pub struct TileGrid<'a>(/* private fields */);Expand description
A rectangle of tile indices, with the row stride of the grid it sits in.
A level map is wider than a tilemap, so the strip that scrolls into view is not contiguous in the source. Binding the stride to the data rather than passing it alongside keeps the two from being paired wrongly, and the two kinds of grid are separate types so that one cannot be written where the other belongs.
ⓘ
const LEVEL: TileGrid = TileGrid::new(&DATA, 100);
map::write(d, Map::Zero, x, 0, LEVEL.sub(col, 0, 1, 18));Implementations§
Source§impl<'a> TileGrid<'a>
impl<'a> TileGrid<'a>
Sourcepub const fn new(data: &'a [u8], width: u8) -> Self
pub const fn new(data: &'a [u8], width: u8) -> Self
All of data, laid out width cells per row.
The height follows from the length, so a partial last row is dropped, and so is anything past row 255.
§Panics
If width is zero.
Trait Implementations§
Auto Trait Implementations§
impl<'a> BankSafe for TileGrid<'a>
impl<'a> Freeze for TileGrid<'a>
impl<'a> RefUnwindSafe for TileGrid<'a>
impl<'a> Send for TileGrid<'a>
impl<'a> Sync for TileGrid<'a>
impl<'a> Unpin for TileGrid<'a>
impl<'a> UnsafeUnpin for TileGrid<'a>
impl<'a> UnwindSafe for TileGrid<'a>
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