Struct Map

Source
pub struct Map {
    pub width: usize,
    pub height: usize,
    pub map: Vec<char>,
}

Fields§

§width: usize§height: usize§map: Vec<char>

Implementations§

Source§

impl Map

Source

pub fn new(width: usize, height: usize, map: &str) -> Map

Examples found in repository?
examples/ex1.rs (line 32)
10fn main() {
11    let win_w: usize = 1024;
12    let win_h: usize = 512;
13
14    let mut framebuffer: Framebuffer = Framebuffer::new(win_h, win_w);
15
16    let map_string = "0000222222220000\
17                      1              0\
18                      1      11111   0\
19                      1     0        0\
20                      0     0  1110000\
21                      0     3        0\
22                      0   10000      0\
23                      0   3   11100  0\
24                      5   4   0      0\
25                      5   4   1  00000\
26                      0       1      0\
27                      2       1      0\
28                      0       0      0\
29                      0 0000000      0\
30                      0              0\
31                      0002222222200000";
32    let mut map: Map = Map::new(16, 16, map_string);
33
34    let mut player: Player = Player{
35        x: 3.456,
36        y: 2.345,
37        direction: 1.523,
38        fov: PI / 3.,
39    };
40
41    let mut sprites: Sprites = vec![
42        Sprite::new(3.523, 3.812, 2),
43        Sprite::new(1.843, 8.765, 0),
44        Sprite::new(5.323, 5.365, 1),
45        Sprite::new(4.123, 10.265, 1),
46    ];
47
48    let wall_textures: Texture = Texture::new("./examples/walltex.png");
49    let mon_textures: Texture = Texture::new("./examples/montex.png");
50
51    render(&mut framebuffer, &mut map, &mut player, &mut sprites, &mon_textures, &wall_textures);
52    framebuffer.write_file("frame.ppm");
53}
Source

pub fn get(&self, x: usize, y: usize) -> usize

Source

pub fn is_empty(&self, x: usize, y: usize) -> bool

Source

pub fn get_char(&self, x: usize, y: usize) -> char

Auto Trait Implementations§

§

impl Freeze for Map

§

impl RefUnwindSafe for Map

§

impl Send for Map

§

impl Sync for Map

§

impl Unpin for Map

§

impl UnwindSafe for Map

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.