Added some special settings.
This commit is contained in:
parent
d5caa29017
commit
19210b0032
1 changed files with 14 additions and 9 deletions
|
@ -15,6 +15,8 @@ def true_false_random():
|
||||||
class Settings:
|
class Settings:
|
||||||
fps: int = 60
|
fps: int = 60
|
||||||
window_size: tuple = (1000, 600)
|
window_size: tuple = (1000, 600)
|
||||||
|
slipperiness_left: int = 1
|
||||||
|
slipperiness_right: int = 1
|
||||||
|
|
||||||
|
|
||||||
class FallingSandParticle:
|
class FallingSandParticle:
|
||||||
|
@ -32,7 +34,7 @@ class FallingSandParticle:
|
||||||
old_pos = self.pos
|
old_pos = self.pos
|
||||||
ox, oy = old_pos
|
ox, oy = old_pos
|
||||||
|
|
||||||
if oy >= self.app.sand_surface.get_height() - 2:
|
if oy >= self.app.sand_surface.get_height() - self.app.max_height:
|
||||||
self.app.falling_sand_particles.remove(self)
|
self.app.falling_sand_particles.remove(self)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -42,24 +44,24 @@ class FallingSandParticle:
|
||||||
y += 1
|
y += 1
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
self.app.matrix[ox - 1, oy + 2] == self.app.sand_surface.map_rgb(self.app.gray)
|
self.app.matrix[ox - 1, oy + self.app.slipperiness_left] == self.app.sand_surface.map_rgb(self.app.gray)
|
||||||
and self.app.matrix[ox + 1, oy + 2] == self.app.sand_surface.map_rgb(self.app.gray)
|
and self.app.matrix[ox + 1, oy + self.app.slipperiness_right] == self.app.sand_surface.map_rgb(self.app.gray)
|
||||||
): # when the sand can slide in two directions
|
): # when the sand can slide in two directions
|
||||||
if true_false_random():
|
if true_false_random():
|
||||||
x -= 1
|
x -= 1
|
||||||
y += 2
|
y += self.app.slipperiness_left
|
||||||
|
|
||||||
else:
|
else:
|
||||||
x += 1
|
x += 1
|
||||||
y += 2
|
y += self.app.slipperiness_right
|
||||||
|
|
||||||
elif self.app.matrix[ox - 1, oy + 2] == self.app.sand_surface.map_rgb(self.app.gray): # can only slide left
|
elif self.app.matrix[ox - 1, oy + self.app.slipperiness_left] == self.app.sand_surface.map_rgb(self.app.gray): # can only slide left
|
||||||
x -= 1
|
x -= 1
|
||||||
y += 2
|
y += self.app.slipperiness_left
|
||||||
|
|
||||||
elif self.app.matrix[ox + 1, oy + 2] == self.app.sand_surface.map_rgb(self.app.gray): # can only slide right
|
elif self.app.matrix[ox + 1, oy + self.app.slipperiness_right] == self.app.sand_surface.map_rgb(self.app.gray): # can only slide right
|
||||||
x += 1
|
x += 1
|
||||||
y += 2
|
y += self.app.slipperiness_right
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if self.not_moving == 32: # counter that increases when the particle is inactive and if it is 32,
|
if self.not_moving == 32: # counter that increases when the particle is inactive and if it is 32,
|
||||||
|
@ -105,6 +107,9 @@ class FallingSand:
|
||||||
setattr(self.settings, "save", lambda: save_dataclass_json(self.settings, "settings.json"))
|
setattr(self.settings, "save", lambda: save_dataclass_json(self.settings, "settings.json"))
|
||||||
|
|
||||||
self.fps = self.settings.fps
|
self.fps = self.settings.fps
|
||||||
|
self.slipperiness_left = self.settings.slipperiness_left
|
||||||
|
self.slipperiness_right = self.settings.slipperiness_right
|
||||||
|
self.max_height = self.slipperiness_left if self.slipperiness_left > self.slipperiness_right else self.slipperiness_right
|
||||||
self.falling_sand_particles = []
|
self.falling_sand_particles = []
|
||||||
self.rainbow_data = [[255, 40, 40], 0] # color calculation stuff
|
self.rainbow_data = [[255, 40, 40], 0] # color calculation stuff
|
||||||
self.rainbow_steps = [(1, True), (0, False), (2, True), (1, False), (0, True), (2, False)]
|
self.rainbow_steps = [(1, True), (0, False), (2, True), (1, False), (0, True), (2, False)]
|
||||||
|
|
Loading…
Reference in a new issue