Fixed da stuubid crashes.
This commit is contained in:
parent
aba7f137fb
commit
871fb02521
1 changed files with 7 additions and 5 deletions
12
falling_sand.py
Normal file → Executable file
12
falling_sand.py
Normal file → Executable file
|
@ -25,6 +25,7 @@ class FallingSandParticle:
|
||||||
self.not_moving = 0
|
self.not_moving = 0
|
||||||
|
|
||||||
x, y = start_pos
|
x, y = start_pos
|
||||||
|
|
||||||
self.app.matrix[x, y] = self.color
|
self.app.matrix[x, y] = self.color
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
@ -79,12 +80,13 @@ class FallingSandParticle:
|
||||||
|
|
||||||
return
|
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[ox, oy] = self.app.gray
|
||||||
self.app.matrix[x, y] = self.color
|
self.app.matrix[x, y] = self.color
|
||||||
|
|
||||||
|
|
||||||
class FallingSand:
|
class FallingSand:
|
||||||
|
@ -206,7 +208,7 @@ class FallingSand:
|
||||||
bx += ax
|
bx += ax
|
||||||
by += ay
|
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))
|
self.falling_sand_particles.append(FallingSandParticle(self, (bx, by), color))
|
||||||
|
|
||||||
def rainbow(self):
|
def rainbow(self):
|
||||||
|
|
Loading…
Reference in a new issue