From e91837cea6b5fc3982d4875de98ff166e9932b5b Mon Sep 17 00:00:00 2001 From: Joshua Saxby <Joshua2.Saxby@live.uwe.ac.uk> Date: Mon, 10 Feb 2020 03:49:27 +0000 Subject: [PATCH] Fixed bugs where top row would not clear on cascade or be checked for cascades --- source/main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index e424d71..06e6f94 100755 --- a/source/main.cpp +++ b/source/main.cpp @@ -533,7 +533,10 @@ int eliminate_rows(MicroBitImage& stacked_shapes) { stacked_shapes.setPixelValue(x, above + 1, value); } } - // FIXME: we don't clear the top row, but we should! + // clear the top row, the manual shift down didn't clear it + for (int x = 0; x < 5; x++) { + stacked_shapes.setPixelValue(x, 0, 0); + } } } else { /* @@ -546,7 +549,16 @@ int eliminate_rows(MicroBitImage& stacked_shapes) { row--; } } while (row > 0); - // FIXME: we don't check if the top row can be eliminated, but we should! + /* + * these checks left out the top row, so manually check it now as a special + * case as the clearing behaviour for it is different + */ + if (is_row_contiquous(stacked_shapes, 0)) { + eliminated++; + for (int x = 0; x < 5; x++) { + stacked_shapes.setPixelValue(x, 0, 0); + } + } // return the number of eliminated rows return eliminated; } -- GitLab