Beispiel #1
0
 def make_alive(self, xPos, yPos, particle_type):
     ''' this makes a cell alive once we clicked it'''
     if particle_type[0] == 1:
         self.grid[xPos][yPos] = particles.Ground(xPos, yPos)
     else:
         self.grid[xPos][yPos] = particles.Water(xPos, yPos, 1)
     return None
Beispiel #2
0
 def _go_up(self, x,  y, grid):
     if grid[x - 1][y].id != 2:
         grid[x - 1][y] = particles.Water(x - 1, y)
     self.flow = grid[x][y].mass - self._get_stable(grid[x][y].mass + grid[x - 1][y].mass)
     if self.flow > self.MINFLOW:
         self.flow *= 0.6
     self.flow = self.constrain(self.flow, 0, grid[x][y].mass)
     grid[x][y].mass -= self.flow
     grid[x - 1][y].mass += self.flow
     return None
Beispiel #3
0
 def _go_left(self, x,  y, grid):        
     if grid[x][y - 1].id != 2: # if the cell is not water
         grid[x][y - 1] = particles.Water(x, y - 1)
     self.flow = (grid[x][y].mass - grid[x][y - 1].mass) / 4
     if self.flow > self.MINFLOW:
         self.flow *= 0.6
     self.flow = self.constrain(self.flow, 0, grid[x][y].mass)
     grid[x][y].mass -= self.flow
     grid[x][y - 1].mass += self.flow
     return None
Beispiel #4
0
 def _go_right(self, x,  y, grid):
     if grid[x][y + 1].id != 2:
         grid[x][y + 1] = particles.Water(x, y + 1)
     self.flow = (grid[x][y].mass - grid[x][y + 1].mass) / 4
     if self.flow > self.MINFLOW:
         self.flow *= 0.6
     self.flow = self.constrain(self.flow, 0, grid[x][y].mass)
     grid[x][y].mass -= self.flow
     grid[x][y + 1].mass += self.flow
     return None
Beispiel #5
0
 def _go_down(self, x,  y, grid):            
         if grid[x + 1][y].id != 2: # if the cell is not water
             grid[x + 1][y] = particles.Water(x + 1, y)
         self.flow = self._get_stable(grid[x][y].mass + grid[x + 1][y].mass) - grid[x + 1][y].mass
         if self.flow > self.MINFLOW:
             self.flow *= 0.6
         self.flow = self.constrain(self.flow, 0, min(self.MAXSPEED, grid[x][y].mass))
         grid[x][y].mass -= self.flow
         grid[x + 1][y].mass += self.flow
         return None