- #1
shivajikobardan
- 674
- 54
- TL;DR Summary
- HTML5 canvas javascript
JavaScript:
function checkBoundaryCollision() {
if (x - ballRadius <= 0 || x + ballRadius >= canvasWidth) {
dx = -dx;
}
if (y - ballRadius <= 0 || y + ballRadius >= canvasHeight) {
dy = -dy;
}
}
Full code here: