I'm having a bit of a problem with this code (I'm newby at this) PLEASE HELP!!!!
              in 
             Programming Questions 
              •  
              2 years ago    
            
 
           
             Hey, I started using Processing a coupple of months ago and I have a coupple of silly quiestions... well I made this code for some visuals for a concert... but I can't make the balls collide with each other.. can anyone please please please... tell me how to do it. I used sonia and the balls answer to the sound level.... now I need to make them bounce with each other... thanx!!! Heres the code:
            
             
            
            
             
              
             
             
              
             
             
              
             
             
              
             
             
                
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
                  
             
             
                
             
             
              
             
             
              
             
             
              
             
             
                  
             
             
           
 
            
           
              import pitaru.sonia_v2_9.*;
             
             
              int cuantas = 600;
             
             
              Pelota[]
             
             
              Pelotas = new Pelota[cuantas];
             
             
              void setup(){
             
             
                size(1280,800);
             
             
                for(int i=0;i<cuantas;i++){
             
             
                  Pelotas[i]= new Pelota(random(160+15),random(120+15),random(3)+0.2,random(3)+0.2,random(10)+2,random(200)+56);
             
             
                }
             
             
              Sonia.start(this);
             
             
                LiveInput.start();
             
             
              }  
             
             
              class Pelota{
             
             
                float x,y,vx,vy,t,c;
             
             
                Pelota(float xin, float yin, float vxin, float vyin, float tin, float cin){
             
             
                  x=xin;
             
             
                  y=yin;
             
             
                  vx=vxin;
             
             
                  vy=vyin;
             
             
                  t=tin;
             
             
                  c=cin;
             
             
                }
             
             
              void mueve(){
             
             
                if(x<=0||x>=width) vx*=-1;x+=vx/2;
             
             
                if(y<=0 || y>=height) vy*=-1; y+=vy/2;
             
             
              }
             
             
              void dibuja(){
             
             
                float level = LiveInput.getLevel();
             
             
                smooth();
             
             
                noStroke();
             
             
                fill(0,c,random(255));
             
             
                ellipse(x,y,level*100,level*100);
             
             
              }
             
             
              void dibujaroja(){
             
             
                float level = LiveInput.getLevel();
             
             
                smooth();
             
             
                noStroke();
             
             
                fill(255,0,0);
             
             
                ellipse(x,y,level*100,level*100);
             
             
              }
             
             
              }
             
             
              void draw(){
             
             
                fill(0);
             
             
                rect(0,0,width,height);
             
             
                for(int i=0;i<cuantas;i++){
             
             
                    if(i==50){
             
             
                  Pelotas[i].mueve();
             
             
                  Pelotas[i].dibujaroja();}
             
             
                  else{
             
             
                  Pelotas[i].mueve();
             
             
                  Pelotas[i].dibuja();}
             
             
                }
             
             
              }
             
             
              public void stop(){
             
             
                Sonia.stop();
             
             
                super.stop();
             
             
              }
             
              
              
              1  
            
 
            