Get audio file at random when the ball boucing around

Viewed 26

Hi, can you check? Sorry for the nub question, but I checked and still don't know what I did wrong, it says I am missing operator, semicolon or } at line 26 near "draw". But I swear to god I checked and still can't find anything.. please help me thank you very much, my code is below.

//bounce noise tab
import processing.sound.*;
SoundFile bounce;
ArrayList<SoundFile> sounds = new ArrayList<SoundFile>();

Ball[] bouncingBalls = new Ball[10];

void setup(){
  size(500,500);
  background(50);
  
  for (int i = 0; i < 100; i++) {
   SoundFile sound = new SoundFile (this, "poz.wav", "guita.wav", "guitaa.wav");
   sound.amp(0.5);
   sounds.add(sound);
}

  
  // create all the boucning balls
 for (int i = 0; i < bouncingBalls.length; i++){
  bouncingBalls[i] = new Ball();
  // bounce = new SoundFile(this,"poz.wav");
  // bounce.amp (0.5);
// }
  

void draw(){
  background (137,207,240);
 // for each ball, display and move 
  for (Ball b: bouncingBalls);
     b.move();
  b.display();
  //if (this.x < 0 || this.x > width) {
   //this.velX = this.velX * -1;
   // play a random sound from the list
   //int index = (int)random(sounds.size());
  // sounds.get(index).play();
  
  }
}
}

// Ball Tab

class Ball {
  float x,y,velX, velY;
  
  Ball(){
    // random stating position
  this.x = random(0, width);
  this.y = random(0, height);
  // random velcity
  this.velX = random(-10,10);
  this.velY = random(-10,10);
  
  }
  // ball displays itself
  void display() {
    ellipse(this.x, this.y, 20,20);
  }
  //ball changes its position
  void move(){
    this.x = this.x + this.velX;
        this.y = this.y + this.velY;
        
        //ball bouncing off the sides
        if (this.x < 0 || this.x > width){
          this.velX = this.velX * -1;
        }
        // ball baouncing off the yop to and bottom
        if (this.x < 0 || this.x > width) {
   this.velX = this.velX * -1;
   // play a random sound from the list
   int index = (int)random(sounds.size());
   sounds.get(index).play();
        }
  }
}

I don't know why i cant i see the problem

0 Answers
Related