C
C#7mo ago
Nate

Ping Pong Game (Need Helping Adjusting AI Move)

Need help with the Computer hitting the ball back
8 Replies
Nate
NateOP7mo ago
Nate
NateOP7mo ago
the computer paddle always hits the ball back making no possibility for the player to win how can i make it so the computer paddle doesn't always hit the ball so the player can have a fair chance of winning
Buddy
Buddy7mo ago
Please, prefer $paste
MODiX
MODiX7mo ago
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
Buddy
Buddy7mo ago
You can make the AI move slower (slower paddle speed), or add randomness to it's "thinking".
Nate
NateOP7mo ago
where in the code can i adjust the speed under MoveComputerPaddle() pcbComp.Left -= (int)dblSpeed; is that suppose to slow it down?
Buddy
Buddy7mo ago
wherever the movement code is
Nate
NateOP7mo ago
private void MoveComputerPaddle() { // Moves the computer paddle position to align with the ball if (pcbComp.Left + (pcbComp.Width / 2) < pcbBall.Left) { pcbComp.Left += (int)dblSpeed/1; } else if (pcbComp.Left + (pcbComp.Width / 2) > pcbBall.Left) { pcbComp.Left -= (int)dblSpeed/1; } } here is what i have for the computer paddle
Want results from more Discord servers?
Add your server