Hello, I’m doing a game and I’m new to Processing, I’ve done this,I’ve been looking for videos, in forums and nothing, I’m having problems in the score, every time I give it where it has to add +1, it adds much more.
PImage pentagon;
PImage triangle;
PImage sis;
PImage cinc;
PImage quatre;
PImage tres;
PImage rectangle;
int state;
int points;
boolean pCount = true;
void setup() {
size(400, 600);
background(255);
quatre = loadImage("RECTAANGULO.png");
tres = loadImage("TRIAANGULO.png");
rectangle = loadImage("RECTANGLE.png");
sis = loadImage("HEXAAGONO.png");
cinc = loadImage("PENTAAGONO.png");
triangle = loadImage("TRIÀNGLE.png");
pentagon = loadImage("PENTÀGON.png");
}
void draw(){
fill(0);
textSize(20);
text("puntuacion:" + points , 20, 550);
if (state == 0) {
image(rectangle,30,100);
image(tres,200,220);
image(quatre,0,220);
if((mousePressed)&&(mouseX > 20 && mouseX < 190) && (mouseY > 150 && mouseY < 300)){
++points;
}
}
if (state == 1) {
image(pentagon,50,100);
image(cinc,200,220);
image(sis, 0, 220);
if((mousePressed)&&(mouseX > 20 && mouseX < 190) && (mouseY > 150 && mouseY < 300)){
++points;
}
}
if (state == 2) {
image(triangle,30,100);
image(tres,200,220);
image(cinc,0,220);
if((mousePressed)&&(mouseX > 20 && mouseX < 190) && (mouseY > 150 && mouseY < 300)){
++points;
}
}
if (state == 3) {
image(rectangle,30,100);
image(sis,200,220);
image(quatre,0,220);
if((mousePressed)&&(mouseX > 20 && mouseX < 190) && (mouseY > 150 && mouseY < 300)){
++points;
}
}
}
void mouseClicked() {
state++;
if(state == 4){
state = 0;
}
}