Fixed da stuubid crashes.

This commit is contained in:
The Wobbler 2024-07-15 19:59:10 +02:00
parent aba7f137fb
commit 871fb02521

12
falling_sand.py Normal file → Executable file
View file

@ -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):