class Ball { float r; float m; float x; float y; float vx; float vy=10; color colore; Ball() { r = 15; m = r; x = random(r,width-r); y = random(r,height/2); vx = 5; colore = color(0); } void bounce() { float xSfera=x; float xPaddle=xpos; float scarto=-xPaddle+xSfera; float forzaMassima=15; if ((x + vx <= xpos + radius/2) && (x + vx >= xpos - radius/2) && (y + vy >= height-15-r)) { y = height - r; //aggiustameto per non sforare vx =vx+((forzaMassima/100)*scarto); vy *= -b; LiveInput.startRecLoop(mySampleObj, mySampleObj.getCurrentFrame()); } if ( y + vy + r > height ) { mySampleObj.play(); reset(); } if ( y + vy - r < 0 ) { y = r; vy *= -b; LiveInput.stopRec(mySampleObj); } if ( x + vx + r > width ) { x = width - r; vx *= -b; vy *= f; } if ( x + vx - r < 0 ) { x = r; vx *= -b; vy *= f; } } void move() { x += vx; y += vy; } void display() { fill(colore); ellipse(x,y,2*r,2*r); } }