Ping Pong Game (Need Helping Adjusting AI Move)
Need help with the Computer hitting the ball back
8 Replies
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
Please, prefer $paste
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!
You can make the AI move slower (slower paddle speed), or add randomness to it's "thinking".
where in the code can i adjust the speed
under MoveComputerPaddle()
pcbComp.Left -= (int)dblSpeed;
is that suppose to slow it down?
wherever the movement code is
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