question using functions on this program
in
Programming Questions
•
10 months ago
Hi,
I hope someone can help me understand functions. I am learning programming processing and I have a project that I been working on. In the end I hope to use minim to put in an mp3 file as this animation plays. For now I am having trouble understanding how functions work. I have been following the book but seem to have hit a rut. here is the code that I want to use functions on:
int rMax= int(random(90,100));
int gMax= int(random(60,95));
int bMax= int(random(100,110));
int aMax= int(random(80,90));
int r = int(random(rMax));
int g = int(random(gMax));
int b = int(random(bMax));
int a = int(random(aMax));
int circleX = int(random(425,475));
int circleY = int(random(100));
int circleSize=0;
int count=0;
int count2=0;
void setup(){
background(200);
size(900,700);
stroke(180);
smooth();
frameRate(40);
}
void draw(){
count=count+1;
count2=count2+1;
fill(r,g,b,a);
if (count<600){
ellipse(random(0,width), random(0,height), random(width/6),random(0,height/6));
loop();
}
if (count>435){
ellipseMode(CENTER);
fill(200,200,200,7);
ellipse(circleX,circleY,circleSize,circleSize);
circleSize=circleSize+4;
}
if(count>650){
fill(rMax,gMax,bMax,aMax);
ellipse(random(0,width), random(0,height), random(width/7),random(0,height/7));
//return(color());
loop();
}
if(count>900){
fill(r,g,b,aMax);
ellipse(random(0,width), random(0,height), random(width/7),random(0,height/7));
//return(color());
loop();
}
if(count>1100){
fill(r,g,b,a);
ellipse(random(0,width), random(0,height), random(width/7),random(0,height/7));
//return(color());
loop();
}
if (count>1700){
ellipseMode(CENTER);
fill(200,200,200,7);
ellipse(circleX,600,circleSize,circleSize);
circleSize=circleSize+4;
}
if(count>1900){
fill(r,g,b,a);
ellipse(random(0,width), random(0,height), random(width/7),random(0,height/7));
//return(color());
loop();
}
if(count>2100){
fill(r,g,b,a);
ellipse(random(0,width), random(0,height), random(width/7),random(0,height/7));
//return(color());
loop();
}
if(circleSize>(height*5)){
circleSize=0;
}
if (count==2350){
count=0;
}
//println(circleSize);
println(count);
println(count2);
}
Once I understand how functions work I hope to make this into an object oriented program. Finally I would want to use minim to put in an mp3 file to start simultaneously.
Thanks so much for your help... This finals will be the death of me without you lol
I hope someone can help me understand functions. I am learning programming processing and I have a project that I been working on. In the end I hope to use minim to put in an mp3 file as this animation plays. For now I am having trouble understanding how functions work. I have been following the book but seem to have hit a rut. here is the code that I want to use functions on:
int rMax= int(random(90,100));
int gMax= int(random(60,95));
int bMax= int(random(100,110));
int aMax= int(random(80,90));
int r = int(random(rMax));
int g = int(random(gMax));
int b = int(random(bMax));
int a = int(random(aMax));
int circleX = int(random(425,475));
int circleY = int(random(100));
int circleSize=0;
int count=0;
int count2=0;
void setup(){
background(200);
size(900,700);
stroke(180);
smooth();
frameRate(40);
}
void draw(){
count=count+1;
count2=count2+1;
fill(r,g,b,a);
if (count<600){
ellipse(random(0,width), random(0,height), random(width/6),random(0,height/6));
loop();
}
if (count>435){
ellipseMode(CENTER);
fill(200,200,200,7);
ellipse(circleX,circleY,circleSize,circleSize);
circleSize=circleSize+4;
}
if(count>650){
fill(rMax,gMax,bMax,aMax);
ellipse(random(0,width), random(0,height), random(width/7),random(0,height/7));
//return(color());
loop();
}
if(count>900){
fill(r,g,b,aMax);
ellipse(random(0,width), random(0,height), random(width/7),random(0,height/7));
//return(color());
loop();
}
if(count>1100){
fill(r,g,b,a);
ellipse(random(0,width), random(0,height), random(width/7),random(0,height/7));
//return(color());
loop();
}
if (count>1700){
ellipseMode(CENTER);
fill(200,200,200,7);
ellipse(circleX,600,circleSize,circleSize);
circleSize=circleSize+4;
}
if(count>1900){
fill(r,g,b,a);
ellipse(random(0,width), random(0,height), random(width/7),random(0,height/7));
//return(color());
loop();
}
if(count>2100){
fill(r,g,b,a);
ellipse(random(0,width), random(0,height), random(width/7),random(0,height/7));
//return(color());
loop();
}
if(circleSize>(height*5)){
circleSize=0;
}
if (count==2350){
count=0;
}
//println(circleSize);
println(count);
println(count2);
}
Once I understand how functions work I hope to make this into an object oriented program. Finally I would want to use minim to put in an mp3 file to start simultaneously.
Thanks so much for your help... This finals will be the death of me without you lol
1