From 4c79d077c3616a5d2937540206448ed850660f18 Mon Sep 17 00:00:00 2001 From: lempamo Date: Tue, 28 Feb 2017 17:18:46 -0500 Subject: [PATCH] setting up snakey froot --- ShiftOS.WinForms/Applications/Snakey.cs | 34 ++++++++++++++++-- .../Properties/Resources.Designer.cs | 10 ++++++ ShiftOS.WinForms/Properties/Resources.resx | 3 ++ ShiftOS.WinForms/Resources/SnakeyFruit.png | Bin 0 -> 239 bytes 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 ShiftOS.WinForms/Resources/SnakeyFruit.png 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; } - - + } } diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index 289c980..9262790 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -968,6 +968,16 @@ namespace ShiftOS.WinForms.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SnakeyFruit { + get { + object obj = ResourceManager.GetObject("SnakeyFruit", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index 8fbc6d3..a5e2d4e 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -445,6 +445,9 @@ ..\Resources\SnakeyBody.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\SnakeyFruit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\SnakeyHeadD.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/ShiftOS.WinForms/Resources/SnakeyFruit.png b/ShiftOS.WinForms/Resources/SnakeyFruit.png new file mode 100644 index 0000000000000000000000000000000000000000..4279e63a33848a56d83abc6beb4602e22e639f4d GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VOS+@4BLl<6e(pbstUx|zfk$L9 z0|Vb75M~tB@M-`GN|v}rlmzFem6RtIr7{#GX6BXX<)xM=nCKbk85)}~M^^zA<#@U{ zhFJK&J>$rAK!L|4@O^#eZ|x~Ab6Y)c#kQJHIJo5FuhS`!il-YVT!~ND?^MnbFLrEM z^Ls<1$4B!7=82E;7nHsED1T+X(mwkN<)A;jHyoDyke