MDN breakout step 5
This commit is contained in:
parent
50cd7f411f
commit
27d3f538ed
@ -66,10 +66,21 @@ canvas { background: #eee; display: block; margin: 0 auto; }
|
||||
dx = -dx;
|
||||
ballColor = randColor();
|
||||
}
|
||||
if(y + dy > canvas.height-ballRadius || y + dy < ballRadius) {
|
||||
if(y + dy < ballRadius) {
|
||||
dy = -dy;
|
||||
ballColor = randColor();
|
||||
}
|
||||
else if(y + dy > canvas.height-ballRadius) {
|
||||
if(x > paddleX && x < paddleX + paddleWidth) {
|
||||
dy = -dy;
|
||||
dx *= 1.01;
|
||||
dy *= 1.01;
|
||||
}
|
||||
else {
|
||||
alert("GAME OVER");
|
||||
document.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
if(rightPressed && paddleX < canvas.width-paddleWidth) {
|
||||
paddleX += paddleSpeed;
|
||||
|
Loading…
Reference in New Issue
Block a user