fn make_snake(len: i32, width: i32, height: i32, dir: &Direction) -> LinkedList<Block> {
        let mut body: LinkedList<Block> = LinkedList::new();

        let mut rnd = thread_rng();
        let start_x = rnd.gen_range(len + 2, width - 3);
        let start_y = rnd.gen_range(len + 2, height - 3);

        for i in 0..len {
            match dir {
                Direction::UP => {
                    body.push_back(Block {
                        x: start_x,
                        y: start_y + i,
                    });
                }
                Direction::DOWN => {
                    body.push_back(Block {
                        x: start_x,
                        y: start_y - i,
                    });
                }
                Direction::LEFT => {
                    body.push_back(Block {
                        x: start_x + i,
                        y: start_y,
                    });
                }
                Direction::RIGHT => {
                    body.push_back(Block {
                        x: start_x - i,
                        y: start_y,
                    });
                }
            }
        }

        body
    }
/// Create random position based on length, board size, and direction
Create random position based on length, board size, and direction
Create random position based on length board size and direction
fn make_snake(len: i32, width: i32, height: i32, dir: &Direction) -> LinkedList<Block> {
        let mut body: LinkedList<Block> = LinkedList::new();
        let mut rnd = thread_rng();
        let start_x = rnd.gen_range(len + 2, width - 3);
        let start_y = rnd.gen_range(len + 2, height - 3);
        for i in 0..len {
            match dir {
                Direction::UP => {
                    body.push_back(Block {
                        x: start_x,
                        y: start_y + i,
                    });
                }
                Direction::DOWN => {
                    body.push_back(Block {
                        x: start_x,
                        y: start_y - i,
                    });
                }
                Direction::LEFT => {
                    body.push_back(Block {
                        x: start_x + i,
                        y: start_y,
                    });
                }
                Direction::RIGHT => {
                    body.push_back(Block {
                        x: start_x - i,
                        y: start_y,
                    });
                }
            }
        }
        body
    }
fn make_snake ( len : i32 , width : i32 , height : i32 , dir : & Direction ) -> LinkedList < Block > { let mut body : LinkedList < Block > = LinkedList :: new ( ) ; let mut rnd = thread_rng ( ) ; let start_x = rnd . gen_range ( len + 2 , width - 3 ) ; let start_y = rnd . gen_range ( len + 2 , height - 3 ) ; for i in 0 .. len { match dir { Direction :: UP => { body . push_back ( Block { x : start_x , y : start_y + i , } ) ; } Direction :: DOWN => { body . push_back ( Block { x : start_x , y : start_y - i , } ) ; } Direction :: LEFT => { body . push_back ( Block { x : start_x + i , y : start_y , } ) ; } Direction :: RIGHT => { body . push_back ( Block { x : start_x - i , y : start_y , } ) ; } } } body }
Create random position based on length, board size, and direction
Create random position based on length board size and direction
len
i32
width
i32
height
i32
dir
&Direction
len
i32
width
i32
height
i32
dir
&Direction