Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }