diff options
| author | lempamo <[email protected]> | 2017-02-28 17:41:18 -0500 |
|---|---|---|
| committer | lempamo <[email protected]> | 2017-02-28 17:41:18 -0500 |
| commit | 85ae3a820a9a41550c98d55cbaf95beb923d8746 (patch) | |
| tree | 725ff73c9e069b52e91c40d67a8a1a9f9df190df /ShiftOS.WinForms/Applications | |
| parent | 29a6c631ca65c2914ea657c0150e272167d2e0d2 (diff) | |
| download | shiftos_thereturn-85ae3a820a9a41550c98d55cbaf95beb923d8746.tar.gz shiftos_thereturn-85ae3a820a9a41550c98d55cbaf95beb923d8746.tar.bz2 shiftos_thereturn-85ae3a820a9a41550c98d55cbaf95beb923d8746.zip | |
tail stuff
Diffstat (limited to 'ShiftOS.WinForms/Applications')
| -rw-r--r-- | ShiftOS.WinForms/Applications/Snakey.cs | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/ShiftOS.WinForms/Applications/Snakey.cs b/ShiftOS.WinForms/Applications/Snakey.cs index 94dd671..17c7c85 100644 --- a/ShiftOS.WinForms/Applications/Snakey.cs +++ b/ShiftOS.WinForms/Applications/Snakey.cs @@ -38,6 +38,7 @@ namespace ShiftOS.WinForms.Applications private void updateSnake(object sender, EventArgs e) { PictureBox head = null; + PictureBox tail = null; for (int x = 0; x < 10; x++) { @@ -53,12 +54,32 @@ namespace ShiftOS.WinForms.Applications } } + for (int x = 0; x < 10; x++) + { + if (tail != null) break; + for (int y = 0; y < 10; y++) + { + if (tail != null) break; + if (snakemap[x, y] == 3) + { + tail = (PictureBox)tableLayoutPanel1.GetControlFromPosition(x, y); + break; + } + } + } + int headX = int.Parse(head.Name.Split('b')[1]); int headY = int.Parse(head.Name.Split('b')[2]); int newHeadX = headX; int newHeadY = headY; + int tailX = int.Parse(tail.Name.Split('b')[1]); + int tailY = int.Parse(tail.Name.Split('b')[2]); + + int newTailX = tailX; + int newTailY = tailY; + Image headImg = null; switch (snakedirection) { @@ -95,7 +116,33 @@ namespace ShiftOS.WinForms.Applications ((PictureBox)tableLayoutPanel1.GetControlFromPosition(headX, headY)).Image = Properties.Resources.SnakeyBody; if (!extending) { + Image tailImg = null; + switch (tailDirection()) + { + case 0: + newTailX = tailX - 1; + break; + + case 1: + newTailY = tailY + 1; + break; + + case 2: + newTailX = tailX + 1; + break; + + case 3: + newTailY = tailY - 1; + break; + default: + break; + } + switch (nextTailDirection(newTailX, newTailY)) + { + default: + break; + } } if (extending) extending = false; if (newheadlocation == 1) @@ -104,6 +151,11 @@ namespace ShiftOS.WinForms.Applications } } + private int nextTailDirection(int x, int y) + { + return -1; + } + private void gameover() { throw new NotImplementedException(); @@ -219,7 +271,7 @@ namespace ShiftOS.WinForms.Applications } } - private int getTailDirection() + private int tailDirection() { PictureBox tail = null; |
