expecting RCURLY, found 'else'
in
Programming Questions
•
1 year ago
I'm getting the error "expecting RCURLY, found 'else'" and I can't figure out why. I've been using Processing for about a week so excuse the silly errors I'm sure there are.
class Ball{
float xpos, ypos;
color myColor;
boolean placed = false;
Ball(color tempcolor){
myColor=tempcolor;
}
}
void display(){
if(placed){
makeBall(xpos, ypos);
} else {
makeBall(mouseX, mouseY);
}
}
void makeBall(float tempxpos, float tempypos){
xpos=tempxpos;
ypos=tempypos;
fill(#ffffff);
ellipse(xpos,ypos,50,50);
}
Ball ball1 = new Ball(#ffffff);
Ball ball2 = new Ball(#000000);
int clickCounter=0;
void setup(){
background(#009900);
size(600,400);
}
void draw(){
background(#009900);
ball1.display();
if(clickCounter>0){
ball1.placed=true;
ball2.display();
}
if(clickCounter>1);
ball2.placed=true;
}
void mousePressed(){
println("mousePressed");
clickCounter++;
dif x = (ball1.x-ball2.x)/speed;
dif y = (ball1.y-ball2.y)/speed;
float localdist = dist(ball1.x,ball1.y,ball2.x,ball2.y);
if (localdist > diam || clicked == false); {
ball1.x = ball1.x - dif.x;
ball.y = ball1.x - dif.y;
}else{
clicked = true;
}
if(clicked){
ball2.x = ball2.x-dif.x;
ball2.y = ball2.y-dif.y;
}
}
class Ball{
float xpos, ypos;
color myColor;
boolean placed = false;
Ball(color tempcolor){
myColor=tempcolor;
}
}
void display(){
if(placed){
makeBall(xpos, ypos);
} else {
makeBall(mouseX, mouseY);
}
}
void makeBall(float tempxpos, float tempypos){
xpos=tempxpos;
ypos=tempypos;
fill(#ffffff);
ellipse(xpos,ypos,50,50);
}
Ball ball1 = new Ball(#ffffff);
Ball ball2 = new Ball(#000000);
int clickCounter=0;
void setup(){
background(#009900);
size(600,400);
}
void draw(){
background(#009900);
ball1.display();
if(clickCounter>0){
ball1.placed=true;
ball2.display();
}
if(clickCounter>1);
ball2.placed=true;
}
void mousePressed(){
println("mousePressed");
clickCounter++;
dif x = (ball1.x-ball2.x)/speed;
dif y = (ball1.y-ball2.y)/speed;
float localdist = dist(ball1.x,ball1.y,ball2.x,ball2.y);
if (localdist > diam || clicked == false); {
ball1.x = ball1.x - dif.x;
ball.y = ball1.x - dif.y;
}else{
clicked = true;
}
if(clicked){
ball2.x = ball2.x-dif.x;
ball2.y = ball2.y-dif.y;
}
}
1