diff --git a/falling_sand.py b/falling_sand.py old mode 100644 new mode 100755 index d883e8d..676e291 --- a/falling_sand.py +++ b/falling_sand.py @@ -25,6 +25,7 @@ class FallingSandParticle: self.not_moving = 0 x, y = start_pos + self.app.matrix[x, y] = self.color def update(self): @@ -79,12 +80,13 @@ class FallingSandParticle: return - self.not_moving = 0 + if not x > self.app.sand_surface.get_width() - 2:# and not x < 0: + self.not_moving = 0 - self.pos = (x, y) + self.pos = (x, y) - self.app.matrix[ox, oy] = self.app.gray - self.app.matrix[x, y] = self.color + self.app.matrix[ox, oy] = self.app.gray + self.app.matrix[x, y] = self.color class FallingSand: @@ -206,7 +208,7 @@ class FallingSand: bx += ax by += ay - if self.matrix[bx, by] == self.sand_surface.map_rgb(self.gray) and bx % 2 == 0 and by % 2 == 0: + if not bx > self.sand_surface.get_width() - 2 and self.matrix[bx, by] == self.sand_surface.map_rgb(self.gray) and bx % 2 == 0 and by % 2 == 0: self.falling_sand_particles.append(FallingSandParticle(self, (bx, by), color)) def rainbow(self):