I am having trouble with my int missed I can’t get it to work like I want it to count as a missed as soon as it touches the line before the scoreboard and every time missed plus one the score would decrease by one. If anyone can help that would be great
This is what I got so far.
PImage p;
int missed = 0;
int hits = 0;
int score = 0;
int y = 25;
int x = (int)random(25,475);
void setup(){
p = loadImage("projectBackground.png");
size(500,700);
background(255);
}
void draw(){
background(p);
fill(#DFF218);
ellipse(x,y,50,50);
y+=5;
if(y >= height){
y = 25;
x = (int)random(25,475);}
fill(0);
textSize(25);
textAlign(CENTER);
text("Score= " + score, 100,650);
text("Missed= " + missed, 250,650);
text("Hits= " + hits, 400,650);
if(y > 575){
y = 25;
x = (int)random(25,475);
}
}
void mousePressed() {
if( dist(mouseX, mouseY, x, y) < 25 ){
hits++;
score++;
y = 25;
x = (int)random(25,475);
}
if(y > 575){
y = 25;
}
if(hits == 0){
missed++;
}
}
void keyPressed(){
if(key == 'r'){
loop();
}
if(key == 's'){
noLoop();
}
}