Esempio n. 1
0
 public void Update(SnakeBodyPart parentPart)
 {
     // Where is my parent?
     parentPosition.SetTo(parentPart.position);
     // If my parent is not in the way...
     if (!targetPosition.Equals(parentPosition))
     {
         // Save my previous position
         previousPosition.SetTo(position);
         // Move me to there
         position.SetTo(targetPosition);
         // Then set my new target
         targetPosition.SetTo(parentPosition);
     }
 }
Esempio n. 2
0
 public void Grow()
 {
     /* Create new bodypart at the tail of the snake. */
     SnakeBodyPart newPart = new SnakeBodyPart(
         texture,
         bodyParts.Last().previousPosition);
     /* Set the parts attributes to appropriate values to reflect
      * its parent/super-part. */
     newPart.parentPosition.SetTo(bodyParts.Last().position);
     newPart.targetPosition.SetTo(bodyParts.Last().position);
     newPart.previousPosition.SetTo(trailPosition);
     bodyParts.Add(newPart);
     this.length++;
 }