Pong's CPU updated, But, don't know if it is impossible to beat. I haven't beat it yet

This commit is contained in:
Justin 2018-12-23 22:04:10 -05:00
parent bca879db94
commit 8f34b3a0c7

View file

@ -47,16 +47,27 @@ namespace ShiftOS.Main.Apps
ball.Top -= (int)ballY; ball.Top -= (int)ballY;
ball.Left -= (int)ballX; ball.Left -= (int)ballX;
cpuPaddle.Top += speed;
if (cpuPaddle.Top < 0 || cpuPaddle.Top > this.Height) speed = -speed;
//CPU
if (ballX < 0)
{
if (ball.Top < cpuPaddle.Top + 51)
{
cpuPaddle.Top -= 5;
}
if(ball.Top > cpuPaddle.Top + 51)
{
cpuPaddle.Top += 5;
}
}
if (ball.Left < 0) if (ball.Left < 0)
{ {
ResetToRest(); ResetToRest();
ballX = -ballX; ballX = -ballX;
} }
if (ball.Left + ball.Width > this.Height) if (ball.Left + ball.Width > this.Width)
{ {
ResetToRest(); ResetToRest();
ballX = -ballX; ballX = -ballX;