示例#1
0
        public void Update()
        {
            if (this.Body.Count == 0)
            {
                return;
            }

            Coordinates lastBodyPartCoordinates = new Coordinates(this.Body[0].Position.X, this.Body[0].Position.Y);

            this.UpdateHead();

            if (this.Body.Count == 1)
            {
                return;
            }

            this.UpdateTail(lastBodyPartCoordinates);
        }
示例#2
0
文件: snake.cs 项目: begoon/stuff
 private char SnakeBodyCharacter(Coordinates position)
 {
     return position == SnakeHead ? SnakeHeadCharacter() : '@';
 }
示例#3
0
 private void UpdateTail(Coordinates lastBodyPartCoordinates)
 {
     for (int index = 1; index < this.Body.Count; index++)
     {
         Coordinates currentBodyPartCoordinates = new Coordinates(this.Body[index].Position.X, this.Body[index].Position.Y);
         this.Body[index].Position.X = lastBodyPartCoordinates.X;
         this.Body[index].Position.Y = lastBodyPartCoordinates.Y;
         lastBodyPartCoordinates = currentBodyPartCoordinates;
     }
 }