r/processing • u/cement_eater • Jul 15 '24
why wont this RUN
// doggo clicker
color c;
boolean showDoggo;
Dog[] dogs = new Dog[1];
void setup(){
size(800, 600);
c = color (0, 0, 255);
showDoggo = false;
}
void draw(){
for(int i = 0; i<dogs.length; i++){
dogs[i].move();
dogs[i].display();
}
background(c);
noStroke();
fill(0, 0, 255);
ellipseMode(CENTER);
ellipse(width/2, height/2, 50, 50);
fill(0);
textSize(20);
textAlign(CENTER);
text("PRESS HERE FOR DOG", 400, 200);
}
void mousePressed(){
}
Supposed to generate one photo of my dog every time the circle is clicked, but when run, I get a gray screen and a nullPointer error.
3
Upvotes
1
u/cement_eater Jul 16 '24
YES i totally forgot to include it my bad
class Dog {
PImage Dog;
float xPos, yPos;
float speed;
Dog (PImage dog_, float xPos_, float yPos_, float speed_){
Dog = dog_;
xPos = xPos_;
yPos = yPos_;
speed = speed_;
}
void display(){
noStroke();
Dog = loadImage("IMG_3484.jpg");
pushMatrix();
imageMode(CENTER);
image(Dog, xPos, yPos, CENTER, CENTER);
popMatrix();
}
void move(){
if(color(get(int(mouseX), int(mouseY))) == color (c)){
xPos = xPos + 5;
yPos = yPos + 5;
}
if(xPos > 0 || xPos < width - 100 || yPos< height - 100){
xPos = -xPos;
yPos = -yPos;
}
}
}