mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-22 18:02:16 +00:00
tail stuff
This commit is contained in:
parent
29a6c631ca
commit
85ae3a820a
1 changed files with 53 additions and 1 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue