January 2018
Beginner to intermediate
454 pages
10h 8m
English
This type will be the one holding all the game's information:
Let's write down this type:
struct Tetris { game_map: Vec<Vec<u8>>, current_level: u32, score: u32, nb_lines: u32, current_piece: Option<Tetrimino>, }
Once again, pretty simple. I don't think any additional information is required so let's continue!
Let's start by writing the new method for this new type:
impl Tetris { fn new() -> Tetris { let mut game_map = Vec::new(); for _ in 0..16 { game_map.push(vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); } Tetris { game_map: game_map, current_level: 1, score: 0, nb_lines: ...
Read now
Unlock full access