title: Random bouncing ball
body: <p>I found some answers in internet which explain how to make a ball bouncing, but some of them don't helped me (because bounces are not random), and some are very difficult (my knowledge in physics are limited).</p>
  
  <p><strong>Problem</strong> : I have a ball which move and bounce, but not randomly, and I want to make this ball bouncing randomly.</p>
  
  <p>I already have this piece of code :</p>
  
  <pre><code>Public Class Ball{
  
      /** Coordinates */
      private int x, y;
  
      /** Speed of the ball*/
      private int speedX, speedY;
  
      public Ball(int x, int y, int speedX, int speedY) {
          this.x = x ;
          this.y = y ;
          this.speedX = speedX;
          this.speedY = speedY;
      }
  
      public void moveAndBounce() {
          x += speedX ;
          y += speedY ;
  
          // Assuming that touchWallHorizontal() and touchWallHorizontal() work
          if (touchHorizontalWall()) {
              speedX = -speedX ;
          }
          if (touchVerticalWall()) {
              speedY = -speedY ;
          }
      }
  
      public static void main (String [] args){
          Ball ball = new Ball(); // Initialisation
          while (true){
              ball.moveAndBounce() ;
          }
      }
  }
  </code></pre>
  
  <p>It works perfectly, but the ball movement is always the same (a rectangle).</p>
  
  <p><strong>Question</strong> : is there a way to have a random bouncing without add attributes to the ball (just with coordinates and speed) ? </p>
  
  <p>And if not, is there not too difficult solution to resolve this problem ?</p>
  
  <p>Thanks in advance !</p>