示例#1
0
 public void AddPart(Color col)
 {
     SnakePart prevTail = body.ElementAt(body.Count - 1);
     SnakePart tail = new SnakePart(prevTail.X,prevTail.Y,prevTail.direction,false,size);
     tail.brush = col;
     body.Add(tail);
     score += 3;
 }
示例#2
0
 public SnakeDoc(int x, int y,int s)
 {
     body = new List<SnakePart>();
     size = s;
     head = new SnakePart(x, y, Direction.LEFT, true,size);
     body.Add(head);
     SnakePart tail = new SnakePart(x + 1, y, Direction.LEFT, false, size);
     body.Add(tail);
     score = 0;
     IsOutOfBounds = false;
     foodIsEaten = false;
 }
示例#3
0
        public void ChangeDirection(Direction newD)
        {
            SnakePart part = body.ElementAt(1);

            if ((head.X == part.X && (newD == Direction.UP || newD == Direction.DOWN)) ||
                (head.Y == part.Y && (newD == Direction.LEFT || newD == Direction.RIGHT)))
            {
                return;
            }

            head.direction = newD;
        }
示例#4
0
        public SnakeDoc(int x, int y, int s)
        {
            body = new List <SnakePart>();
            size = s;
            head = new SnakePart(x, y, Direction.LEFT, true, size);
            body.Add(head);
            SnakePart tail = new SnakePart(x + 1, y, Direction.LEFT, false, size);

            body.Add(tail);
            score         = 0;
            IsOutOfBounds = false;
            foodIsEaten   = false;
        }