The bounciness will be a
number between zero and one. Zero indicates no bounciness. One indicates perfect bounciness, of the sort we never see in the real world.
But how to make the ball behave according to the bounciness?
Turns out it's really easy. At the moment we're making a bounce happen by doing this:
this.velocity_y= -this.velocity_y; // bounce off the bottom
All we do is
multiply by our bounciness factor:
this.velocity_y= -this.velocity_y * this.bounciness; // bounce off the bottom
If bounciness is one, it will behave as before. If it's zero, it won't bounce at all. If it's 0.5, it'll rebound to half the starting height. Now the vertical bouncing is behaving more realistically, but there's obviously a problem with the horizontal behaviour.