moving a boucing ball with sound
              in 
             Contributed Library Questions 
              •  
              2 years ago    
            
 
           
             Hello, I am learning processing,
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
              
             
             
              
             
             
              
             
             
               
             
             
               
             
             
               
             
             
               
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
               
             
             
              
             
             
              
             
              
           
 
            
           
             I found some nice tuts, on 
             http://www.ecole-art-aix.fr/rubrique81.html (in french, no english version, sorry)
            
            
             I am trying to mix two tuts:
            
            
             one is a bouncing ball, 
             http://www.ecole-art-aix.fr/article342.html 
            
            
             and the other one using a ESS library > 
             http://www.ecole-art-aix.fr/article409.html 
            
            
             so having a boucing ball, ok can do
            
            
             moving a ball with the sound, ok no problems
            
            
             having a boucing ball using the sound , not OK at all, my ball do not bounce anymore.
            
            
             This is my (ugly) code:
            
            
             if anyone can help me.......
            
            
              int deplacementX, deplacementY; 
             
             
              int x, y; 
             
             
              float a = 400;
             
             
              import krister.Ess.*;
             
             
              AudioInput entree_son;
             
             
              FFT analyse_son;
             
             
              void setup() {
             
             
               Ess.start(this);
             
             
               entree_son=new AudioInput();
             
             
               analyse_son=new FFT();
             
             
               entree_son.start();
             
             
               size(400,400);
             
             
               noStroke();
             
             
               x = 0;
             
             
               y = 0;             
             
             
               deplacementX = 0;
             
             
               deplacementY = 0;   
             
             
              }
             
             
              void draw() {
             
             
               nettoyer();
             
             
               bouger();
             
             
               rebondir();
             
             
               dessiner();
             
             
              }
             
             
              void nettoyer(){
             
             
                background(255);
             
             
              }
             
             
              void rebondir() {
             
             
               if ( (x > width && deplacementX > 0) || (x < 0 && deplacementX < 0) ) {
             
             
                 deplacementX = -deplacementX;
             
             
               }
             
             
               if ( (y > width && deplacementY > 0) || (y < 0 && deplacementY < 0) ) { 
             
             
                 deplacementY = -deplacementY;
             
             
               }
             
             
              }
             
             
              void bouger() {
             
             
               float niveau = analyse_son.getLevel(entree_son) * 100;
             
             
               a += niveau;
             
             
               a = a % 400;
             
             
               x = (int) a + deplacementX;
             
             
               y = (int) a + deplacementY;
             
             
              }
             
             
              void dessiner() {
             
             
               fill(80,120,120);
             
             
               ellipse(x,y,10,10);
             
             
              }
             
             
              
              1  
            
 
            