diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2020-12-21 23:34:51 +0100 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2020-12-21 23:34:51 +0100 |
commit | de3c3da845443880d8e87d56e47e77c9b5019e79 (patch) | |
tree | 5432e5168e5049a959ad4bc46fa9d0fb6a5ba198 | |
parent | 3ca5ab7806b36393244bf42edabf42f4e28fecfa (diff) |
Burn rows
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
-rwxr-xr-x | cameltris.py | 13 |
1 files changed, 13 insertions, 0 deletions
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() |