-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Description
/// <summary>
/// Informs the slime to grow by one segment.
/// </summary>
public void Grow()
{
// Capture the value of the tail segment
SlimeSegment tail = _segments[_segments.Count - 1];
// Create a new tail segment that is positioned a grid cell in the
// reverse direction from the tail moving to the tail.
SlimeSegment newTail = new SlimeSegment();
newTail.At = tail.To + tail.ReverseDirection * _stride;
newTail.To = tail.At;
newTail.Direction = Vector2.Normalize(tail.At - newTail.At);
// Add the new tail segment
_segments.Add(newTail);
}I encountered a confusing point while learning the 2D game tutorial on the official website. In Chapter 22: Snake Game Mechanics, in the Growth method of slime, newTail.At = tail.To + tail.ReverseDirection * _stride; doesn't this make newTail.At equal to tail.At?
Metadata
Metadata
Assignees
Labels
No labels