Initially I was trying to pull out the pixels of an image and draw circles using the color of that pixel when the mouse is at that position. It worked, then I tried to create an array of 6 images so every time when I press the right arrow key, it shifts to the next image and do the same thing to the new image. But this loop is not working(I highlighted this part). I tried printing out the boolean "next", which controls the shifting of images. The boolean value is right, but the loop it controls is not working. Can anybody help me? I have my code below.
PImage actress;
PImage rose;
PImage cake;
PImage phantom;
PImage rabbit;
PImage rain;
int s=600, minSize = 2;
int steps = 5;
boolean next;
boolean previous;
boolean shft;
boolean imp;
int curimage = 0;
PImage image1;
PImage iarray[];
dot mom;
void setup() {
size(s,s);
iarray = new PImage[6];
actress = loadImage("actress.jpg");
iarray[0]=actress;
rose = loadImage("rose.jpg");
iarray[1]=rose;
cake = loadImage("cake.png");
iarray[2]=cake;
phantom = loadImage("phantom of the opera.png");
iarray[3]=phantom;
rabbit = loadImage ("rabbit.png");
iarray[4]=rabbit;
rain = loadImage("raindrops on window.jpg");
iarray[5]=rain;
image1=iarray[curimage];
//image1.resize(s,s);
smooth(); noStroke();
mom = new dot(s/2,s/2,s,s/2,s/2,s);
}
void draw(){
updateImage();
mom.draw();
}
void updateImage() {
background(0);
println(next);
if(next=true){
if (curimage<5) {
curimage=curimage++;
}
else if (curimage==5){
curimage=0; }
next=false;
fill(0);
rect(0,0,600,600);
}}
void mouseMoved() {
mom.interact();
}
class dot {
boolean alife = true;
int x0, y0, d0, x, y, d;
color c0, c;
float t;
dot[] kids;
dot(int _x0, int _y0, int _d0, int _x, int _y, int _d) {
x0=_x0; y0=_y0; d0=_d0; x=_x; y=_y; d =_d;
c = iarray[curimage].get(x,y); c0 = iarray[curimage].get(x0,y0);