@@ -14,21 +14,18 @@ def draw(self, window):
14
14
self .grid .draw (window )
15
15
self .draw_brush (window )
16
16
17
-
18
17
def add_particle (self , row , column ):
19
18
if self .mode == "sand" :
20
- # 50% chance to add a sand particle
21
- if random .random () < 0.2 : # 50% probability
19
+ if random .random () < 0.2 :
22
20
particle = SandParticle
23
21
self .grid .add_particle (row , column , particle )
24
22
elif self .mode == "rock" :
25
- # Always add a rock particle
26
23
particle = RockParticle
27
24
self .grid .add_particle (row , column , particle )
28
25
29
26
def update (self ):
30
27
orientation = random .randint (0 , 1 )
31
- for row in range (self .grid .rows - 1 , - 1 , - 1 ): # Start from the bottom
28
+ for row in range (self .grid .rows - 1 , - 1 , - 1 ):
32
29
if orientation == 0 :
33
30
for column in range (self .grid .columns - 1 , - 1 , - 1 ):
34
31
self .process_particle (row , column )
@@ -92,11 +89,9 @@ def apply_brush(self, row, column):
92
89
self .add_particle (current_row , current_col )
93
90
94
91
def draw_brush (self , window ):
95
-
96
92
mouse_pos = pygame .mouse .get_pos ()
97
93
column = mouse_pos [0 ] // self .cell_size
98
94
row = mouse_pos [1 ] // self .cell_size
99
-
100
95
cursor_size = self .brush_size * self .cell_size
101
96
color = (255 , 255 , 255 )
102
97
@@ -107,8 +102,4 @@ def draw_brush(self, window):
107
102
elif self .mode == "erase" :
108
103
color = (255 , 105 , 180 )
109
104
110
- pygame .draw .rect (
111
- window ,
112
- color ,
113
- (column * self .cell_size , row * self .cell_size , cursor_size , cursor_size ),
114
- )
105
+ pygame .draw .rect (window , color , (column * self .cell_size , row * self .cell_size , cursor_size , cursor_size ))
0 commit comments