Avoid a infinite loop when scrolling is involved
authorNeil <neil@dip.sun.ac.za>
Sat, 20 Apr 2013 10:22:14 +0000 (12:22 +0200)
committerNeil <neil@dip.sun.ac.za>
Sat, 20 Apr 2013 10:22:14 +0000 (12:22 +0200)
erdslangetjie/__main__.py

index 8071d303de802105fa12e429579315a02ff163bc..e408ac8204851dcb0ee40209e4a7c5adea5ab8be 100644 (file)
@@ -126,15 +126,28 @@ class GameWindow(RelativeLayout):
                 if true_point[0] >= self.view.size[0]:
                     self.view.scroll_x += self.x_scroll_margin
                     true_point = self.to_parent(*check_point)
+                    # Avoid an infinite loop that can happen we
+                    # changing screens
+                    if self.view.scroll_x > 0.99:
+                        return
                 elif true_point[0] < 0:
                     self.view.scroll_x -= self.x_scroll_margin
                     true_point = self.to_parent(*check_point)
+                    # See above
+                    if self.view.scroll_x < 0.01:
+                        return
                 elif true_point[1] >= self.view.size[1]:
                     self.view.scroll_y += self.y_scroll_margin
                     true_point = self.to_parent(*check_point)
+                    # See above
+                    if self.view.scroll_y > 0.99:
+                        return
                 elif true_point[1] < 0:
                     self.view.scroll_y -= self.y_scroll_margin
                     true_point = self.to_parent(*check_point)
+                    # See above
+                    if self.view.scroll_y < 0.01:
+                        return
 
     def included(self, point, margin):
         if point[0] < margin: