mouseClicked() Method isn't called


#1
int cellCount = 100;
int bombCount = 20;
Grid grid;

void setup() {
  size(1000, 1000);
  background(255);

  grid = new Grid((int)Math.sqrt(cellCount), (int)Math.sqrt(cellCount), bombCount);
  grid.showGrid();  
  grid.cellsSetNeighbours();
}

void mouseClicked() {
  if (mouseButton == LEFT) {
      if (grid.discoverCell(mouseX/cellCount, mouseY/cellCount)) {
        fill(0);
        textSize(50);
        textAlign(CENTER);
        text("You stupid motherf*cker lost", width/2, height/2);
        grid.discoverAllCells();
      }
    }else if(mouseButton == RIGHT){
      grid.markCell(mouseX/cellCount, mouseY/cellCount);
    }
}

Whenever I click anywhere on the screen, nothing happens :frowning:


#2

I am pretty sure you need a void draw() for the sketch to keep running.

You could also try debugging by adding println() as the first line in mouseClicked, and the first line in the if statements. This gives you an idea of how far through your code it gets.


#3

I added the draw() Method an it worked!

Thanks a lot :slight_smile: