Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
samuelmorocho
samuelmorocho's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Help with syntax error please!
[1 Reply]
07-May-2011 11:45 PM
Forum:
Programming Questions
Hi, im doing this type of, but i keep getting syntax errors and cant find what it is.
Thanks for any help.
int num_balls = 50;
boolean[] color_change;
int[] xpos;
int[] ypos;
int[] xspeeds;
int[] yspeeds;
void setup(){
size(900,800);
xpos = new int[num_balls];
ypos = new int[num_balls];
xspeeds = new int[num_balls];
yspeeds = new int[num_balls];
for(int i = 0 ; i < num_balls; i++){
xpos[i] = (int)random(0, width);
ypos[i] = (int)random(0,200);
xspeeds[i] = (int)random(12,13);
yspeeds[i] = (int)random(12,13);
color_change[i] = false;
}
}
void draw(){
background(0);
if (mousePressed==true)
{stroke(255,0,0);
line(mouseX,565,mouseX,0);}
else{stroke(0);
if(mouseX>xpos[i]-10&&mouseX<xpos[i]+10){
color_change[i]=true;
}
if(color_change[i]) {
fill(0) ;
} else {
fill(255);
}
}
noStroke();
for(int i = 0 ; i < num_balls; i++){
xpos[i] = xpos[i] + xspeeds[i];
ypos[i] = ypos[i] + yspeeds[i];
if( xpos[i] > width || xpos[i] < 0){
xspeeds[i] = xspeeds[i]* -1;
}
if( ypos[i] > 200|| ypos[i] < 0){
yspeeds[i] = yspeeds[i]* -1;
}
ellipse(xpos[i], ypos[i], 30,30);
}
triangle(mouseX-8, 580, mouseX+8, 580, mouseX, 565);
}
«Prev
Next »
Moderate user : samuelmorocho
Forum