HTML and CSS Reference
In-Depth Information
ball2 = new Ball(20),
ball0_dragging = false,
ball1_dragging = false,
ball2_dragging = false,
spring = 0.03,
friction = 0.9,
springLength = 100,
vx = 0,
vy = 0;
ball0.x = Math.random() * canvas.width;
ball0.y = Math.random() * canvas.height;
ball1.x = Math.random() * canvas.width;
ball1.y = Math.random() * canvas.height;
ball2.x = Math.random() * canvas.width;
ball2.y = Math.random() * canvas.height;
canvas.addEventListener('mousedown', function () {
if (utils.containsPoint(ball0.getBounds(), mouse.x, mouse.y)) {
ball0_dragging = true;
}
if (utils.containsPoint(ball1.getBounds(), mouse.x, mouse.y)) {
ball1_dragging = true;
}
if (utils.containsPoint(ball2.getBounds(), mouse.x, mouse.y)) {
ball2_dragging = true;
}
}, false);
canvas.addEventListener('mouseup', function () {
if (ball0_dragging || ball1_dragging || ball2_dragging ) {
ball0_dragging = false;
ball1_dragging = false;
ball2_dragging = false;
}
}, false);
canvas.addEventListener('mousemove', function () {
if (ball0_dragging) {
ball0.x = mouse.x;
ball0.y = mouse.y;
}
if (ball1_dragging) {
ball1.x = mouse.x;
ball1.y = mouse.y;
}
if (ball2_dragging) {
ball2.x = mouse.x;
ball2.y = mouse.y;
}
}, false);
function springTo (ballA, ballB) {
Search WWH ::




Custom Search