Error message?
in
Programming Questions
•
1 year ago
So I am extremely new to Processing, as in I've been working in it for a week now and am having some issues.
I'm currently writing a very basic program that will eventually be a very simple billiards type game(a green background and when clicked a ball appears, the second time another ball appears and on the third click the first ball hits the second off the screen). However I am having a hard time getting it to work. I keep getting "unexpected token:void" when I try to render. I have checked and rechecked for different simple mistakes and I'm still unsure of my problem. Here is what I have written so far:
class Ball{
float xpos, ypos;
boolean placed;
Ball(){
}
}
void display(){
if(placed==true){
makeBall(xpos, ypos);
}
else{
makeBall(mouseX, mouseY);
}
}
void makeBall(float thisX,float thisY){
fill(#FFFFFF);
ellipse(thisX, thisY, 50, 50);
}
Ball ball1= new Ball();
Ball ball2= new Ball();
int clickCounter=0;
void setup() {
size (400, 600);
background (#009900);
}
void draw() {
background (#009900);
ball1.display();
if (clickCounter>0) {
ball2.display();
}
}
void mousePressed() {
println("the mouse was pressed");
}
void mouseReleased() {
clickCounter++;
if (clickCounter==1){
ball1.placed=true;
ball1.xpose=mouseX;
ball1.ypos=mouseY;
}
else if (clickCounter==2){
ball2.placed=true;
ball2.xpos=mouseX;
ball2.ypos=mouseY;
}
void keyPressed(){
if (key=='c'){
println("clear");
clickCounter=0;
}
}
1