diff options
| author | Richie Moch <[email protected]> | 2018-12-23 23:41:07 -0600 |
|---|---|---|
| committer | Richie Moch <[email protected]> | 2018-12-23 23:41:07 -0600 |
| commit | 87546f325f6fb24dcc5ab34851cc06b074d79984 (patch) | |
| tree | 4905888bc331bc9bb9d5ca060a4a5811210213b2 /ShiftOS.Main/Apps/Pong.cs | |
| parent | 8f34b3a0c7118abb81526a3dc5f435ba8f8485f8 (diff) | |
| download | shiftos-rewind-87546f325f6fb24dcc5ab34851cc06b074d79984.tar.gz shiftos-rewind-87546f325f6fb24dcc5ab34851cc06b074d79984.tar.bz2 shiftos-rewind-87546f325f6fb24dcc5ab34851cc06b074d79984.zip | |
Wrote Breakout, and only with minimal bugs this time!
Diffstat (limited to 'ShiftOS.Main/Apps/Pong.cs')
| -rw-r--r-- | ShiftOS.Main/Apps/Pong.cs | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/ShiftOS.Main/Apps/Pong.cs b/ShiftOS.Main/Apps/Pong.cs deleted file mode 100644 index cde3c31..0000000 --- a/ShiftOS.Main/Apps/Pong.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace ShiftOS.Main.Apps -{ - public partial class Pong : UserControl - { - bool goUp = false; - bool goDown = false; - int speed = 5; - float ballX = 5; - float ballY = 5; - public Pong() - { - InitializeComponent(); - gameTimer.Start(); - ResetToRest(); - } - void ResetToRest() - { - ball.Location = new Point((int)Math.Round(this.Width / 2d, 0), (int)Math.Round(this.Height / 2d, 0)); - playerPaddle.Location = new Point(playerPaddle.Location.X, (int)Math.Round(this.Height / 2d, 0)); - cpuPaddle.Location = new Point(cpuPaddle.Location.X, (int)Math.Round(this.Height / 2d, 0)); - } - - private void Pong_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.W) goUp = true; - if (e.KeyCode == Keys.S) goDown = true; - } - - private void Pong_KeyUp(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.W) goUp = false; - if (e.KeyCode == Keys.S) goDown = false; - } - - private void gameTimer_Tick(object sender, EventArgs e) - { - ball.Top -= (int)ballY; - ball.Left -= (int)ballX; - - - - //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.Width) - { - ResetToRest(); - ballX = -ballX; - } - if (ball.Top < 0 || ball.Top + ball.Height > this.Height) ballY = -ballY; - if (ball.Bounds.IntersectsWith(playerPaddle.Bounds) || ball.Bounds.IntersectsWith(cpuPaddle.Bounds)) ballX = -ballX; - - if (goUp && playerPaddle.Top > 0) playerPaddle.Top -= 8; - if (goDown && playerPaddle.Top < this.Height) playerPaddle.Top += 8; - - } - } -} |
