From de3c3da845443880d8e87d56e47e77c9b5019e79 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Mon, 21 Dec 2020 23:34:51 +0100 Subject: Burn rows Signed-off-by: Olivier Gayot --- cameltris.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cameltris.py b/cameltris.py index 60f8aee..1246b4e 100755 --- a/cameltris.py +++ b/cameltris.py @@ -175,6 +175,18 @@ def generate_piece(): return (piece, [initial_y_position, initial_x_position]) +def burn_rows(): + rows_to_burn = list() + + for row in grid: + if all(map(lambda element: element is not None, row)): + rows_to_burn.append(row) + + for row in rows_to_burn: + grid.insert(0, [None for _ in range(10)]) + grid.remove(row) + + def stick_piece(): global current_piece, current_piece_position @@ -184,6 +196,7 @@ def stick_piece(): continue grid[row_id + current_piece_position[0]][col_id + current_piece_position[1]] = element + burn_rows() current_piece, current_piece_position = generate_piece() pygame.init() -- cgit v1.2.3