Receiving error but cannot debug: ArrayIndexOutOfBoundsException

int currentScreen;
int col = 10;
int row = 100;
int speed;
mark[][] mymark = new mark[col][row];

PImage img;
PImage img0;
PImage img1;
PImage img2;
PImage img3;

import processing.sound.*;
SoundFile file, file2;

boolean screen1bool = false;

void setup() {
  size (1000, 683);
  //noStroke();
  //smooth();

  img = loadImage ("batman.jpeg");
  img0 = loadImage ("joker.jpg");
  img0.resize(1000, 683);

  img1 = loadImage("jolaugh.jpg");
  img1.resize(1000, 683);
  img1.loadPixels();
      for (int x = 0; x < img1.width; x++ ) {
        for (int y = 0; y < img1.height; y++ ) {

          int loc = x + y*img1.width;

          float r = red  (img1.pixels[loc]);
          float g = green(img1.pixels[loc]);
          float b = blue (img1.pixels[loc]);

          //float adjustBrightness = map(mouseX, 0, width, 0, 8); 
          ////r *= adjustBrightness;
          ////g *= adjustBrightness;
          ////b *= adjustBrightness;

          color c = color(r, g, b);
          if (y > mouseY)
            c = color(200, random(60, 100), r, 0);
          if (x > mouseX/2)
            c = color(random(0, 150), b, 50, 0);
          if (x > mouseX)
            c = color(r/2+60, b*1.5, g/2+50, 0);

          r = constrain(r, 0, 255); 
          g = constrain(g, 0, 255);
          b = constrain(b, 0, 255);

          //noStroke();
          //fill(c);
          //ellipse(x,y,10,10);

          img1.pixels[loc] = c;
        }
        img1.updatePixels();
      image(img1, 0, 0);
      if (!file.isPlaying()) {
      file.play();
    } else {

    img0.resize(1000, 683);
    image(img0, 0, 0);
  }
      }

  img2 = loadImage("riddler.jpeg");
  img2.resize(1000, 683);

  img3 = loadImage("rid.png");
  img3.resize(20, 40);

  file = new SoundFile(this, "jlaugh.mp3");
  file2 = new SoundFile(this, "rmt.mp3");

  for (int i=0; i<col; i++) {
    for (int j=0; j<row; j++) {
      mymark[i][j] = new mark(color(random(255)), i*40, j*8, random(1, 5));
    }
  }
}


void draw() {

  switch (currentScreen) {

  case 1: 
    keyPressedOne(); 
    break;

  case 2: 
    keyReleasedOne(); 
    break;

  case 3: 
    keyReleasedTwo(); 
    break;

  default: 
    image(img, 0, 0); 
    break;
  }

  fill(255); 
  text(currentScreen, width-23, 23);
}

void mousePressed() {
  currentScreen++;
  if (currentScreen > 3) {
    currentScreen = 0;
  }
}

void keyPressedOne() {
  if (keyPressed) {
    if (key == '1') {
      int x = int(random(img.width));
      int y = int(random(img.height));
      noStroke();
      fill(img.get(mouseX, mouseY), 128);
      rect(mouseX, mouseY, 10, 10);
      x+= int (random(-speed, speed));
      y += int (random(-speed, speed));
      color c = img.get(x, y);
      fill(c, 50);
      ellipse(x, y, 20, 20);
    }
  } else {
    background (200);
  }
}

void keyReleasedOne() {

  if (keyPressed) {
    if (key == '2') {
      screen1bool = !screen1bool;
    }
}
}

void keyReleasedTwo() {
  if (keyPressed) {
    if ( key == '3') {
      //background(img2);
      ////blend(img3, 0, 0, 33, 100, 67, 0, 33, 100, ADD);
      ////blend(img3, 0, 0, 33, 100, 67, 0, 33, 100, ADD);

      //int i = 1;
      //while (i < 100) {
      //  image(img3, i*10, i*5);
      //    i = i + 20;


      background(255);
      for (int i=0; i<col; i++) {
        for (int j=0; j<row; j++) {
          mymark[i][j].move();
          mymark[i][j].display();
        }
      }
    } 
    if (!file2.isPlaying()) {
      file2.play();
    }
  } else {
    image(img2, 0, 0);
  }
}

it stopped responding after adding to setup()

1 Like