A snake game in rust with well-structed code.
The game is mainly controlled by struct Game , and based on struct Block.
struct Game {
snake: snake::Snake,
food: food::Food,
background: background::BackGround,
}
struct Snake {
body: VecDeque<Block>,
direction: Direction,
add_len: bool,
}
struct Food {
f: Block,
}
struct Block {
x: usize,
y: usize,
}
struct BackGround {
map: [[Block; WIDTH]; HEIGHT],
}