mirror of
https://github.com/ShiftOS-Rewind/ShiftOS.git
synced 2025-01-22 17:52:15 +00:00
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:
parent
bca879db94
commit
8f34b3a0c7
1 changed files with 14 additions and 3 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue