Ok, we can now move all the tetrimino and generate them. Two mechanisms are still missing: checking lines to see whether one can be sent (that is, removed since complete) and making a tetrimino permanent (that is, not movable anymore).
Let's start with the line check:
fn check_lines(&mut self) { let mut y = 0; while y < self.game_map.len() { let mut complete = true; for x in &self.game_map[y] { if *x == 0 { complete = false; break } } if complete == true { self.game_map.remove(y); y -= 1; // increase the number of self.lines } y += 1; } while self.game_map.len() < 16 { self.game_map.insert(0, vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); } }
For now, I didn't add the score, lines sent counting, nor level handling but ...