I know hardly anything about processing and have no background in computer programming on a purely logic level so forgive me if my questions seem elementary.
I am trying to understand the syntax and grammar of functions. I don't know where I am going wrong here though.
It is supposed to draw three balls that change color and move when the mouse is clicked... But I also wouldl like them to stop when the keyboard is pressed.
So far I can't even get the first part to show. I get an error message that reads 'expecting LPAREN'
Any help?
CODE:
int speed =0;
void setup(){
size(800,600);
background(0);
smooth();
//int r = (int)random (0,600);
}
void draw()
{
if mousePressed() {
background(0);
ball_2(0,(int)random (0,100));
ball_2(0,(int)random (0,50));
ball_2(0,(int)random (0,25));
speed = 1;
}
}
else keyPressed (){
speed = 0;
}
void ball_2(int xpos, int ypos){
ellipse(xpos,ypos,100,100);
fill ((int)random (100,200),(int)random (100,200),(int)random (100,200));
}
I am trying to understand the syntax and grammar of functions. I don't know where I am going wrong here though.
It is supposed to draw three balls that change color and move when the mouse is clicked... But I also wouldl like them to stop when the keyboard is pressed.
So far I can't even get the first part to show. I get an error message that reads 'expecting LPAREN'
Any help?
CODE:
int speed =0;
void setup(){
size(800,600);
background(0);
smooth();
//int r = (int)random (0,600);
}
void draw()
{
if mousePressed() {
background(0);
ball_2(0,(int)random (0,100));
ball_2(0,(int)random (0,50));
ball_2(0,(int)random (0,25));
speed = 1;
}
}
else keyPressed (){
speed = 0;
}
void ball_2(int xpos, int ypos){
ellipse(xpos,ypos,100,100);
fill ((int)random (100,200),(int)random (100,200),(int)random (100,200));
}
1