class Ball {
float x;
float y;
float n;
float m;
float b= width-800;
float c = height-800;
PImage img1;
color colorFromMousePosition = get(mouseX, mouseY);
//float a;
Ball () {
float n = constrain (b, width, width-800);
float m = constrain (c, height, height-800);
x = random(n);
y = random (m);
}
void display() {
if (mousePressed==false) {
noStroke();
fill (230, 0, 0);
ellipse (x, y, 12, 12);
} else {
noStroke();
fill (230, 0, 0);
ellipse (mouseX, mouseY, 12, 12);
}
}
void boundary () {
if (brightness(colorFromMousePosition) == 255) {
ellipse (mouseX, mouseY, 12, 12);
} else {
ellipse (x-1,y-1,12,12);
}
}
}
This time I post only the Class ball. I hvae a problem, in the variables of the class I put " color colorFromMousePosition = get(mouseX, mouseY); " and then in the function I creat a void boundary but if I run the code is shown the “NullPointerException”……… Also in the last else I don’t think so the x and y of the elllipse are good to stop the movement… Have you got any other input?? I’m stuck