aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications/Pong.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-06-16 20:36:43 -0400
committerMichael <[email protected]>2017-06-16 20:36:43 -0400
commit79fe2101aef62b744b150203dee6953b0d17f5aa (patch)
tree0999c7c61bf9161df6f7ad96917f90a0487e485f /ShiftOS.WinForms/Applications/Pong.cs
parenteb4b032b355e7a1477a73fae9ba7a379314c4c4b (diff)
downloadshiftos_thereturn-79fe2101aef62b744b150203dee6953b0d17f5aa.tar.gz
shiftos_thereturn-79fe2101aef62b744b150203dee6953b0d17f5aa.tar.bz2
shiftos_thereturn-79fe2101aef62b744b150203dee6953b0d17f5aa.zip
Get rid of namespaces in commands.
Diffstat (limited to 'ShiftOS.WinForms/Applications/Pong.cs')
-rw-r--r--ShiftOS.WinForms/Applications/Pong.cs25
1 files changed, 24 insertions, 1 deletions
diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs
index 87b7a93..3f06676 100644
--- a/ShiftOS.WinForms/Applications/Pong.cs
+++ b/ShiftOS.WinForms/Applications/Pong.cs
@@ -42,6 +42,15 @@ namespace ShiftOS.WinForms.Applications
LevelComplete();
}
};
+#if DEBUG
+ this.KeyDown += (o, a) =>
+ {
+ if(a.KeyCode == Keys.D)
+ {
+ drawAiBall = !drawAiBall;
+ }
+ };
+#endif
}
private double ballX = 0.0f;
@@ -266,11 +275,14 @@ namespace ShiftOS.WinForms.Applications
ballX = 0;
ballY = 0;
opponentY = 0;
+ xVel = 1;
aiBallX = 0;
aiBallY = 0;
doAi = true;
}
+ private bool drawAiBall = false;
+
private void pnlcanvas_Paint(object sender, PaintEventArgs e)
{
@@ -281,11 +293,22 @@ namespace ShiftOS.WinForms.Applications
ballXLocal -= ((double)paddleWidth / 2);
ballYLocal -= ((double)paddleWidth / 2);
+ double aiballXLocal = linear(aiBallX, -1.0, 1.0, 0, pnlcanvas.Width);
+ double aiballYLocal = linear(aiBallY, -1.0, 1.0, 0, pnlcanvas.Height);
+
+ aiballXLocal -= ((double)paddleWidth / 2);
+ aiballYLocal -= ((double)paddleWidth / 2);
+
e.Graphics.Clear(pnlcanvas.BackColor);
+ //draw the ai ball
+ if (drawAiBall)
+ e.Graphics.FillEllipse(new SolidBrush(Color.Gray), new RectangleF((float)aiballXLocal, (float)aiballYLocal, (float)paddleWidth, (float)paddleWidth));
+
+
//draw the ball
- if(doBallCalc)
+ if (doBallCalc)
e.Graphics.FillEllipse(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)ballXLocal, (float)ballYLocal, (float)paddleWidth, (float)paddleWidth));
double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height);