diff --git a/frontend/src/pages/Games/PongAi.js b/frontend/src/pages/Games/PongAi.js index d9d2f789b..dbf2c3903 100644 --- a/frontend/src/pages/Games/PongAi.js +++ b/frontend/src/pages/Games/PongAi.js @@ -12,6 +12,8 @@ import handleResize from "../../components/game/HandleResize"; const GameCanvas = (aiDifficulty) => { // Default Parameters const defaultSpeedX = 300; + const playerSpeedIncrease = 0.5; + let playerSpeed = 5; let resize = true; const winScore = 10; const defaultSpeedY = 20; @@ -198,7 +200,10 @@ const GameCanvas = (aiDifficulty) => { ballX = canvas.width - paddleWidth - 10; ballSpeedX *= -1; if (ballSpeedX < 0) ballSpeedX -= ballSpeedIncrease; - else ballSpeedX += ballSpeedIncrease; + else { + ballSpeedX += ballSpeedIncrease; + playerSpeed += playerSpeedIncrease; + } ballSpeedY += distanceFromCenter * ballAngleOffset * @@ -210,6 +215,7 @@ const GameCanvas = (aiDifficulty) => { ballSpeedX = defaultSpeedX; ballSpeedY = defaultSpeedY; scoreRight += 1; + playerSpeed = 5; setScoreRight(scoreRight); } else if (ballX - ballSize * 3 > canvas.width) { ballX = canvas.width / 2; @@ -217,11 +223,11 @@ const GameCanvas = (aiDifficulty) => { ballSpeedX = -defaultSpeedX; ballSpeedY = -defaultSpeedY; scoreLeft += 1; + playerSpeed = 5; setScoreLeft(scoreLeft); } }; - const playerSpeed = 10; let keys = {}; const movePaddle = () => {