diff options
author | curly <curlybryce@protonmail.com> | 2022-08-18 13:57:29 -0600 |
---|---|---|
committer | curly <curlybryce@protonmail.com> | 2022-08-18 13:57:29 -0600 |
commit | 63b2ed39a56ffe6ea7a9d4fc3942cb3dce9f668a (patch) | |
tree | 1a791b7cbb028208e4bc2370dc1fa62f717d54b8 /src/tetris.rs | |
parent | 05ae9cd13fee07e7653e3d616e812ccedba8f1b9 (diff) | |
download | tetris-63b2ed39a56ffe6ea7a9d4fc3942cb3dce9f668a.tar.gz tetris-63b2ed39a56ffe6ea7a9d4fc3942cb3dce9f668a.tar.bz2 tetris-63b2ed39a56ffe6ea7a9d4fc3942cb3dce9f668a.zip |
much better
Diffstat (limited to 'src/tetris.rs')
-rw-r--r-- | src/tetris.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tetris.rs b/src/tetris.rs index c28a4b9..af0f579 100644 --- a/src/tetris.rs +++ b/src/tetris.rs @@ -28,9 +28,10 @@ impl Tetris { // Check each row of the grid // If one is full, remove it and drop // the rest of the grid down - pub fn check_lines(&mut self) { + pub fn check_lines(&mut self) -> u8 { // While there are full lines, continue to iterate let mut row = 19; + let mut total = 0; while row > 0 { let mut c = 0; for x in self.grid.get(row as usize).expect("Out of bounds") { @@ -45,11 +46,13 @@ impl Tetris { if c == 10 { self.grid.remove(row as usize); self.grid.insert(0, vec![0; 10]); + total += 1; continue; } row -= 1; } + return total } pub fn get_grid_pos(&self, pos: piece::Pos) -> i8 { |