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
impl Map
Sourcepub fn new(width: usize, height: usize, map: &str) -> Map
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}
pub fn get(&self, x: usize, y: usize) -> usize
pub fn is_empty(&self, x: usize, y: usize) -> bool
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> 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