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; }
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; }
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; }
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; }