Using HTML5 canvas where would be the best place to start to move my 3 balls in random trajectories (along a smooth line, no jumping) and when they hit each other bounce away and then go on another path, until again they hit each other and again bounce away.
So far I have set up a simple example on jsfiddle where each ball follows its own path (though they do disappear off the screen).
At the moment the trajectory is as simple as
function animate(){
// Yellow Circle
circles[0].x+=1;
circles[0].y+=-1.5;
// Blue Cirlce
circles[1].x+=-1;
circles[1].y+=-1.5;
// Red Circle
circles[2].x+=1;
circles[2].y+=-1;
draw();
}
I would love to see an example, but also to know what methods and calculations I should be looking at.