@@ -258,7 +258,7 @@ <h5 id="message"></h5>
258
258
return distance <= r + R ;
259
259
}
260
260
261
- // Update game state
261
+ // Update game state, keybroad controls
262
262
function update ( ) {
263
263
// Move paddles
264
264
// Move right paddle up down based on "ArrowUp" and "ArrowDown" keys
@@ -550,7 +550,7 @@ <h5 id="message"></h5>
550
550
if ( touchYstartLeft !== null ) {
551
551
let distYLeft = mouseY - touchYstartLeft ;
552
552
leftPaddleY = previousYPositionLeft + distYLeft ;
553
- leftPaddleY = Math . max ( 0 , Math . min ( canvas . height - paddleHeight , leftPaddleY ) ) ;
553
+ leftPaddleY = Math . max ( 0 + paddleHeight / 2 , Math . min ( canvas . height - paddleHeight / 2 , leftPaddleY ) ) ;
554
554
let distXLeft = mouseX - touchXstartLeft ;
555
555
leftPaddleX = previousXPositionLeft + distXLeft ;
556
556
leftPaddleX = Math . max ( 0 , Math . min ( canvas . width / 2 , leftPaddleX ) ) ;
@@ -559,7 +559,7 @@ <h5 id="message"></h5>
559
559
if ( touchYstartRight !== null ) {
560
560
let distYRight = mouseY - touchYstartRight ;
561
561
rightPaddleY = previousYPositionRight + distYRight ;
562
- rightPaddleY = Math . max ( 0 , Math . min ( canvas . height - paddleHeight , rightPaddleY ) ) ;
562
+ rightPaddleY = Math . max ( 0 + paddleHeight / 2 , Math . min ( canvas . height - paddleHeight / 2 , rightPaddleY ) ) ;
563
563
let distXRight = mouseX - touchXstartRight ;
564
564
rightPaddleX = previousXPositionRight + distXRight ;
565
565
rightPaddleX = Math . min ( canvas . width , Math . max ( canvas . width / 2 , rightPaddleX ) ) ;
0 commit comments