From: Neil Date: Sat, 20 Apr 2013 10:22:14 +0000 (+0200) Subject: Avoid a infinite loop when scrolling is involved X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=f05ea56092899055d0c96e8f3a2eb7a1c74b5c84;p=erdslangetjie.git Avoid a infinite loop when scrolling is involved --- diff --git a/erdslangetjie/__main__.py b/erdslangetjie/__main__.py index 8071d30..e408ac8 100644 --- a/erdslangetjie/__main__.py +++ b/erdslangetjie/__main__.py @@ -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: