diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 3f06676..c260ae3 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -83,6 +83,15 @@ namespace ShiftOS.WinForms.Applications private string counter = ""; + private void Bounce(Rectangle ball, Rectangle paddle) + { + // reverse x velocity to send the ball the other way + xVel = -xVel; + + // adjust y velocity based on where the ball hit the paddle + yVel += linear((ball.Top + (ball.Height / 2)), paddle.Top, paddle.Bottom, -1, 1); + } + public void UpdateBall() { if (doBallCalc) @@ -141,11 +150,7 @@ namespace ShiftOS.WinForms.Applications //check if the ball x is greater than the player paddle's middle coordinate if (ballRect.Right >= opponentRect.Left) { - //reverse x velocity to send the ball the other way - xVel = -xVel; - - //set y velocity based on where the ball hit the paddle - yVel = linear((ballRect.Top + (ballRect.Height / 2)), opponentRect.Top, opponentRect.Bottom, -1, 1); + Bounce(ballRect, opponentRect); doAi = false; } @@ -169,11 +174,7 @@ namespace ShiftOS.WinForms.Applications { if (ballRect.Left <= playerRect.Right) { - //reverse x velocity to send the ball the other way - xVel = -xVel; - - //set y velocity based on where the ball hit the paddle - yVel = linear((ballRect.Top + (ballRect.Height / 2)), playerRect.Top, playerRect.Bottom, -1, 1); + Bounce(ballRect, playerRect); //reset the ai location aiBallX = ballX; @@ -255,15 +256,12 @@ namespace ShiftOS.WinForms.Applications new System.Threading.Thread(() => { doBallCalc = false; - counter = "3"; - Engine.AudioManager.PlayStream(Properties.Resources.writesound); - System.Threading.Thread.Sleep(1000); - counter = "2"; - Engine.AudioManager.PlayStream(Properties.Resources.writesound); - System.Threading.Thread.Sleep(1000); - counter = "1"; - Engine.AudioManager.PlayStream(Properties.Resources.writesound); - System.Threading.Thread.Sleep(1000); + for (int i = 3; i > 0; i--) + { + counter = i.ToString(); + Engine.AudioManager.PlayStream(Properties.Resources.writesound); + System.Threading.Thread.Sleep(1000); + } doBallCalc = true; header = ""; counter = ""; diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 82d99f0..e8ad298 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -824,7 +824,7 @@ namespace ShiftOS.WinForms item.Text = Localization.Parse("{SHUTDOWN}"); item.Click += (o, a) => { - TerminalBackend.InvokeCommand("sos.shutdown"); + TerminalBackend.InvokeCommand("shutdown"); }; apps.DropDownItems.Add(item); if (Shiftorium.UpgradeInstalled("advanced_app_launcher")) @@ -853,7 +853,7 @@ namespace ShiftOS.WinForms catbtn.Height = 24; flcategories.Controls.Add(catbtn); catbtn.Show(); - catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("sos.shutdown"); + catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("shutdown"); } } } @@ -1109,7 +1109,7 @@ namespace ShiftOS.WinForms private void btnshutdown_Click(object sender, EventArgs e) { - TerminalBackend.InvokeCommand("sos.shutdown"); + TerminalBackend.InvokeCommand("shutdown"); } public void HideAppLauncher()