Unexpected token
in
Programming Questions
•
11 months ago
I am getting an unexpected token: void error for line 72:
void mousePressed() {
and I can't figure out why! I'm not missing any semicolons and I don't have any extra or missing curly braces. It's a super simple program, I'm sure the problem will be obvious to anyone with more experience than me
boolean mouseInRed;
boolean redOn = false;
boolean mouseInGreen;
boolean greenOn = false;
boolean mouseInBlue;
boolean blueOn = false;
void setup() {
size(500, 500);
rectMode(CORNERS);
}
void draw() {
if (redOn) {
background(255, 0, 0);
}
else {
background(0);
}
if (greenOn) {
background(0, 255, 0);
}
else {
background(0);
if (blueOn) {
background(0, 0, 255);
}
else {
background(0);
}
fill(255, 0, 0);
stroke(175);
strokeWeight(12);
rect(50, 200, 150, 300);
if (redOn) {
noFill();
stroke(0);
strokeWeight(2);
rect(50, 200, 150, 300);
}
fill(0, 255, 0);
stroke(175);
strokeWeight(12);
rect(200, 200, 300, 300);
if (greenOn) {
noFill();
stroke(0);
strokeWeight(2);
rect(200, 200, 300, 300);
}
fill(0, 0, 255);
stroke(175);
strokeWeight(12);
rect(350, 200, 450, 300);
if (blueOn) {
noFill();
stroke(0);
strokeWeight(2);
rect(350, 200, 450, 300);
}
void mousePressed() {
mouseInRed = (mouseX > 50) && (mouseX < 150)
&& (mouseY > 200) && (mouseY < 300);
if (mouseInRed) redOn = !redOn;
mouseInGreen = (mouseX > 200) && (mouseX < 300)
&& (mouseY > 200) && (mouseY < 300);
if (mouseInGreen) greenOn = !greenOn;
mouseInBlue = (mouseX > 350) && (mouseX < 450)
&& (mouseY > 200) && (mouseY < 300);
if (mouseInBlue) blueOn = !blueOn;
}
1