From 5d9b94900bc6909d7aa6489b951a6b89f40e3ed7 Mon Sep 17 00:00:00 2001
From: Joshua Saxby <Joshua2.Saxby@live.uwe.ac.uk>
Date: Sun, 9 Feb 2020 21:20:28 +0000
Subject: [PATCH] Fixed another oversight in collision-detection code

---
 source/main.cpp | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/source/main.cpp b/source/main.cpp
index 10355d1..6bed254 100755
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -287,7 +287,7 @@ bool can_shape_move(
                 }
                 // if Y is negative, we don't need to check this row
                 if (destination.y < 0) {
-                    break; // no point checking this row, out of screen
+                    continue; // no point checking this pixel, out of screen
                 }
                 // check if the translated position of this pixel is not free
                 if (stacked.getPixelValue(destination.x, destination.y) != 0) {
@@ -389,12 +389,13 @@ void start_new_game() {
         Point origin(1, -3);
         // this is the down unit-vector
         Vector down(0, 1);
-        // draw the scene
-        UBIT.display.print(stacked_shapes);
-        // draw Block with transparency enabled on clear image pixels
-        UBIT.display.print(block.image(), origin.x, origin.y, 1);
-        // while Block can go down
+        // if Block can go down
         if (can_shape_move(block, origin, stacked_shapes, down)) {
+            /*
+             * this is the Block scrolling down loop
+             * its exit condition is not checked on every iteration but at a
+             * fixed time interval (every time the Block is meant to go down)
+             */
             while (true) {
                 // allow player to shift the Block left or right
                 /*
@@ -426,6 +427,7 @@ void start_new_game() {
                         if (can_shape_move(block, origin, stacked_shapes, down)) {
                             origin = origin + down;
                         } else {
+                            // if we can't shift it down, then it's time to stop
                             break;
                         }
                         // update the "stopwatch"
-- 
GitLab