pub fn render(canvas: &mut render::WindowCanvas, map: &mut Map)
{
    canvas.set_draw_color(Color::RGB(0, 0, 0));
    canvas.clear();

    for x in 0..CELLS_PER_ROW {
        let xpos = (x * CELL_HEIGHT) as i32;

        for y in 0..CELLS_PER_COL {
            let ypos = (y * CELL_HEIGHT) as i32;
            let rect = rect::Rect::new(xpos, ypos, CELL_WIDTH as u32, CELL_HEIGHT as u32);
            let cell = &map.get_cell(x as i32, y as i32).unwrap();

            canvas.set_draw_color(cell.get_fill_color());
            canvas.fill_rect(rect).unwrap();
            canvas.set_draw_color(CELL_BORDER_COLOR);
            canvas.draw_rect(rect)
                  .expect(&format!("couldn't draw line: ({},{}) -> ({},{})",
                                   0, y, SDL2_WIN_WIDTH, y));
        }
    }

    // updates the screen with changes since the last call
    canvas.present();
}
/// Renders the cells and other elements into the SDL2 window
Renders the cells and other elements into the SDL2 window
Renders the cells and other elements into the SDL2 window
pub fn render(canvas: &mut render::WindowCanvas, map: &mut Map)
{
    canvas.set_draw_color(Color::RGB(0, 0, 0));
    canvas.clear();
    for x in 0..CELLS_PER_ROW {
        let xpos = (x * CELL_HEIGHT) as i32;
        for y in 0..CELLS_PER_COL {
            let ypos = (y * CELL_HEIGHT) as i32;
            let rect = rect::Rect::new(xpos, ypos, CELL_WIDTH as u32, CELL_HEIGHT as u32);
            let cell = &map.get_cell(x as i32, y as i32).unwrap();
            canvas.set_draw_color(cell.get_fill_color());
            canvas.fill_rect(rect).unwrap();
            canvas.set_draw_color(CELL_BORDER_COLOR);
            canvas.draw_rect(rect)
                  .expect(&format!("couldn't draw line: ({},{}) -> ({},{})",
                                   0, y, SDL2_WIN_WIDTH, y));
        }
    }
    // updates the screen with changes since the last call
    canvas.present();
}
pub fn render ( canvas : & mut render :: WindowCanvas , map : & mut Map ) { canvas . set_draw_color ( Color :: RGB ( 0 , 0 , 0 ) ) ; canvas . clear ( ) ; for x in 0 .. CELLS_PER_ROW { let xpos = ( x * CELL_HEIGHT ) as i32 ; for y in 0 .. CELLS_PER_COL { let ypos = ( y * CELL_HEIGHT ) as i32 ; let rect = rect :: Rect :: new ( xpos , ypos , CELL_WIDTH as u32 , CELL_HEIGHT as u32 ) ; let cell = & map . get_cell ( x as i32 , y as i32 ) . unwrap ( ) ; canvas . set_draw_color ( cell . get_fill_color ( ) ) ; canvas . fill_rect ( rect ) . unwrap ( ) ; canvas . set_draw_color ( CELL_BORDER_COLOR ) ; canvas . draw_rect ( rect ) . expect ( & format ! ( " " 0 y SDL2_WIN_WIDTH y ) ) ; } } // updates the screen with changes since the last call canvas . present ( ) ; }
Renders the cells and other elements into the SDL2 window
Renders the cells and other elements into the SDL2 window
canvas
&mut render::WindowCanvas
map
&mut Map
canvas
&mut render::WindowCanvas
map
&mut Map