diff options
| author | lempamo <[email protected]> | 2017-02-28 17:18:46 -0500 |
|---|---|---|
| committer | lempamo <[email protected]> | 2017-02-28 17:19:36 -0500 |
| commit | 4c79d077c3616a5d2937540206448ed850660f18 (patch) | |
| tree | 35f7244a675544e01e67ed69021da8b0bf360a02 /ShiftOS.WinForms/Applications | |
| parent | bb4a3801623579296cf081f4e9172080d852bc7b (diff) | |
| download | shiftos_thereturn-4c79d077c3616a5d2937540206448ed850660f18.tar.gz shiftos_thereturn-4c79d077c3616a5d2937540206448ed850660f18.tar.bz2 shiftos_thereturn-4c79d077c3616a5d2937540206448ed850660f18.zip | |
setting up snakey froot
Diffstat (limited to 'ShiftOS.WinForms/Applications')
| -rw-r--r-- | ShiftOS.WinForms/Applications/Snakey.cs | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/ShiftOS.WinForms/Applications/Snakey.cs b/ShiftOS.WinForms/Applications/Snakey.cs index 560d2c0..8f3f7ea 100644 --- a/ShiftOS.WinForms/Applications/Snakey.cs +++ b/ShiftOS.WinForms/Applications/Snakey.cs @@ -87,6 +87,8 @@ namespace ShiftOS.WinForms.Applications } if (newHeadX > 9 || newHeadX < 0 || newHeadY > 9 || newHeadY < 0) return; + + int newheadlocation = snakemap[newHeadX, newHeadY]; snakemap[newHeadX, newHeadY] = 2; ((PictureBox)tableLayoutPanel1.GetControlFromPosition(newHeadX, newHeadY)).Image = headImg; snakemap[headX, headY] = 1; @@ -95,6 +97,16 @@ namespace ShiftOS.WinForms.Applications { } + if (extending) extending = false; + if (newheadlocation == 1) + { + gameover(); + } + } + + private void gameover() + { + throw new NotImplementedException(); } private void OnKeyDown(object sender, PreviewKeyDownEventArgs e) @@ -141,6 +153,7 @@ namespace ShiftOS.WinForms.Applications picBox.Size = new System.Drawing.Size(20, 20); picBox.Image = Properties.Resources.SnakeyBG; picBox.Name = "pb" + x.ToString() + "b" + y.ToString(); + picBox.Margin = new Padding(0); return picBox; } @@ -172,9 +185,27 @@ namespace ShiftOS.WinForms.Applications } snakemap[8, 5] = 3; ((PictureBox)tableLayoutPanel1.GetControlFromPosition(8, 5)).Image = Properties.Resources.SnakeyTailL; + placefruit(); snakeupdater.Start(); } + private void placefruit() + { + Random rnd1 = new Random(); + + while (true) + { + int fruitX = rnd1.Next(10); + int fruitY = rnd1.Next(10); + + if (snakemap[fruitX, fruitY] == 0) + { + snakemap[fruitX, fruitY] = 4; + break; + } + } + } + private void clearGame() { snakemap = null; @@ -210,7 +241,6 @@ namespace ShiftOS.WinForms.Applications return -1; } - - + } } |
