Labs

var ball = {
  x: 300,
  y: 200,
  r: 15,
  vx: 0,
  vy: 0,
  elasticity: .5
};
 
// ...
 
ball.x += ball.vx;
ball.y += ball.vy;
 
ball.vx *= .99;
ball.vy *= .99;
 
ball.vy += .25;
 
if (ball.y + ball.r > canvas.height) {
  ball.y = canvas.height - ball.r;
  ball.vy = -Math.abs(ball.vy);
  ball.vy *= ball.elasticy;
}