Пример #1
0
        // increments movement toward direction
        public void UpdatePosition(){
            // moves head
            var head = Body[0];
            switch (CardinalDirection){
                case EDirection.North:
                    Body[0] -= new Vector2D(0, 1);
                    break;
                case EDirection.South:
                    Body[0] += new Vector2D(0, 1);
                    break;
                case EDirection.East:
                    Body[0] += new Vector2D(1, 0);
                    break;
                case EDirection.West:
                    Body[0] -= new Vector2D(1, 0);
                    break;
            }

            // moves body after head, caterpillar style
            for (int i = 1; i < Body.Count; i++){
                Vector2D oldPos = Body[i];
                Body[i] = head;
                head = oldPos;
            }
        }
Пример #2
0
 public Snake(Vector2D startPosition, int playerCount){
     Id = playerCount;
     _t2 = new Stopwatch();
     for (int i = 0; i < 4; i++) {
         Body.Add(new Vector2D(startPosition));
     }
     CardinalDirection = EDirection.South;
 }
Пример #3
0
 public Apple(Vector2D startPosition) {
     Body.Add(new Vector2D(startPosition));
 }
Пример #4
0
 public Apple(Vector2D startPosition, int points) {
     Body.Add(new Vector2D(startPosition));
     Points = points;
 }