From 8f34b3a0c7118abb81526a3dc5f435ba8f8485f8 Mon Sep 17 00:00:00 2001 From: Justin Date: Sun, 23 Dec 2018 22:04:10 -0500 Subject: [PATCH] Pong's CPU updated, But, don't know if it is impossible to beat. I haven't beat it yet --- ShiftOS.Main/Apps/Pong.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ShiftOS.Main/Apps/Pong.cs b/ShiftOS.Main/Apps/Pong.cs index aa0c792..cde3c31 100644 --- a/ShiftOS.Main/Apps/Pong.cs +++ b/ShiftOS.Main/Apps/Pong.cs @@ -47,16 +47,27 @@ namespace ShiftOS.Main.Apps ball.Top -= (int)ballY; 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) { ResetToRest(); ballX = -ballX; } - if (ball.Left + ball.Width > this.Height) + if (ball.Left + ball.Width > this.Width) { ResetToRest(); ballX = -ballX;