public Snake(Point tail, int length, Direktion _direktion) { direktion = _direktion; pList = new List <Point>(); for (int i = 0; i < length; i++) { Point p = new Point(tail); p.Move(i, i, direktion); pList.Add(p); } }
public void Move(int offsetHorizontal, int offsetVertical, Direktion direktion) { if (direktion == Direktion.LEFT) { x = x - offsetHorizontal; } else if (direktion == Direktion.RIGHT) { x = x + offsetHorizontal; } else if (direktion == Direktion.TOP) { y = y - offsetVertical; } else if (direktion == Direktion.BOTTOM) { y = y + offsetVertical; } }
public void HendleKey(ConsoleKey key) { if (key == ConsoleKey.LeftArrow && direktion != Direktion.RIGHT) { direktion = Direktion.LEFT; } else if (key == ConsoleKey.RightArrow && direktion != Direktion.LEFT) { direktion = Direktion.RIGHT; } else if (key == ConsoleKey.UpArrow && direktion != Direktion.BOTTOM) { direktion = Direktion.TOP; } else if (key == ConsoleKey.DownArrow && direktion != Direktion.TOP) { direktion = Direktion.BOTTOM; } }