def delCell(self, event): cellWidth, cellHeight = self.config.attr.game.cell.size x, y = int(event.posx)/cellWidth, int(event.posy)/cellHeight if self.game.habitat.delCell(x, y): self.cellStates[x][y] = 0 cellSprite = CellSprite(self.screen) cellSprite.remove((x, y)) pygame.display.flip() self.trigger(CellRemovedEvent())
def updateCells(self): cellSprite = CellSprite(self.screen) for i in range(self.game.habitat.gridSize[0]): for j in range(self.game.habitat.gridSize[1]): #If a cell is setted to keeps alive if self.cellStates[i][j] > 1: self.cellStates[i][j] -= 1 self.game.habitat.grid[i][j] = 1 if self.game.habitat.grid[i][j]: if not self.cellStates[i][j]: self.cellStates[i][j] = 1 cellSprite.put((i, j)) elif self.cellStates[i][j]: self.cellStates[i][j] = 0 cellSprite.remove((i, j))