diff --git a/mdn-breakout/index.html b/mdn-breakout/index.html index ec0c943..4efb584 100644 --- a/mdn-breakout/index.html +++ b/mdn-breakout/index.html @@ -37,7 +37,7 @@ canvas { background: #eee; display: block; margin: 0 auto; } for(c=0; c canvas.width-ballRadius || x + dx < ballRadius) { dx = -dx; @@ -142,6 +146,21 @@ canvas { background: #eee; display: block; margin: 0 auto; } } } + function collisionDetection() { + for(c=0; c b.x && x < b.x+brickWidth && y > b.y && y < b.y+brickHeight) { + dy = -dy; + b.status = 0; + } + } + } + } + document.addEventListener("keydown", keyDownHandler, false); document.addEventListener("keyup", keyUpHandler, false); setInterval(draw, 10);